Dark's Code Dump

Possibly useful

8mm film telecine: a software approach

There are many posts online singing the praises of 8mm telecine by scanning individual frames with a macro lens or scanner. And rightfully so – in the average case it produces better results than the alternative of realtime recording of a video projected on to a wall, projected within a film transfer box, or ‘directly’ using a special lens configuration.

With these assumptions, along with a first attempt filmed off a wall that looked mediocre at best, I went on a wild goose chase trying to build a hardware solution to what I perceived to be the greatest issues with filming off a wall: focus, frame blending and the rolling shutter effect. The focus seemed consistently worse than it could have been due to multiple variables at play: projector lens zoom, projector lens focus, camera focus, camera position, original film not always perfectly focused. To capture a flicker-free image, I found the framerate and shutter of the camera had to be configured to span potentially multiple frames of the original, which introduced a nasty blending effect. Motion appeared nice and smooth, but panning lost all detail, and ghost images occurred across transitions. Panning exhibited rolling shutter / ‘jello’ effect, vaguely similar to the tearing that results from lack of vsync, where the top half of the image would be a frame different from the bottom half.

I tried using a Sankyo variable speed projector, but it had failed to stand the test of time and had multiple issues (microswitch failures, film gate misaligned/broken). I tried focusing using a reversed lens macro configuration in conjunction with the projector lens pulled out further than usual – this resulted in a full frame in reasonable focus, but with bad chromatic aberration everywhere but the centre. Perhaps this would have worked with a macro setup with a longer working distance (max I could achieve was about 0.5cm too short), eliminating the need for the projector lens, which may have been the source of the CA. Finally, I investigated a hardware solution to run the projector off a controllable motor to advance frame by frame, but decided to save that as a last resort due to the level of hassle involved.

Eventually I came to the solution of using software to tidy up the ‘recording the wall’ approach to the same level of quality that I have seen from professional telecine with a proper machine.

Requirements

  • Canon DSLR supporting Magic Lantern and video DPAF (I used a 70D)
  • Fast normal lens with minimal distortion (I used a Sigma 30mm Art f1.4 stepped down to f2.0)
  • Projector with half or variable speed control (I used a Eumig with 9fps and 18fps options)
  • A4 paper stuck on wall

I consider this a ‘software approach’ due to the lack of hardware mods or unusual hardware configurations. The only hardware involved is the bare minimum of a camera and projector.

The process is as follows:

Capture

The process of capturing is straight forward – the projector is set far enough away from the A4 sheet to project a roughly A5-sized image without excessive zoom and without excessive light bleeding – for me this was 60-80cm. The camera is set wherever it can be to capture with minimal black borders and minimal keystone distortion – for me this was on a pile of books touching the front of the projector, slightly off to one side to avoid covering the projector lens.

Settings are as follows:

  • Projector at 9 fps (half speed)
  • ISO 100
  • f/2.0 or equivalent to avoid clipping highlights/shadows at ISO 100
  • 1/50 shutter (for 50hz mains)
  • Magic Lantern video FPS Override set to 34 fps and ‘Optimize for’: ‘HiJello’ (34 fps is a made up value with no basis other than it visually works for me, may need adjusting for your case)
  • Magic Lantern Raw Video enabled, I had it set to 4:3 1056×792 12-bit lossless, but your camera/SD card may be capable of more
  • Sound recording disabled to avoid ML bugs (not that it is needed!)
  • May also need focus peaking disabled to avoid pink frames during long recording
  • Auto focus enabled – the DPAF tends to pick up the grain of the paper and not lose focus, and produces results with better focus than humanly possible

For the Eumig projector I used, the lens holder flips outward when rewinding, so focus is lost between playback sessions. I had to manually re-set the projector lens focus at the start of each recording, but not a big deal.

Processing

Step 1
Open the raw video with MLVApp. The default tonemapping is iffy for this kind of work, so change to Rec. 709 and gamma to 2.0. Set the colour temperature to a reasonable middle ground for the whole film – it will be dynamically overridden later so does not need to be perfect. Adjust the Dark Strength, Dark Range, Highlights and Shadows sliders to give the best dynamic range you can while maintaining black blacks and minimal clipping/noise. I found I also had to increase Raw Black Level by 3, and Raw White Level by a few hundred. Increase denoising, sharpening and saturation as you see fit – this is the best stage for these changes.
Export to a high quality interim format – I used Apple ProRes 422 HQ.

Step 2
Process with AVISynth using the following script. The only changes needed should be the filename at the top and dimensions to reform(). For some more problematic films, I had better luck with specifying a specific lockchan to GamMac, and setting gammax.

Points of interest are:

  • assumefps() compensates for the recording speed, as the MLV comes out at 30 fps, but for 1:1 speed with the original it should be played at 68 fps.
  • srestore() produces a visually perfect conversion to 30 fps in one step, removing all frame blending and rolling shutter artifacts, and preparing the result for better playback on modern 60hz displays.
  • reform() performs keystone correction to produce a straight-edged 4:3 image.
  • At this point there is a near-perfect telecine’d result, the rest is at your discretion as it does remove the old fashioned look.
  • RemoveDirtSMC() with a large threshold removes most of the dust and imperfections on the film, alleviating the need to physically clean the film.
  • McDegrainSharp() does a fantastic job of denoise and degrain, hard to tell the original is 8mm film after this!
  • GamMac() is simply black magic – removes colour cast and fine tunes the white balance throughout. The settings given took a lot of trial and error, but have not needed changed for 90% of films I’ve run through this.
original=ffms2("E:\m29-1904.mov")
original=original.assumefps(68)
source=original
source=source.ConvertTo8bit()
source=source.srestore(frate=30.00, speed=-16, omode=6).filldrops()

bg = blankclip(source)
# MANUALLY GATHER THESE DIMENSIONS FOR EACH VIDEO AND UNCOMMENT
#source=source.reform(bg, qr=true, ltopx=66,ltopy=11, lbotx=80,lboty=725, rtopx=982,rtopy=28, rbotx=977,rboty=702)

usegammac=true
source=source.RemoveDirtSMC(90)
source=source.McDegrainSharp()
if (usegammac)
{
    rgbsource=source.ConvertToRGB24(matrix="Rec709")
    gammacborder=150
    rgbsource=rgbsource.GamMac(show=false, lockchan=-3, loTH=0.0004, hiTh=0.04, x=gammacborder, y=gammacborder, w=-gammacborder, h=-gammacborder, scale=2)
    source=rgbsource.ConvertBackToYUY2(matrix="Rec709")
    source=source.Tweak(sat=1.05)
}

return source
#return original

In terms of software I used AvsPmod (GUI editor), Avisynth Plus x64, Avs2YUV and FFMPEG. Gathering the plugins was easier said than done, so to save the effort, and hopefully not in breach of any licenses, here is my entire plugins directory: avisynth-x64-plugins.zip

My command line was:

avs2yuv64.exe cine8mm.avs -o - | ffmpeg -i pipe: -c:v prores_ks -profile:v 3 -vf vidstabdetect=shakiness=5:accuracy=15:stepsize=6:mincontrast=0.3 out.mov

Step 3
The final stage is to perform stabilisation with the gold standard algorithm – libvidstab. This simultaneously compensates for slight timing imperfections in the original and projector, as well as actually stabilising the (handheld) footage. Camera pans end up silky smooth on 60hz displays, while motion is left as-is without fake interpolation.

You may need to recompile ffmpeg to enable this, though I found it comes as standard in the ffmpeg.exe included with ImageMagick. I found I had to almost completely disable angular stabilisation (maxangle) or scene changes happen via a weird rotation rather than sharply transitioning. maxshift is set to the maximum possible that does not jump about too wildly during fast pans.

ffmpeg -i out.mov -vf vidstabtransform=input="transforms.trf":zoom=0:optzoom=1:maxshift=10:maxangle=0.0005,unsharp=5:5:0.8:3:3:0.4 -c:v libx264 -profile:v high -level 4.1 -preset veryslow -pix_fmt yuv420p -crf 23 -tune film out.mkv

CRF 23 might seem a bit high for the final master copy, but interestingly I found that a moderate level of x264 compression makes the result look better!

Example final output

tl;dr: Capturing off a wall is better than trying to project an image directly on to a DSLR sensor, unless you are prepared to take apart lenses and build a custom lens. Processing the result of a wall capture in software correctly can produce a final result comparable with professional telecine.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.