Video with Linux

Slow Motion Video in Linux

The workflow described here starts with interlaced 60i video, uses motion adaptive deinterlacing to convert it to 60p and then reinterprets this as 30p video for a slow motion effect. We slow the audio down as well. This results in a video clip with remarkably smooth slow motion and rather silly sound. We give examples using standard and high definition sources.

Needed Software

This method relies only on open source software. Note that the -interlace option is not present in standard versions of ffmpeg and you will need my patchs discussed in DVD complaint mpeg2 on Linux to use it. Alternatively, you can leave this option out wherever it appears below because the results should be the same anyway.

Standard Definition DV Source

In this section we assume that s001.avi is standard-definition interlaced video captured from a widescreen miniDV camcorder. Details about how to obtain such a video source file are given in DV Video Workflow in Linux. Our goal is to convert this video clip to a slow motion video clip with the same video and audio format. The commands are
$ ffmpeg -i s001.avi -f s16le -y s001.raw
$ sox -V -s -w -c2 -r24000 s001.raw -r48000 s001-slow.wav
$ ffmpeg -i s001.avi -f yuv4mpegpipe -pix_fmt yuv411p -y /dev/stdout |
    yuvcorrect -T INTERLACED_BOTTOM_FIRST 2>/dev/null |
    yuvdeinterlace -d |
    yuvfps -s 30000:1001 -r 30000:1001 |
    yuvcorrect -T PROGRESSIVE 2>/dev/null |
    ffmpeg -f yuv4mpegpipe -i /dev/stdin -i s001-slow.wav \
        -interlace 0 -vcodec dvvideo -acodec pcm_s16le \
        -y s001-slow.avi
It is worth pointing out that since all processing is done using the yuv411p colorspace a recent version of mjpegtools is needed.

High Definition HDV Source

In this section we assume that hd001.mpg is high-definition interlaced video captured from a HDV camcorder. Details about how to obtain such a video source file are given in HD Video Workflow in Linux. Again, our goal is to convert this video clip to a slow motion video clip with the same video and audio format. The commands are
$ ffmpeg -i hd001.mpg -f s16le -y hd001.raw
$ sox -V -s -w -c2 -r24000 hd001.raw -r48000 hd001-slow.wav
$ toolame -b384 -s48 hd001-slow.wav hd001-slow.m2a
$ ffmpeg -i hd001.mpg -f yuv4mpegpipe -pix_fmt yuv420p -y /dev/stdout |
    yuvcorrect -T INTERLACED_TOP_FIRST 2>/dev/null |
    yuvdeinterlace -d |
    yuvfps -s 30000:1001 -r 30000:1001 |
    yuvcorrect -T PROGRESSIVE 2>/dev/null |
    mpeg2enc --no-constraints -f3 -nn -a3 -Ktmpgenc -lh \
        -b24000 -V488 -r32 -G18 -q9 -s -o hd001-slow.m2v
$ mplex -f3 hd001-slow.m2v hd001-slow.m2a -r28000 -b800 -o hd001-slow.mpg
Note that mpeg2 video clips from a standard definition DVD camcorder can similarly be converted to a slow motion video clip. The only change necessary is to set the bitrate as -b7500 in the ecoding step.

Conclusions

Motion adaptive deinterlacing allows one to create smooth slow motion from interlaced camcorder footage. If the slow motion created above is not smooth it probably means you got the interlacing order wrong in the yuvcorrect command just before the yuvdeinterlace. Switch the order and check if this improves things. The resulting files can be imported into Cinelerra and edited along with regular clips straight off the camera.
Last Updated: Thu Jul 16 17:27:55 PDT 2009