Oct 17

Capturing VHS video with vlc via v4l2

Category: Linux   — Published by goeszen on October 17, 2016 at 12:34 pm

After re-using my VHS mencoder avconv capture pipeline today, on a Ubuntu 14.04 system, I've found that things had degraded since my last post. It seems the stk1160 driver, in relation to my kernel, or my halfbaked install of it, or anything else was raising issues again. Capture framerate dropped to an unusable rate (with mencoder skipping frames like mad), so the recorded video appeared sped-up.

Time to try something new and it turned out, this time, I've found a great solution: vlc.

Playing back Video4Linux sources worked out of the box, simply by opening the /dev/video0 device via GUI. Same for audio, which even trusty tvtime refused to deliver today, rendering the image as a green mess. vlc took all hurdles.

First, on Ubuntu 14.04, audio was back to muted, so I had to issue $ amixer -c stk1160mixer sset Line unmute cap
but after that, I could start capturing video. Don't forget to check out the naming of your audio device (the "hw:..." bit), which changes between boots, with $ cat /proc/asound/cards

So here it is, the command-line command to capture from the stk1160 EasyCap stick, complete with a GUI/display output to monitor what you're recording:

sudo nice -n -19 vlc v4l:///dev/video0 :v4l-norm=0 :input-slave=alsa://hw:2,0 :live-caching=300 '--sout=#transcode{vcodec=HFYU,acodec=s16l,channels=2,samplerate=48000}:duplicate{dst=display,dst=std{access=file{no-overwrite},mux=avi,dst='VHS_vlc.avi'}}'

As you can see, I stick with the previously introduced 2-step encoding + compression stance, first I capture with vlc to HuffyYUV + WAV in an AVI container, then I'll compress this "raw" video to mp4. top tells me capture runs at about ~60% CPU on an Intel Core2 CPU 4300 @ 1.80GHz.


As of October 2016 there seems to be something screwed up here. As Jake (comment 7) points out, this command captures 720x480 video. I don't know why. I could reproduce it (in a quick test), but adding scale=1 doesn't fix it. Adding height=576 made the video 864 pixels wide, as vlc assumes a default aspect ratio of 1.5 (related). So adding ,scale=1,height=576,width=720,aspect=4:3 to the #transcode part set the frame size at the correct dimensions, but the image is cropped at the bottom! (as Jake pointed out).

My impression is something with the driver setup on Ubuntu as of now has degraded. Also, I wasn't able to set proper video norm any more (:v4l-norm to zero for PAL doesn't work, and testing with tvtime - a handy tool for such things - didn't work either. The image was either b/w or all green. Something with S-VHS switching??)

Please add a comment if you found a solution or know what's going on.

Previous posts related to VHS and video capturing: