Ffmpeg: how to create an interlaced h.264 video

ffmpegh.264video-encodingx264

I would like to convert a high quality non interlaced input video into a less quality but wider distributable H.264/MP4 format. The output should have some constraints – in particular: it should be interlaced!

I tried the following command, where mandelbrot is a synonymous for the high quality input:

ffmpeg -hide_banner \
    -t 10 -y \
    -f lavfi \
    -i anullsrc=r=48k:cl=stereo \
    -f lavfi \
    -i mandelbrot=r=50:size=1920x1080 \
    -vf 'interlace=scan=tff:lowpass=complex,format=yuv420p' \
    -codec:a aac \
    -b:a 128k \
    -aac_coder twoloop \
    -codec:v libx264 \
    -preset veryfast \
    -tune animation \
    -profile:v high \
    -crf 35 \
    -level 5.2 \
    -x264opts interlaced=1 \
    -shortest \
    mandelbrot.mp4

My ffmpeg is ffmpeg version 3.4.2-2.

However, I am not sure that the command line is correct.

  • libx264 does not detect an interlaced input by itself. I have to insert -x264opts interlaced=1.
  • Other faq's tell something about -flags +ilme+ildct

Can you confirm my parameters? Thank you very much.

Best Answer

Finally I got excellent results with

ffmpeg \
 -y \
 -hide_banner \
 -i "${INPUT_FILE}" \
 \
 [... audio ...]\
 \
 -vf tinterlace=interleave_top,fieldorder=tff \
 -crf 28 \
 -preset placebo \
 [... more video ...]\
 -codec:v libx264 \
 \
 -f mp4 \
 -flags +ildct+ilme \
 [... more muxing ...]\
 \
 "${OUTPUT_FILE}"
Related Question