Search code examples
gstreameraudio-recordingvideo-recording

capturing both audio and video with gstreamer to a file


I am using gstreamer to capture both audio and video to a file. I tried something as:

gst-launch-1.0 -v -e autovideosrc ! queue ! omxh264enc ! 'video/x-h264, 
stream-format=(string)byte-stream' ! h264parse ! queue ! autoaudiosrc ! 
voaacenc ! qtmux ! filesink location=test.mp4

This returns an error saying that I cannot connect the queue to an audiosrc.

Capturing just the video with:

gst-launch-1.0 -v -e autovideosrc ! queue ! omxh264enc ! 'video/x-
h264, stream-format=(string)byte-stream' ! h264parse ! qtmux ! 
filesink location=test.mp4

works fine.


Solution

  • Your pipeline is not correct. You have just one continuous pipeline. What you look for is more like a "Y" shaped one:

    gst-launch-1.0 -v -e autovideosrc ! queue ! omxh264enc ! 'video/x-h264, stream-format=(string)byte-stream' ! h264parse ! queue ! qtmux0. autoaudiosrc ! voaacenc ! qtmux ! filesink location=test.mp4

    Note the dot at qtmux0 after your queue. This means "connect to the qtmux0 element" (which is the default name for the first qtmux element in your pipeline). After that there is no "!" - so the autoaudiosrc element following marks the begin of a new "branch" of your pipeline.

    I did not test this.. so I hope got the syntax right..