GStreamer Tee (Multiplexer)

I am trying to save a video stream (coming from my webcam) to a MKV and FLV file. This means that I have to separate the video and audio wiring after h264 encoding and multiplex each path using a different multiplayer.

Here is how I think it should work:

|->queue->matroskamux->filesink v4l2src->videorate->videoscale->x264enc->tee-| |->queue->flvmux->filesink 

Is this assumption correct? Are all the lines in the right places? What will the GStreamer team look like? I have a particular problem with the yew concept. How / where to run them in a team and how to manipulate different Troika. I looked at "Tee" in the GStreamer documentation, but I still have problems using them.

Thanks in advance!

EDIT: Well, thanks mreithub, I got it for the video. This is what the command looks like:

 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 start the sound:

 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 (the command executes, but stops immediately - there is no error message). But I also have problems determining the position in which audio coding should be placed. In my attempt at a solution, I encode audio in each Tee-Pipeline (right?). But I would like to encode the sound only once, and then just mux it along both pipelines respectively.

Here's another try: after encoding the sound, I broke pipleine with Tee and assigned it to 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, I get the following error message:

 could not link queue1 to flvmux 

Thanks!

+4
source share
1 answer

As you want, video and audio in your pipeline, it will be a little more complicated (I thought a little pic could help): GraphViz diagram showing the resulting pipeline

To make the gst-launch command as clear as possible, I put each part of the linear pipeline on one command line (red connections on the first line, then blue, green and yellow, and finally the contents of the queue, which is colored black in the figure above):

 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 with lame instead of ffenc_aac , since I don't have it, but it should work with both of them.

Edit: I completely rewrote the answer, including sound support, added a pipeline icon (pic btw. Was created using the amazing GraphViz tool).

+16
source

Source: https://habr.com/ru/post/1445808/


All Articles