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 541408 - gstffmpegmux + movenc : last buffer duration unit mismatch ?
gstffmpegmux + movenc : last buffer duration unit mismatch ?
Status: RESOLVED DUPLICATE of bug 371939
Product: GStreamer
Classification: Platform
Component: gst-libav
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-07-03 16:03 UTC by Aurelien Grimaud
Modified: 2008-07-06 20:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix working for ffmux_mov (969 bytes, patch)
2008-07-03 16:16 UTC, Aurelien Grimaud
reviewed Details | Review

Description Aurelien Grimaud 2008-07-03 16:03:26 UTC
I am recording RTP stream (h264 / AMR) to a mov file using ffmux_mov.
AMR is rate 8000 Hz.

When reading the file, buffers are timestamped correctly and each one have a duration of 20 ms, except the last one which have a duration of 2.5 sec.

movenc.c : mov_write_stts_tag : the duration for each entry is based on next entry (dts(i+1) - dts(i)), except the last one which involves total track duration (trackduraion - dts(i) + dts(0))
I think there is a problem with the units dts and trackduration 

gstffmpegmux.c : gst_ffmpegmux_collected : it computes pkt.dts and pkt.duration as following :
    * pkt.dts = gst_ffmpeg_time_gst_to_ff(GST_BUFFER_TIMESTAMP(buffer), time_base).
    Duration for movenc will though be 160 : which is the number of samples for 20 ms at 8000Hz

    * pkt.duration = gst_util_..scale_int(GST_BUFFER_DURATION(buffer), AV_TIME_BASE, GST_SECOND) which leads to a duration expressed in seconds. (20 ms here)

Therefore, in movenc.c, computing trackDuration by adding pkt.duration and pkt.dts is weird ! samples + seconds !

This leads to a last packet duration of 20000 (ms) instead of 160 (samples), and when file is played with qtdemux, the last buffer has a duration of 2.5 seconds : 20000 / 8000 .... The other ones has the righet duration : 20 ms which is 160/8000

I think there is a correction to do in gstffmpegmux.c to express pkt.duration in samples instead of seconds, or pkt.dts in second instead of samples.
But oggenc or matroskaenc are also adding pts and duration.

What do you think, what is wrong ?

in gstffmpegmux.c 1.31 there was pts = GST_BUFFER_TIMESTAMP(buf) * AV_TIMEBASE / GST_SECOND. 
in 1.32 it changed in av_rescale_q(GST_BUFFER_TIMESTAMP(buf),bq, ffmpegmux...->time_base), ecpressing pts in timebase instead of time.
Comment 1 Aurelien Grimaud 2008-07-03 16:16:20 UTC
Created attachment 113932 [details] [review]
fix working for ffmux_mov

This fixes it for my ffmux_mov ...
Maybe not with all mux ..
Comment 2 Mark Nauwelaerts 2008-07-06 20:57:01 UTC
In fact, this duration does not only mess up duration of the last buffer, but also the overall duration of the .mov (and .asf, .flv, etc).  The duration problem has already been noted for .mov elsewhere.

However, thanks for noting the problem here, and pointer to the cause !

*** This bug has been marked as a duplicate of 371939 ***