Best way to concatenate and play streams

Eloi Bail eloi.bail at gmail.com
Tue Mar 19 13:35:52 PDT 2013


>
> Hi all,


I have several input files encoded in H264 that are short ( 2 mn).
I would like to chain them and play it smoothly.

I saw three ways to do it :

*1) Using playbin2*
*
*
Listening to "about_to_finish" event and change the uri of the playbin2
pipeline then,

--> It works but I do not have a smooth transition when uri changement
occurs


*2) using gnlcomposition*

I tried to set a pipeline with correct duration (2mn

GST_DEBUG=2 gst-launch-0.10 gnlcomposition name=comp gnlfilesource
> name=video1 location="./myfile.avi" start=0 duration=0 media-start=0
> media-duration=120000000000  gnlfilesource name=video2
> location="./myfile2.avi" start=120000000000 duration=240000000000
> media-start=0 media-duration=120000000000 ! autovideosink



I have the following error :

Définition du pipeline à PAUSED...
0:00:00.042206793  9639      0x1133050 WARN                avidemux
gstavidemux.c:3744:gst_avi_demux_stream_header_pull:<avidemux0> Unknown tag
RCOV in AVI header at off 9496
0:00:00.042530150  9639      0x1133050 WARN                avidemux
gstavidemux.c:2582:gst_avi_demux_stream_for_id:<avidemux0> invalid stream
nr 560
0:00:00.042659018  9639      0x1133050 WARN                avidemux
gstavidemux.c:2582:gst_avi_demux_stream_for_id:<avidemux0> invalid stream
nr 738
0:00:00.042758981  9639      0x1133050 WARN                avidemux
gstavidemux.c:2582:gst_avi_demux_stream_for_id:<avidemux0> invalid stream
nr 738
0:00:00.042878288  9639      0x1133050 WARN                avidemux
gstavidemux.c:2582:gst_avi_demux_stream_for_id:<avidemux0> invalid stream
nr 738
0:00:00.042984286  9639      0x1133050 WARN                avidemux
gstavidemux.c:2582:gst_avi_demux_stream_for_id:<avidemux0> invalid stream
nr 738
0:00:00.043083517  9639      0x1133050 WARN                avidemux
gstavidemux.c:2582:gst_avi_demux_stream_for_id:<avidemux0> invalid stream
nr 359
Le pipeline est en phase de PREROLL...
0:00:00.051146232  9639      0x11330f0 WARN                avidemux
gstavidemux.c:3744:gst_avi_demux_stream_header_pull:<avidemux1> Unknown tag
RCOV in AVI header at off 9496
0:00:00.051324655  9639      0x11330f0 WARN                avidemux
gstavidemux.c:2582:gst_avi_demux_stream_for_id:<avidemux1> invalid stream
nr 560
0:00:00.051385497  9639      0x11330f0 WARN                avidemux
gstavidemux.c:2582:gst_avi_demux_stream_for_id:<avidemux1> invalid stream
nr 738
0:00:00.051424734  9639      0x11330f0 WARN                avidemux
gstavidemux.c:2582:gst_avi_demux_stream_for_id:<avidemux1> invalid stream
nr 738
0:00:00.051474771  9639      0x11330f0 WARN                avidemux
gstavidemux.c:2582:gst_avi_demux_stream_for_id:<avidemux1> invalid stream
nr 738
0:00:00.051512985  9639      0x11330f0 WARN                avidemux
gstavidemux.c:2582:gst_avi_demux_stream_for_id:<avidemux1> invalid stream
nr 738
0:00:00.051550250  9639      0x11330f0 WARN                avidemux
gstavidemux.c:2582:gst_avi_demux_stream_for_id:<avidemux1> invalid stream
nr 359
0:00:00.179362043  9639 0x7f403c008990 WARN                    faad
gstfaad.c:328:gst_faad_set_format:<faad0> buggy faad version, wrong nr of
channels 2 instead of 1
0:00:00.191962359  9639 0x7f403c0088a0 WARN               gnlsource
gnlsource.c:213:element_pad_added_cb:<video2> We already have (pending)
ghost-ed a valid source pad (ghostpad:'':'', pendingblock:1
0:00:00.204969320  9639 0x7f40280034a0 WARN                    faad
gstfaad.c:328:gst_faad_set_format:<faad1> buggy faad version, wrong nr of
channels 2 instead of 1
0:00:00.210988459  9639 0x7f4028003400 WARN               gnlsource
gnlsource.c:213:element_pad_added_cb:<video1> We already have (pending)
ghost-ed a valid source pad (ghostpad:'':'', pendingblock:1
0:00:00.234065944  9639 0x7f4028003400 WARN                  ffmpeg
gstffmpegdec.c:2315:gst_ffmpegdec_frame:<ffdec_h2641> ffdec_h264: decoding
error (len: -1, have_data: 0)
0:00:00.234863079  9639      0x11330f0 WARN                avidemux
gstavidemux.c:5254:gst_avi_demux_loop:<avidemux1> error: Erreur interne de
flux de données.
0:00:00.234953061  9639      0x11330f0 WARN                avidemux
gstavidemux.c:5254:gst_avi_demux_loop:<avidemux1> error: streaming stopped,
reason not-linked
ERREUR : de l'élément
/GstPipeline:pipeline0/GnlFileSource:video1/GstURIDecodeBin:internal-uridecodebin/GstDecodeBin2:decodebin21/GstAviDemux:avidemux1
: Erreur interne de flux de données.
Information de débogage supplémentaire :
gstavidemux.c(5254): gst_avi_demux_loop ():
/GstPipeline:pipeline0/GnlFileSource:video1/GstURIDecodeBin:internal-uridecodebin/GstDecodeBin2:decodebin21/GstAviDemux:avidemux1:
streaming stopped, reason not-linked
ERREUR : le pipeline refuse de passer en phase de préparation.
Définition du pipeline à NULL...
0:00:00.246670995  9639 0x7f4028003400 WARN                  ffmpeg
gstffmpegdec.c:2315:gst_ffmpegdec_frame:<ffdec_h2641> ffdec_h264: decoding
error (len: -1, have_data: 0)
0:00:00.247565486  9639 0x7f4028003400 WARN                  ffmpeg
gstffmpegdec.c:2315:gst_ffmpegdec_frame:<ffdec_h2641> ffdec_h264: decoding
error (len: -1, have_data: 0)


*3) Using appsrc*
*
*
I can play a file using this method. I implemented a callback feed_data
called when signal need_data occured.
I am using buffers of 4096.
For testing, I am detecting when the last buffer would be used, i.e data to
write to buffer less than 4096. Then I append to this buffer datas from my
second file.
I also changed the timestamp. To see a relevant result for this testing, I
increased chunk-size to 100*4096

 if (app->offset + len > app->length){
>       len = app->length - app->offset;
>       GST_BUFFER_DATA (buffer) = app->data + app->offset;
>       GST_BUFFER_SIZE (buffer) = len;
>       GMappedFile* newfile = g_mapped_file_new ("./file2.avi", FALSE,
> &error);
>       guint8 *newdata;
>       gsize newlength = CHUNK_SIZE - len;
>       GstBuffer *newbuffer;
>       GstBuffer *destbuffer;
>       if (error) {
>         g_print ("failed to open file: %s\n", error->message);
>         g_error_free (error);
>         return -2;
>       }
>       //fill in the new buffer
>       newdata = (guint8 *) g_mapped_file_get_contents (newfile);
>       newbuffer = gst_buffer_new ();
>       GST_BUFFER_DATA (newbuffer) = newdata;
>       GST_BUFFER_SIZE (newbuffer) = newlength;
>      // change timestamp
>       GST_BUFFER_TIMESTAMP(newbuffer) = GST_BUFFER_DURATION (buffer);
>       // hack for testing - wrong duration
>       GST_BUFFER_DURATION(newbuffer) = 500000000;
>       //merge buffer
>       GST_BUFFER_MALLOCDATA (destbuffer) = g_malloc (CHUNK_SIZE);
>       GST_BUFFER_SIZE (destbuffer) = CHUNK_SIZE ;
>       destbuffer = gst_buffer_merge(buffer,newbuffer);
>       GST_BUFFER_DURATION (destbuffer)=GST_BUFFER_DURATION(buffer) +
> GST_BUFFER_DURATION(newbuffer);
>       g_signal_emit_by_name (app->appsrc, "push-buffer", destbuffer, &ret);
>       gst_buffer_unref (destbuffer);




All the time, the video is ending at the end of first file and a EOS is
detected...


Could you tell me which way I should use and eventually help me to make it
work !

Thanks a lot,

Eloi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20130319/9d6e7740/attachment.html>


More information about the gstreamer-devel mailing list