brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ffmpeg -vf yadif removes the comb lines from old interlaced video

Ffmpeg
~/tips/tip-ffmpeg-yadif-deinterlace

ffmpeg -i tape.avi -vf yadif -c:v libx264 -crf 20 -c:a aac tape.mp4

Deinterlaces old TV or camcorder footage so moving parts don't show striped edges.

Footage from old camcorders, DVDs of TV shows and digitized VHS tapes is often interlaced. On a computer screen that shows as thin horizontal stripes along anything that moves.

ffmpeg -i tape.avi -vf yadif -c:v libx264 -crf 20 -c:a aac tape.mp4

yadif (“yet another deinterlacing filter”) rebuilds full frames from the two half-frames of each interlaced frame. With the default settings you get one output frame per input frame, so a 25 fps PAL video stays 25 fps.

For smoother motion, yadif=1 makes one frame per field, which doubles the rate to 50 fps. Sports and fast camera moves look a lot better that way, and the file grows a bit.

Don’t run it on everything. Progressive video, which is nearly all modern phone and camera footage, gets slightly softer from yadif for no reason. To check a file, run ffmpeg -i tape.avi -vf idet -frames:v 500 -f null - and read the “Multi frame detection” line at the end (ffmpeg may print one full of zeros first; skip that one). If most frames are counted as TFF or BFF, it’s interlaced; if most are progressive, leave it alone. There are better but slower deinterlacers too, like bwdif, which I’d try when yadif leaves artifacts.

Further reading: FFmpeg filters documentation

More Ffmpeg tips ffmpeg -stream_loop 2 -i in.mp4 -c copy out.mp4 ffmpeg -i in.mp4 \ ffmpeg -i video.mp4 -i video.en.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=eng video-subs.mp4 ffmpeg -i film.mkv -map 0:v -map 0:a:0 -c:v copy -c:a aac -b:a 192k -ac 2 film-stereo.mkv ffmpeg -i talk.mp4 -vn -c:a copy talk.m4a All Ffmpeg tips (38) All topics

Link