batfastad
20th January 2015, 01:28
Hi everyone
I've unearthed a box of old family videos on VHS tape that I'd like to preserve while I still have a video player that works. Some of these were originally recorded by camcorders on Hi8 or VHS, others were converted a long time ago from various old cinefilm formats.
I have a USB video capture box which I used to use for live web streaming http://blitzcast.com/b1-3/ from a Sony camcorder at events. It was designed for games console streaming but I found it works really well as an all-round capture device.
Normally when archiving audio I capture in the best quality possible then transcode/downsample to a current format for actual practical playback. I'd like to do the same with video, storing it as a "lossless" video file (or as close to as possible) then I'll probably convert to DVD for actual playback for the time being.
Brief digging around and it looks like my lossless capture format options are:
* HuffYUV
* x264 "crf 0"
* MJPEG
It looks like VirtualDub is still a good tool for the job of capturing as well. I've followed this excellent guide for a workflow of setting up VirtualDub for capturing... http://www.doom9.org/index.html?/capture/start.html
I started looking into x264 for capturing. I'd never heard of HuffYUV and found this http://stackoverflow.com/questions/26346810/how-to-use-x264-encoder-with-directshow which suggested using x264vfw as a frontend which exposes x264 within VirtualDub.
These are all PAL VHS tapes so I was running test captures at 720x576 YUY2 and a framerate of 25.0000.
A raw .avi rip from VirtualDub which came in at 5.5GB for 4min of video, with the CPU hardly blinking.
Then a compressed one through x264 with the lossless setting in x264vfw came in at 985MB.
But this hit the 4 cores in my laptop up to about 85% throughout (CPU i5-4210M). The VirtualDub overlay was very choppy but the stats window reported no dropped frames so I thought I might be ok. On playback it's not choppy like the VirtualDub preview, though in a side-by-side against the raw .avi capture, it is very slightly off in places.
So I don't think my laptop has enough grunt to be able to capture in x264 lossless in real-time. But I also won't have enough disk space to capture in raw .avi and transcode later. I read somewhere that HuffYUV is typically alot less taxing on CPU and has a similar file size saving to x264 lossless. So it might be that I capture in HuffYUV and then transcode to x264 afterwards. I need to experiment with HuffYUV more.
I did a test transcode using ffmpeg from the linux command line to take my raw .avi to x264 lossless.
This is my command: ffmpeg -i testcapture.avi -c:v libx264 -crf 0 -preset slow -c:a aac -b:a 192k -ac 2 -strict -2 testcapture_x264_c0_slow.mp4
File size down to 1.8GB for 4m 30s of video, which is just about acceptable for my archiving. The encoding took about 7min with CPU maxed throughout, so really there was no way I was going to be able to do this in real-time during the 4m 30s of video.
I tried -preset veryslow but that took about 15mins so it's probably not worth the extra time needed for any improvement in encoding quality there might be. I couldn't see any difference.
Playback, no minor stutters like the real-time encoding. Looks identical to me when comparing the raw avi. So x264 lossless for archiving seems like a great option based on quality/file size.
I should say that I'm not bothered about cleaning up the source at this stage, cropping black bars and removing any VHS blips/noise etc. I want to capture what's coming out of the VHS player, and if there's noise/blips then that's part of the video as much as the rest of it IMO.
ffmpeg printed out the specs of my raw capture at the start of the encoding log...
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x576, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
The x264 output from ffmpeg...
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv422p, 720x576, q=-1--1, 12800 tbn, 25 tbc
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 192 kb/s
My questions...
1) De-interlacing. When playing back my raw avi capture I can see horizontal lines in areas of motion similar to this http://www.doom9.org/capture/images/interlaced.jpg So the video is probably interlaced and I should de-interlace.
Would it make sense that my PAL VHS tapes (non-broadcast) are interlaced? Or is interlacing something that's only used in broadcast etc?
Since I'm planning on keeping an x264 file and probably authoring DVDs for relatives, it's not like I would ever need to re-interlace in the future?
2) Is my ffmpeg command above appropriate for taking my raw .avi down to x264 lossless? Are there any further options for the video that I need?
3) Would a higher -crf value reduce file size without much of a loss in quality?
4) Does this input stream info from ffmpeg look right for a PAL VHS capture... yuyv422, 720x576, 25 tbr/tbn/tbc?
5) The output stream info from ffmpeg is now yuv422p instead of yuyv422. Does that look right?
6) The added "p" there, does that mean my source was interlaced and the output is now progressive, and x264 has auto de-interlaced or something?
7) I've seen a few small mentions of x264 only supporting 4:2:0 (whatever that means). Is that going to be a problem for my workflow above?
Should I be worried about the 422 in the source and output from ffmpeg?
8) Anyone have any good info about capturing with HuffYUV in VirtualDub then converting from HuffYUV to x264 in ffmpeg?
I should also say that I'm capturing in Windows 7 because the drivers for the capture box are installed, then running ffmpeg under Linux (Xubuntu) which is my primary desktop OS. I should probably try using the capture box under Linux to see what happens but at the moment I'd just like to make sure my workflow is ok.
I hope all of that makes sense. Video encoding stuff is always something I look at for a project once every few years then immediately forget and end up having to re-learn.
Cheers, B
I've unearthed a box of old family videos on VHS tape that I'd like to preserve while I still have a video player that works. Some of these were originally recorded by camcorders on Hi8 or VHS, others were converted a long time ago from various old cinefilm formats.
I have a USB video capture box which I used to use for live web streaming http://blitzcast.com/b1-3/ from a Sony camcorder at events. It was designed for games console streaming but I found it works really well as an all-round capture device.
Normally when archiving audio I capture in the best quality possible then transcode/downsample to a current format for actual practical playback. I'd like to do the same with video, storing it as a "lossless" video file (or as close to as possible) then I'll probably convert to DVD for actual playback for the time being.
Brief digging around and it looks like my lossless capture format options are:
* HuffYUV
* x264 "crf 0"
* MJPEG
It looks like VirtualDub is still a good tool for the job of capturing as well. I've followed this excellent guide for a workflow of setting up VirtualDub for capturing... http://www.doom9.org/index.html?/capture/start.html
I started looking into x264 for capturing. I'd never heard of HuffYUV and found this http://stackoverflow.com/questions/26346810/how-to-use-x264-encoder-with-directshow which suggested using x264vfw as a frontend which exposes x264 within VirtualDub.
These are all PAL VHS tapes so I was running test captures at 720x576 YUY2 and a framerate of 25.0000.
A raw .avi rip from VirtualDub which came in at 5.5GB for 4min of video, with the CPU hardly blinking.
Then a compressed one through x264 with the lossless setting in x264vfw came in at 985MB.
But this hit the 4 cores in my laptop up to about 85% throughout (CPU i5-4210M). The VirtualDub overlay was very choppy but the stats window reported no dropped frames so I thought I might be ok. On playback it's not choppy like the VirtualDub preview, though in a side-by-side against the raw .avi capture, it is very slightly off in places.
So I don't think my laptop has enough grunt to be able to capture in x264 lossless in real-time. But I also won't have enough disk space to capture in raw .avi and transcode later. I read somewhere that HuffYUV is typically alot less taxing on CPU and has a similar file size saving to x264 lossless. So it might be that I capture in HuffYUV and then transcode to x264 afterwards. I need to experiment with HuffYUV more.
I did a test transcode using ffmpeg from the linux command line to take my raw .avi to x264 lossless.
This is my command: ffmpeg -i testcapture.avi -c:v libx264 -crf 0 -preset slow -c:a aac -b:a 192k -ac 2 -strict -2 testcapture_x264_c0_slow.mp4
File size down to 1.8GB for 4m 30s of video, which is just about acceptable for my archiving. The encoding took about 7min with CPU maxed throughout, so really there was no way I was going to be able to do this in real-time during the 4m 30s of video.
I tried -preset veryslow but that took about 15mins so it's probably not worth the extra time needed for any improvement in encoding quality there might be. I couldn't see any difference.
Playback, no minor stutters like the real-time encoding. Looks identical to me when comparing the raw avi. So x264 lossless for archiving seems like a great option based on quality/file size.
I should say that I'm not bothered about cleaning up the source at this stage, cropping black bars and removing any VHS blips/noise etc. I want to capture what's coming out of the VHS player, and if there's noise/blips then that's part of the video as much as the rest of it IMO.
ffmpeg printed out the specs of my raw capture at the start of the encoding log...
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x576, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
The x264 output from ffmpeg...
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv422p, 720x576, q=-1--1, 12800 tbn, 25 tbc
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 192 kb/s
My questions...
1) De-interlacing. When playing back my raw avi capture I can see horizontal lines in areas of motion similar to this http://www.doom9.org/capture/images/interlaced.jpg So the video is probably interlaced and I should de-interlace.
Would it make sense that my PAL VHS tapes (non-broadcast) are interlaced? Or is interlacing something that's only used in broadcast etc?
Since I'm planning on keeping an x264 file and probably authoring DVDs for relatives, it's not like I would ever need to re-interlace in the future?
2) Is my ffmpeg command above appropriate for taking my raw .avi down to x264 lossless? Are there any further options for the video that I need?
3) Would a higher -crf value reduce file size without much of a loss in quality?
4) Does this input stream info from ffmpeg look right for a PAL VHS capture... yuyv422, 720x576, 25 tbr/tbn/tbc?
5) The output stream info from ffmpeg is now yuv422p instead of yuyv422. Does that look right?
6) The added "p" there, does that mean my source was interlaced and the output is now progressive, and x264 has auto de-interlaced or something?
7) I've seen a few small mentions of x264 only supporting 4:2:0 (whatever that means). Is that going to be a problem for my workflow above?
Should I be worried about the 422 in the source and output from ffmpeg?
8) Anyone have any good info about capturing with HuffYUV in VirtualDub then converting from HuffYUV to x264 in ffmpeg?
I should also say that I'm capturing in Windows 7 because the drivers for the capture box are installed, then running ffmpeg under Linux (Xubuntu) which is my primary desktop OS. I should probably try using the capture box under Linux to see what happens but at the moment I'd just like to make sure my workflow is ok.
I hope all of that makes sense. Video encoding stuff is always something I look at for a project once every few years then immediately forget and end up having to re-learn.
Cheers, B