GNOME Bugzilla – Bug 761392
avimux writes broken headers for mp3 audio stream
Last modified: 2016-02-01 18:20:45 UTC
Easy way to reproduce: nikita@hugenb:/tmp$ gst-launch-1.0 alsasrc ! lamemp3enc ! avimux ! filesink location=/tmp/f.avi Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... New clock: GstAudioSrcClock Redistribute latency... ^Chandling interrupt. Interrupt: Stopping pipeline ... Execution ended after 0:00:01.299496783 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ... nikita@hugenb:/tmp$ gst-launch-1.0 playbin uri=file:///tmp/f.avi Setting pipeline to PAUSED ... Pipeline is PREROLLING ... WARNING: from element /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0/GstAviDemux:avidemux0: Could not demultiplex stream. Additional debug info: gstavidemux.c(4043): gst_avi_demux_stream_header_pull (): /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0/GstAviDemux:avidemux0: failed to parse stream, ignoring ERROR: from element /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0/GstAviDemux:avidemux0: Could not demultiplex stream. Additional debug info: gstavidemux.c(4360): gst_avi_demux_stream_header_pull (): /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0/GstAviDemux:avidemux0: Could not get/create index ERROR: pipeline doesn't want to preroll. Setting pipeline to NULL ... Attempt to debug in shows that gst_avi_mux_riff_get_avi_header() is called before first call to gst_avi_mux_audsink_scan_mpeg_audio(), which causes audpad->hdr to be written before it is completely initialized. In particular it is written with hdr.scale=1, although later hdr.scale is set to other value.
Small correction: in debug session I used gst-launch-1.0 alsasrc ! lamemp3enc ! mpegaudioparse ! avimux ! filesink location=/tmp/f.avi (i.e. avimux git it with parsed=true)
The headers probably aren't getting finalized properly, pass the -e option to gst-launch, like this: $ gst-launch-1.0 -e alsasrc ! lamemp3enc ! avimux ! filesink location=/tmp/f.avi
It works with -e. Thanks, I was not aware of that. Still not sure it is corrent to (initially) write non-initialized headers. Rewriting later likely won't work with more complex sinks. Why not delaying header write until pushing first buffer? At that moment proper header data seems to be already known.
Thanks for confirming. Closing.
AVI is not really designed to be a streaming format, and I don't think we want to support it as such. As such, avimux will not work well with sinks that don't support seeking back to finalize headers. What you propose could probably be implemented, but I'm not sure it's worth it. That entire function looks a bit dodgy/suspicious.