GNOME Bugzilla – Bug 337866
[ffmpeg] timestamps wrong
Last modified: 2008-01-18 12:19:17 UTC
I've made a simple pipeline to read an avi file and seek to a frame. The pipeline is : filesrc ! avidemux ! ffdec_mpeg4 : avs3sink The sink is specific and allow to seek, in PAUSED state, to a specific frame. The program and the sink that I use are given as an attachment below. The avi file that I use for testing can be found here : http://www.iecn.u-nancy.fr/~torri/files/gstreamer_pb/blood.avi It has only one video stream. No audio. When I seek to frame 0, the timestamp of the buffer (or the stream time) that I get is different from the requested time (computed from the frame number and the frame rate). --gst-debug=avidemux:4 gives the following output : DEBUG (0x804f0a8 - 0:00:01.294759000) avidemux( 9087) gstavidemux.c(494):gst_avi_demux_handle_src_event:<demuxer> seek format 3, flags:3, 73646976, start:0, stop:-1 DEBUG (0x8175a00 - 0:00:01.295026000) avidemux( 9087) gstavidemux.c(2494):gst_avi_demux_process_next_entry:<demuxer> Flow on pad video_00: wrong-state DEBUG (0x8175a00 - 0:00:01.295126000) avidemux( 9087) gstavidemux.c(2617):gst_avi_demux_loop:<demuxer> stream_data flow: wrong-state DEBUG (0x804f0a8 - 0:00:01.295224000) avidemux( 9087) gstavidemux.c(2318):gst_avi_demux_handle_seek:<demuxer> Got keyframe entry 0 [stream:0 / ts:0:00:00.000000000 / duration:0:00:00.040000000]DEBUG (0x804f0a8 - 0:00:01.295314000) avidemux( 9087) gstavidemux.c(2329):gst_avi_demux_handle_seek:<demuxer> seek: 0:00:00.000000000 -- 0:01:00.000000000 keyframe seeking:0 update:1 DEBUG (0x804f0a8 - 0:00:01.295442000) avidemux( 9087) gstavidemux.c(562):gst_avi_demux_handle_src_event:<demuxer> returning 1 DEBUG (0x8175a00 - 0:00:01.295572000) avidemux( 9087) gstavidemux.c(2489):gst_avi_demux_process_next_entry:<demuxer> Processing buffer of size 3210 and time 0:00:00.000000000 on pad video_00 DEBUG (0x8175a00 - 0:00:01.298114000) avidemux( 9087) gstavidemux.c(2489):gst_avi_demux_process_next_entry:<demuxer> Processing buffer of size 3253 and time 0:00:00.040000000 on pad video_00 Timestamp : 40000000 Stream time : 40000000 seek to : 0 the timestamp (or the stream time) is equal to 1 / fps, while I want a time equal to 0. I've also tried to seek to frames i * 100, where i = 0, ..., 14 (there are 1500 frames in the video). For frames number 0, 200, 400, 600, 800, 1000, 1200 and 1400, the timestamp and the stream time are different from the requested time. The sink that I have written seems good (it works perfectly with mkv files, with a small fix in matroskademux). is it a bug in avidemux ?
Created attachment 63070 [details] test program Here is a test program that seek to a specific frame for an avi file. The archive contains a Makefile, the files for the sink and the test program itself. The sink element is installed in ~/.gstreamer-0.10/plugins and the shared library is named gstavs3sink.so Usage : ./seek_avi /path/to/avi/file frame actually, the last parameter ('frame') is not used.
That avi does not have a decodable frame at position 0. There is a keyframe at 0 but it is a static sprite I-VOP so the next frame is at 40000000.
was too fast.. sorry
if I replace ffdec_mpeg4 by xviddec, the buffer timestamps and the stream times are correct. So it seems that it's a bug with ffdec_mpeg4
that assumes xviddec has the timestamps correct...
renaming, avidemux is doing the right thing. ffmpeg timestamping is borked.
we are doing some serious insanity in there. I'm going to give a try at using the pts returned from ffmpeg after decoding and using those as timestamps, they seem saner than what we're doing currently.
timestamping in ffmpeg is now almost OK. The only remaining thing that needs to be implemented is the handling of delayed frames; the first frame might be such a delayed frame that is only returned from the decoder when the second frame is subitted. The picture number might give a clue...
Vincent, What's the status of this bug with latest gst-ffmpeg cvs ?
afaik, it is almost perfect. With blood.mkv, only the first frame has a wrong timestamp. With blood.avi, the first and second frame have wrong timestamp. It's better than before (the 3 or 4 first frames have wrong timestamps)
vincent, is that issue still present ? Quite a few fixes went into gst-ffmpeg regarding timestamps.
there is no improvement. I've changed the server where my tests are located: http://www.maths.univ-evry.fr/pages_perso/vtorri/files/gstreamer_test_seek.tar.bz2 the files are unpacked in a gstreamer_test_seek directory the videos that I use are located here: http://www.maths.univ-evry.fr/pages_perso/vtorri/files/gstreamer_test_seek/blood.mkv http://www.maths.univ-evry.fr/pages_perso/vtorri/files/gstreamer_test_seek/blood.avi
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init), (gst_ffmpegdec_open), (gst_ffmpegdec_get_buffer), (gst_ffmpegdec_release_buffer), (gst_ffmpegdec_video_frame), (gst_ffmpegdec_sink_event), (gst_ffmpegdec_chain): Rewrite timestamping code to let ffmpeg track timestamps. Fixes #482660, #337866.