After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 337866 - [ffmpeg] timestamps wrong
[ffmpeg] timestamps wrong
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-libav
git master
Other Linux
: Normal normal
: 0.10.4
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-04-09 22:58 UTC by Vincent Torri
Modified: 2008-01-18 12:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test program (5.01 KB, application/x-compressed-tar)
2006-04-09 23:03 UTC, Vincent Torri
Details

Description Vincent Torri 2006-04-09 22:58:52 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 ?
Comment 1 Vincent Torri 2006-04-09 23:03:00 UTC
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.
Comment 2 Wim Taymans 2006-04-11 09:45:38 UTC
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.
Comment 3 Wim Taymans 2006-04-11 10:03:13 UTC
was too fast.. sorry
Comment 4 Vincent Torri 2006-04-11 11:14:17 UTC
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
Comment 5 Wim Taymans 2006-04-21 17:56:26 UTC
that assumes xviddec has the timestamps correct...
Comment 6 Wim Taymans 2006-04-21 18:10:19 UTC
renaming, avidemux is doing the right thing. ffmpeg timestamping is borked.
Comment 7 Edward Hervey 2006-05-26 14:27:38 UTC
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.
Comment 8 Wim Taymans 2006-09-09 13:15:24 UTC
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...
Comment 9 Edward Hervey 2006-10-07 07:09:12 UTC
Vincent, What's the status of this bug with latest gst-ffmpeg cvs ?
Comment 10 Vincent Torri 2006-10-07 09:19:20 UTC
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)
Comment 11 Edward Hervey 2007-08-14 15:04:35 UTC
vincent, is that issue still present ? Quite a few fixes went into gst-ffmpeg regarding timestamps.
Comment 12 Vincent Torri 2007-09-01 09:40:34 UTC
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
Comment 13 Wim Taymans 2008-01-18 12:19:17 UTC
        * 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.