[gst-devel] continuous video timestamps after seek
fannys at gmx.net
fannys at gmx.net
Tue Oct 5 22:08:09 CEST 2010
-------- Original-Nachricht --------
> Datum: Fri, 01 Oct 2010 04:35:45 +0200
> Von: fannys at gmx.net
> An: gstreamer-devel at lists.sourceforge.net
> Betreff: [gst-devel] continuous video timestamps after seek
> Hello
>
> I'm streaming a video using the gstrtpbin element. If the end of the
> video stream is reached I want to replay the video in a loop without breaking
> the rtp stream.
>
> To rewind the video I perform a flushing seek after I received the eos
> message. This works but the consequence is that the timestamps of the video
> jump back to zero. This causes invalid timestamp errors in the ffenc_mpeg4
> encoding element.
>
> How I can provide continuous timestamps after rewinding the file?
>
> Sample pipeline:
> gst-lauch -vvv filesrc location=test.avi ! avidemux ! xviddec !
> ffmpegcolorspace ! rawparse ! ffenc_mpeg4 ! rtpmp4vpay ! .send_rtp_sink_0
> gstrtpbin ! udpsink host=127.0.0.1 port=1234
>
> gst_element_seek( pipeline, (double)1.0,
> GST_FORMAT_TIME,GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,sec,GST_SEEK_TYPE_NONE,GST_CLOCK_TIME_NONE))
>
> Fanny
>
I got the problem solved by using the identity element and SEGMENT SEEK.
For documentation:
The problem was created by the ffenc_mpeg4 element after I did the seek to the begin of the file.
ffmpeg :0:: Error, Invalid timestamp=0, last=142
0:00:05.294620195 13255 0x20c4050 ERROR ffmpeg gstffmpegenc.c:723:gst_ffmpegenc_chain_video:<ffenc_mpeg40> ffenc_mpeg4: failed to encode buffer
To solve:
... setup your pipeline by using segments ...
gst_element_set_state(pipeline, GST_STATE_PAUSED);
gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
gst_element_seek(pipeline, 1, GST_FORMAT_TIME, (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT), GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_END, 0);
g_print ("Now playing: %s\n", file_buffer);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
...
for the bus call handler add:
case GST_MESSAGE_SEGMENT_DONE:{
gst_element_seek(pipeline, 1, GST_FORMAT_TIME, (GstSeekFlags)(GST_SEEK_FLAG_SEGMENT), GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_END, 0);
break;
}
The last step is to add the identity element to your pipeline with single-segment=true
->this consumes all incoming segments and only outputs one
->changes the timestamps of the buffers to running time, making them
appear as a continuous stream of data.
gst-launch -vvv filesrc location=test.avi ! avidemux ! ffdec_mpeg4 ! identity single-segment=true ! ffenc_mpeg4 ! rtpmp4vpay ! .send_rtp_sink_0
gstrtpbin ! udpsink host=127.0.0.1 port=1234
I got the pointer for the identity element in the following topic:
http://gstreamer-devel.966125.n4.nabble.com/Problem-using-gnlcomposition-td1690011.html#a1690011
Cheers Fanny
--
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
More information about the gstreamer-devel
mailing list