Capture and view PAL-B raw video and stereo ALSA sound from EasyCAP STK1160 with ffmpeg and encode to x264

1

I would like to digitalize old VHS casettes with EasyCAP STK1160 under linux. The composite video input is /dev/video1, and hw:2,0 is for its the USB ALSA composite two-channel audio.

For capturing the streams in raw format, I use:

ffmpeg -f alsa -ac 2 -i hw:2,0 -f rawvideo -r 25 -s 720x576 -i /dev/video1 -codec:a pcm_s16le -codec:v rawvideo -f rawvideo raw_streams.raw

For encoding the raw file to h264 in two pass, I use:

time ffmpeg -f rawvideo -codec:v rawvideo -s:v 720x576 -r 25 -pix_fmt yuyv422 -deinterlace -i raw_streams.raw -pass 1 -codec:v libx264 -codec:a libfdk_aac -b:a 128k -preset ultrafast -y -b:v 6100k -f mp4 /dev/null
time ffmpeg -f rawvideo -codec:v rawvideo -s:v 720x576 -r 25 -pix_fmt yuyv422 -deinterlace -i raw_streams.raw -pass 2 -codec:v libx264 -codec:a libfdk_aac -b:a 128k -preset ultrafast -y -b:v 6100k -f mp4 "final.mp4"

Question #1: The resulting encoded .mp4 has good video, but no sound. How do I add the sound channel to the raw file and then to the mp4? Succesfully capturing only the sound with the following command shows that there is sound on the line in.

ffmpeg -f alsa -i hw:2,0 output.wav

Question #2: How do I specify PAL-B to be the video capturing format for the raw video? man ffmpeg does not seem to have any information on this matter.

Question #3: Since not all the casettes have recordings on their entire length, I would also like to view the live stream while capturing so that I know when to stop. I do this with:

mplayer -fps 25 tv:// -tv driver=v4l2:device=/dev/video1

I either view the stream or capture. Trying to do both of them produces the following error: /dev/video1: Device or resource busy How can I do these things simultenously?

Gábor Dani

Posted 2016-09-13T20:18:27.637

Reputation: 141

Answers

1

#1 You are saving to a rawvideo stream and so audio will not be saved. You need to save to a container, like NUT:

ffmpeg -f rawvideo -framerate 25 -s 720x576 -i /dev/video1 -f alsa -ac 2 -i hw:2,0
       -c:a pcm_s16le -c:v rawvideo raw.nut

#2 This needs to be set in the capture device's driver/config. FFmpeg is receiving a raw video stream digitized by the USB device. Which property specifically do you need to set? All PAL variants share the frame size and rate.

#3 You can use the tee muxer to pipe the capture to ffplay

ffmpeg -f rawvideo -framerate 25 -s 720x576 -i /dev/video1 -f alsa -ac 2 -i hw:2,0
       -c:a pcm_s16le -c:v rawvideo -f tee "raw.nut|[f=nut]pipe:" | ffplay -f nut -

Gyan

Posted 2016-09-13T20:18:27.637

Reputation: 21 016