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 383420 - [ffmpeg] ISO-derivative muxers don't handle audio correctly
[ffmpeg] ISO-derivative muxers don't handle audio correctly
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-libav
git master
Other Linux
: Normal normal
: 0.10.5
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-12-07 16:46 UTC by Christian Fredrik Kalager Schaller
Modified: 2008-08-21 12:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
cleanups and duration fixes (17.02 KB, patch)
2006-12-11 16:02 UTC, Wim Taymans
none Details | Review
Patch for gstffmpegmux.c revision 1.48 (14.01 KB, patch)
2008-01-18 08:10 UTC, Laurent Glayal
none Details | Review
Patch to release 1.48 of gstffmpegmux.c (14.01 KB, patch)
2008-01-18 08:31 UTC, Laurent Glayal
none Details | Review

Description Christian Fredrik Kalager Schaller 2006-12-07 16:46:23 UTC
The ffmpeg 3GPP muxer doesn't handle audio like MP3 and AAC correctly.
Comment 1 Edward Hervey 2006-12-07 16:53:00 UTC
changing title. The problem is with ALL iso-based muxers (mov, 3gp, 3g2, mp4, m4a, 3j2, psp) since they all share the same code (libavformat/movenc.c)
Comment 2 Edward Hervey 2006-12-07 18:04:44 UTC
Please check the thread on the gst-devel mailing list with the thread titles:

"[gst-devel] ffmux_mp4 (gst-ffmpeg-0.10.1.1 CVS version) not correctly muxing AAC file to MP4"

Also, check bug #371939 which seems to be the same thing.
Comment 3 Wim Taymans 2006-12-11 16:00:50 UTC
ffmpeg movenc only supports packets with a fixed duration.
It does not respect timestamps on incomming packets so the input data needs to be a perfect stream.

The following line sortof works:

gst-launch audiotestsrc num-buffers=100 ! lame ! mp3parse ! ffmux_mp4 ! filesink location=test.mp4

For aac, we don't have a parser.
Comment 4 Wim Taymans 2006-12-11 16:02:21 UTC
Created attachment 78138 [details] [review]
cleanups and duration fixes

This patch fixes the duration in muxed files by setting the frame size to a sensible value based on the total duration and number of frames received.
Comment 5 Edward Hervey 2006-12-12 12:37:25 UTC
This still doesn't fix it.

The problem seems to be that mov_write_moov_tag (called by _write_trailer()) doesn't compute the SampleDuration for each track based on the frame size, it assumes that frame_size never changed :(

So the choice is now :
_ Either figure out the total duration of the file right at the beginning (contained in newsegment), so we can give the proper value for ->frame_size (kind of hacky).
_ Modify libavformat/movenc.c so that it recomputes the SampleDuration before writing the headers in _write_trailer().

Example pipeline where the behaviour is still broken (mpeg4/mp3 in .mp4):

gst-launch-0.10 filesrc location=/data/multimedia/matrix.ogg ! decodebin name=dbin ! queue name=vinq ! videoscale ! video/x-raw-yuv,width=128,height=96 ! ffenc_mpeg4 ! queue name=voutq ! ffmux_mp4 name=mux ! filesink location=matrix.mp4 dbin. ! queue name=ainq ! audioconvert ! audioresample ! audiorate ! lame ! queue name=aoutq ! mux.
Comment 6 Edward Hervey 2006-12-12 12:38:40 UTC
by the way, you will only see the error if you have another stream apart from the audio stream. Else it works (like with audiotestsrc ! lame ! ffmux_mp4).
Comment 7 Wim Taymans 2006-12-12 12:53:34 UTC
Like I said: ffmpeg movenc only supports packets with a fixed duration. If you give it the right fixed duration (with a parser) it works, if you don't (like in your example) it does not.
Comment 8 Laurent Glayal 2008-01-18 08:10:11 UTC
Created attachment 103123 [details] [review]
Patch for gstffmpegmux.c revision 1.48
Comment 9 Laurent Glayal 2008-01-18 08:14:38 UTC
Patch 'migrated' to revision 1.48 :
- some indentations are probably wrong. 
- compilation / runtime wroks but as it did before.... May be this patch will help someone.

pileline used to check :
gst-launch videotestsrc num-buffers=100 ! video/x-raw-yuv, framerate=\(fraction\)8/1, width=176, height=144 ! ffenc_h263p bitrate=36000 rtp-payload-size=1400 !  ffmux_mov audiotestsrc num-buffers=100 samplesperbuffer=160 ! amrnbenc ! identity sync=true ! ffmux_mov0. ffmux_mov0. ! filesink location=/tmp/lglayal.3gp


Resulting file properties :
[lglayal@tuxy mpeg4ip-1.5.0.1]$ ./lib/mp4v2/util/mp4info /tmp/lglayal.3gp
/home/lglayal/TMP/mpeg4ip-1.5.0.1/lib/mp4v2/util/.libs/lt-mp4info version 1.5.0.1
/tmp/lglayal.3gp:
Track   Type    Info
1       video   H263, 15637.375 secs, 0 kbps, 0x0 @ 0.006395 fps
2       audio   AMR, 4.480 secs, 6 kbps, 8000 Hz


Durations, like rate, size, fps are wrong.
Comment 10 Laurent Glayal 2008-01-18 08:31:16 UTC
Created attachment 103124 [details] [review]
Patch to release 1.48 of gstffmpegmux.c

correct regression about 'opended' variable.
Comment 11 Laurent Glayal 2008-01-18 10:32:49 UTC
The generated file does not seem to be usable with the following pipeline :

GST_DEBUG=3 gst-launch filesrc location=/tmp/lglayal.3gp ! decodebin ! fakesink 2>&1 | egrep "audio_|video_" | grep adding
0:00:00.224855000 28223 0x8152ab0 INFO      GST_ELEMENT_PADS gstelement.c:632:gst_element_add_pad:<qtdemux0> adding pad 'video_00'


Only a video pad is detected, on a correct file both pads, audio and video, are created.
Comment 12 Christian Fredrik Kalager Schaller 2008-01-18 13:09:10 UTC
Hi Laurent, regarding my promise to get this patch merged yesterday I need to break it. After a new discussion between myself, edward and wim we decided to that merging the patch before the ffmuxer problems are actually solved would be a bad idea. Going from broken to different broken doesn't really get us anywhere, and I assume the improvements which the patch currently bring doesn't really help you either. If you are interested in working on getting this up and running properly that would of course be great.
Comment 13 Laurent Glayal 2008-01-18 13:26:59 UTC
That's okay, unfortunately  i won't have time to work on it in the next months,... sorry :(
Comment 14 Mark Nauwelaerts 2008-08-04 09:29:36 UTC
Due to updates in ffmpeg and fixes in gstffmpegmux (see also bug #371939 and bug #541408), it appears this problem no longer applies and ffmux_mov & co produce working mov/mp4 files with proper properties according to qtinfo/mp4info (at least so for ffenc_mpeg4/x264/lame/faac etc).