3

My input is as follows:

Input #0, mpeg, from 'D:\Videos\2015.mpg':
Duration: 01:49:08.74, start: 0.220000, bitrate: 4940 kb/s
Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, bt470bg), 720x576 [SAR 16:15 DAR 4:3], max. 7500 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 224 kb/s

The file is almost 4GB for less than 2 hours. It's typical (or maybe even slightly worse than typical) VHS quality with interspersed blank screens for a few minutes (hence need for VBR).

CPU is 4-core Inteal 3770K: MMX2 SSE2Fast SSSE3 SSE4.2 AVX

Question: what ffmpeg parameters should I use to convert this input to MP4(H264/AAC) reasonably quickly (several times faster than actual rate, i.e. for this file in no more than 30 minutes) and reducing file size by at least a half. I guess quality is of a lesser concern since it's a VHS rip anyways, and there is plenty of static and artifacts. What command line switches (for Windows) should I use?

EDIT/UPDATE/BACKSTORY:

After a suggestion I am elaborating a bit... I would have loved to use ffmpeg directly to capture VHS video into MP4, but the problem is that my capture devise driver is configured/installed as so:

C:\Tools\video.tools\ffmpeg-20151123-git-12a419d-win64-static\bin>ffmpeg -loglevel verbose -list_options true -f dshow -i video="ezcap Video Grabber" -loglevel verbose
ffmpeg version N-76822-g12a419d Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55.  9.100 / 55.  9.100
  libavcodec     57. 16.100 / 57. 16.100
  libavformat    57. 19.100 / 57. 19.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 15.100 /  6. 15.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
[dshow @ 0000018baeadb920] DirectShow video device options (from video devices)
[dshow @ 0000018baeadb920]  Pin "Video YUV Out" (alternative pin name "2")
[dshow @ 0000018baeadb920]   pixel_format=uyvy422  min s=160x120 fps=25 max s=720x576 fps=25
[dshow @ 0000018baeadb920]   pixel_format=uyvy422  min s=160x120 fps=29.97 max s=720x486 fps=29.97
[dshow @ 0000018baeadb920]   pixel_format=uyvy422  min s=160x120 fps=29.97 max s=720x480 fps=29.97
[dshow @ 0000018baeadb920]  Pin "Audio PCM Out" (alternative pin name "3")
[dshow @ 0000018baeadb920] Crossbar Switching Information for ezcap Video Grabber:
[dshow @ 0000018baeadb920]   Crossbar Output pin 0: "Video Decoder" related output pin: 1 current input pin: 1 compatible input pins: 1 2
[dshow @ 0000018baeadb920]   Crossbar Output pin 1: "Audio Decoder" related output pin: 0 current input pin: 5 compatible input pins: 5
[dshow @ 0000018baeadb920]   Crossbar Input pin 0 - "Video Tuner" related input pin: 4
[dshow @ 0000018baeadb920]   Crossbar Input pin 1 - "Video Composite" related input pin: 5
[dshow @ 0000018baeadb920]   Crossbar Input pin 2 - "S-Video" related input pin: 5
[dshow @ 0000018baeadb920]   Crossbar Input pin 3 - "Video YRYBY" related input pin: 5
[dshow @ 0000018baeadb920]   Crossbar Input pin 4 - "Audio Tuner" related input pin: 0
[dshow @ 0000018baeadb920]   Crossbar Input pin 5 - "Audio Line" related input pin: 1

The issue is that there is no separate DirectShow Audio device - only Video device (which has both Video and Audio pins). ffmpeg seems to have issues trying to capture both video+audio with such a setup:

ffmpeg -loglevel verbose -f dshow -i video="ezcap Video Grabber":audio="ezcap Video Grabber" test5.mp4
ffmpeg version N-76822-g12a419d Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55.  9.100 / 55.  9.100
  libavcodec     57. 16.100 / 57. 16.100
  libavformat    57. 19.100 / 57. 19.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 15.100 /  6. 15.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
[dshow @ 0000017449b7c0e0] Could not find audio only device with name [ezcap Video Grabber] among source devices of type audio.
[dshow @ 0000017449b7c0e0] Searching for audio device within video devices for ezcap Video Grabber
[dshow @ 0000017449b7c0e0] Could not run graph (sometimes caused by a device already in use by other application)
video=ezcap Video Grabber:audio=ezcap Video Grabber: Input/output error

Hence, I was forced to use the software that came with the capture device: ArcSoft ShowBiz, which does the job, but is less than optimal due to complicated setup and UI, and because it produces MPEG2's rather than more compact MP4's.

7
  • Please show the complete console output instead of just an excerpt. It will provide additional info about your ffmpeg that is necessary for an accurate answer. Also, how did you create the mpg file(s)? If you can I recommend skipping the lossy, intermediate mpg step by recapturing the tape and either using a lossless (or nearly lossless) intermediate file or by piping it directly to ffmpeg.
    – llogan
    Nov 26, 2015 at 20:48
  • @LordNeckbeard Thanks for looking into this. Well, I wanted this question (and answers) to be of benefit to others, so did not want to make it too specific (i.e. ffmpeg specific version and specific software that produced MPEG2's). As for your suggestion to use ffmpeg directly to capture VHS - that's what I was trying to do but gave up because my capture device is listed only under DirectShow Video Devices (no entry under Audio Devices), and I could not get ffmpeg to properly capture both video and audio - it does video fine, but cannot get audio from another pin.
    – Fit Nerd
    Nov 27, 2015 at 5:53
  • @LordNeckbeard As per your suggestion, updated the question with more info.
    – Fit Nerd
    Nov 27, 2015 at 6:02
  • @LordNeckbeard Actually ArcSoft ShowBiz that I currently use for capture is not so stable after all - it may randomly reset the file, and thus cause a lot of recording to be lost and thus I have to re-capture everything. So, I may actually really need ffmpeg to do the job instead, though the problem is, as I described in an update is that it does not recognize audio pin on my video capture source and thus can't record audio.
    – Fit Nerd
    Nov 29, 2015 at 12:41
  • Unfortunately, I know nothing of dshow, but one of the maintainers is active at the Zeranoe FFmpeg Forum. If you can get the pin issue resolved I can help with the command (I'm doing a VHS job now too).
    – llogan
    Nov 29, 2015 at 18:44

1 Answer 1

8

Encoding from a VHS source

ffmpeg -i input -vf "yadif=1:1,hqdn3d=3,drawbox=y=ih-h:w=0:h=6:t=max,format=yuv420p" \
-crf 23 -preset medium -c:a aac -movflags +faststart \
-metadata title="Title" output.mp4

filters

Encoding form a VHS input can be improved with some filters:

  • yadif is a deinterlacer. See the documentation and try out the different modes to see what looks best to you. Alternatively, you could try the w3fdif deinterlacing filter, but I haven't tested that one yet.

  • hqdn3d is a video denoiser. VHS can be noisy, so experiment with various values, and try without it too. Denoising can improve compressibility, but too much denoising will add noticeable blur.

  • drawbox in this example is is making a 6 pixel black box on the very bottom to mask any head switching noise. You may have to adjust the height, or just remove it. This is better than cropping because simply covering it up avoids changing the aspect ratio: if that is not a concern the feel free to crop instead.

  • format is added to use a widely compatible pixel format. It does not really matter with your input though since it is already yuv420p.

other options

  • -crf and -preset will allow you to adjust the output quality and encoding speed. See FFmpeg Wiki: H.264 Video Encoding Guide.

  • -movflags +faststart is useful if your viewers will watch via progressive download. After encoding it will move some info to the beginning of the file so it can begin playback quicker.

  • You will need to add -strict experimental if using an old ffmpeg: the native FFmpeg AAC encoder used to be considered experimental but that is now no longer the case.

1
  • -c:a aac strict experimental should be -c:a aac -strict experimenta
    – n3storm
    Feb 27, 2016 at 10:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .