Reputation: 63
I am new to gstreamer, I want to record both audio and video save it into .mp4 format, Recording video using webcam and audio using MIC Here this is my pipeline
gst-launch-1.0 -e v4l2src ! queue ! x264enc ! h264parse ! queue ! qtmux0. alsasrc ! 'audio/x-raw,rate=44100,depth=24' ! audioconvert ! audioresample ! voaacenc ! aacparse ! qtmux ! filesink location=test.mp4
When i am executing it the video is recording only for 10sec the audio not even recording, Its giving some message like
WARNING: from element /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: Can't record audio fast enough Additional debug info: gstaudiobasesrc.c(866): gst_audio_base_src_create (): /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: Dropped 425565 samples. This is most likely because downstream can't keep up and is consuming samples too slowly.
Help me get over through this Thank You in advance
Upvotes: 5
Views: 11790
Reputation: 958
I ended up using that one (adapted from a random response from the web, sorry i lost the source)
raspivid -t 0 --vflip --hflip -w 1920 -h 1080 -fps 30 --bitrate 14000000 --profile baseline -3d sbs --intra 30 --inline --flush --awb auto --exposure auto --sharpness 0 --contrast -15 --digitalgain 0.0 -o - | gst-launch-1.0 -ve fdsrc num-buffers=-1 ! video/x-h264,width=1920,height=1080,framerate=30/1 ! h264parse ! queue ! smux.video alsasrc device=hw:2,0 ! audio/x-raw,format=S32LE,rate=48000,channel=2 ! audioconvert ! avenc_aac ! aacparse ! queue ! smux.audio_0 splitmuxsink name=smux location=video.mp4 muxer=mpegtsmux
Note it's for capturing steroscopic image, you can drop "-3d sds" and adapt width for single cam. You can also safely drop the -ve which is only useful for debug and change your audio device hw to the number for your capture card ($ arecord -l
to find out the id of your card).
I would prefer to use qtmux but it fails due to missing PTS info in the h264 stream made by raspivid. mpegtsmux is happy tho.
As of now, the resulting mpeg is half broken, and cannot be read by all players (quicktime fails, while vlc is happy). Reencoding with ffmpeg : ffmpeg -vcodec mpeg4 -b:v 7561k -qscale:v 2 -acodec aac -ac 2 -async 1 -strict experimental ./video2.mp4 -threads 0 -i video.mp4
fixed the file.
Hope this is helpful to someone.
Upvotes: 1
Reputation: 61
try with the following pipeline to record audio and video into one file.
gst-launch-1.0 -e v4l2src device="/dev/video0" ! videoconvert ! queue ! x264enc tune=zerolatency ! mux. alsasrc device="hw:2" ! queue ! audioconvert ! audioresample ! voaacenc ! aacparse ! qtmux name=mux ! filesink location=test.mp4 sync=false
Upvotes: 6
Reputation: 63
got the pipeline now it is recording audio and video perfectly
Here the pipeline
gst-launch-1.0 -e v4l2src ! 'video/x-raw,width=960,height=720,framerate=30/1' ! queue ! x264enc tune=zerolatency ! mux. alsasrc ! audio/x-raw,width=16,depth=16,rate=44100,channel=1 ! queue ! audioconvert ! audioresample ! voaacenc ! aacparse ! qtmux name=mux ! filesink location=test.mp4 sync=false
if still anything incorrect in the pipeline let me know
Upvotes: 1