continuous video timestamps after seek

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

continuous video timestamps after seek

fannys
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



--
GMX DSL SOMMER-SPECIAL: Surf & Phone Flat 16.000 für nur 19,99 Euro/mtl.!*
http://portal.gmx.net/de/go/dsl

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: continuous video timestamps after seek

fannys

-------- Original-Nachricht --------
> Datum: Fri, 01 Oct 2010 04:35:45 +0200
> Von: [hidden email]
> An: [hidden email]
> 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

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel