I'm trying to store a video stream (coming from my webcam) into a MKV and FLV file. This means I have to split the video and audio pipeline after the h264 Encoding and mux each path with a different muxer.
This is how I imagine it should be working:
|->queue->matroskamux->filesink
v4l2src->videorate->videoscale->x264enc->tee-|
|->queue->flvmux->filesink
Is this assumption correct? Are all the queues at the right places? How would a GStreamer command like this look like? I'm having especially troubles with the concept of "Tees". How/where to start them in a command and how to manipulate different Tee-Paths. I looked up "Tee" in the GStreamer documentation but I'm still having troubles to apply them.
Thanks in advance!
EDIT: Ok, Thanks to mreithub I got it working for video. This is how the command looks like for now:
gst-launch-0.10 -v -m v4l2src ! videorate ! videoscale ! ffmpegcolorspace ! x264enc ! tee name=muxtee ! queue2 ! matroskamux name=mkvmux ! filesink location=file1.mkv muxtee. ! queue ! flvmux name=flvmux ! filesink location=file1.flv
Here is my attempt to get audio running:
gst-launch-0.10 -v -m v4l2src ! videorate ! videoscale ! ffmpegcolorspace ! x264enc ! tee name=muxtee ! queue2 ! matroskamux name=mkvmux pulsesrc ! ffenc_aac ! filesink location=file1.mkv muxtee. ! queue ! flvmux name=flvmux pulsesrc ! ffenc_aac ! filesink location=file1.flv
This does not work (command executes but immediately stops - no error message). But I'm also having trouble determining the position where to put the audio encoding. In my attempted solution I encode the audio in each Tee-Pipeline (right?). But I'd like to encode audio only once and then just mux it in both pipeline-paths accordingly.
Here's another try: after the audio encoding I split the pipleine using a Tee and assign it to the mkvmuxer and flvmuxer:
gst-launch-0.10 -v -m v4l2src ! videorate ! videoscale ! ffmpegcolorspace ! x264enc ! tee name=muxtee ! queue2 ! matroskamux name=mkvmux ! filesink location=file1.mkv muxtee. ! queue ! flvmux name=flvmux ! filesink location=file1.flv pulsesrc ! ffenc_aac ! tee name=t2 ! queue ! mkvmux. t2. ! queue ! flvmux.
But with this one I'm getting the following error message:
could not link queue1 to flvmux
Thanks!
As you want video and audio in your pipeline, it is going to be a little complicated (I thought a little pic might help):
To keep the gst-launch command as clear as possible, I put each linear pipeline piece into one command line (the red connections in the first line, then the blue, the green and yellow ones and finally the queueing stuff which is colored black in the above picture):
gst-launch-0.10 v4l2src ! videorate ! videoscale ! x264enc ! tee name=videoTee \
pulsesrc ! ffenc_aac ! tee name=audioTee \
flvmux name=flvMux ! filesink location=/tmp/foo.flv \
matroskamux name=mkvMux ! filesink location=/tmp/foo.mkv \
audioTee. ! queue ! flvMux. \
audioTee. ! queue ! mkvMux. \
videoTee. ! queue ! flvMux. \
videoTee. ! queue ! mkvMux.
Just one last note: I tried it using lame
instead of ffenc_aac
as I don't have it installed, but it should work with both of them.
Edit: Completely rewrote the answer including audio support, added a pipeline pic (the pic btw. was made using the awesome GraphViz tool).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With