Recording from tv tuner/webcam with gstreamer and audio/video going out of sync

2.4k Views Asked by At

I have a TV tuner card that shows up as /dev/video1. I am trying to digitize some old VHS tapes. The TV tuner doesn't do audio, I have a wire connected to my microphone in.

This is the gstreamer pipeline I'm using to capture video & audio and save it to a file. I'm using motion jpeg because I don't want it to drop frames and lose content. I'll re-encode it better later.

gst-launch-0.10 v4l2src device=/dev/video1 ! \
    queue ! \
    video/x-raw-yuv,width=640,height=480 ! \
    ffmpegcolorspace ! \
    jpegenc ! \
    avimux name=mux ! \
    filesink location=output.avi \
   pulsesrc ! \
    queue ! \
    audioconvert ! \
    audio/x-raw-int,rate=44100,channels=2 ! \
    mux.

This all works well and good. I have files that play that have video and audio. However sometimes when playing the output files, the audio & video goes out of sync. It happens at the same place in the video, on numerous different media players (totem, mplayer). So I think this is a problem in how I'm saving and recording the file.

Is there anything I can do to the pipeline to make it less likely to suffer from audio/video sync problems? I'm a bit of a newbie to gstreamer and video/audio codecs, so I might be doing something stupid here (please point out!). Is there any video/audio/muxer codec that would be better?

1

There are 1 best solutions below

0
On

Try adding an audiorate element in the audio branch, and a videorate element in the video branch, to see if that makes a difference, or try a different muxer, like qtmux or matroskamux.