7

Digitize a VHS tape with FFmpeg

On this thread, I found a perfect command to digitize a VHS tape with FFmpeg using a USB video grabber. All good with that; it works like a charm. Acceptable bitrate, no dropped frames and, most importantly, a good output file.

Working command:

ffmpeg \
-f v4l2 -standard PAL -thread_queue_size 2048 -i /dev/video1 \
-f alsa -thread_queue_size 2048 -i hw:2,0 \ 
-vcodec libx264 -preset superfast -crf 23 -vf yadif=1 \
-acodec libmp3lame -b:a 128k -channels 2 -ar 48000 \
vhs_output.mov

Question: How to get a live preview?

I've read numerous threads talking about pipes and tee objects, but I still haven't figured out how to get a live preview.

My try for a ffplay pipe:

ffmpeg \
-f v4l2 -standard PAL -thread_queue_size 2048 -i /dev/video1 \
-f alsa -thread_queue_size 2048 -i hw:2,0 \ 
-vcodec libx264 -preset superfast -crf 23 -vf yadif=1 \
-acodec libmp3lame -b:a 128k -channels 2 -ar 48000 \
vhs_output.mov \
-f h264 - | ffplay -

The problem with this command is that there are now two x264 encoders active. Secondly, the preview isn't as fluid as the output since there are now lot's of dropped frames. Where have I gone wrong? How can I reuse the first output? Raw piping isn't an option since ffplay can't handle it.

1 Answer 1

7

The tee muxer is suitable for this.

ffmpeg \
-f v4l2 -standard PAL -thread_queue_size 2048 -i /dev/video1 \
-f alsa -thread_queue_size 2048 -i hw:2,0 \
-map 0 -map 1 \
-vf yadif=1 \
-vcodec libx264 -preset superfast -crf 23 -flags +global_header \
-acodec libmp3lame -b:a 128k -ac 2 -ar 48000 \
-f tee "vhs_output.mov|[f=nut:onfail=ignore]pipe:1" | ffplay -
3
  • Yes, now it can encode without dropping frames using the tee object. On the other hander, the FFplay window never appeared. I've got this message "pipe:: Invalid data found when processing input" after safely exiting FFmpeg. I also notice that there are two files created. ("vhs_output.mov" and " -") May 11, 2018 at 16:17
  • See edited command
    – Gyan
    May 11, 2018 at 16:54
  • Thank you, that did the trick! I hope that it can help others for similar purposes. May 11, 2018 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.