GNOME Bugzilla – Bug 722672
avmux_dv reports invalid audio caps
Last modified: 2014-02-04 15:59:36 UTC
libav only supports encoding DV with 2 channel, 48kHz, 16bit PCM audio but avmux_dv reports supporting a wide range of frequencies. ----------------------------------------- $ gst-inspect-1.0 avmux_dv <snip> SINK template: 'audio_%u' Availability: On request Has request_new_pad() function: 0x7fc03826a7f0 Capabilities: audio/x-raw channels: [ 1, 2 ] rate: [ 4000, 96000 ] format: S16LE layout: interleaved <snip> $ ----------------------------------------- The correct output would be; ----------------------------------------- $ gst-inspect-1.0 avmux_dv <snip> SINK template: 'audio_%u' Availability: On request Has request_new_pad() function: 0x7fc03826a7f0 Capabilities: audio/x-raw channels: [ 2 ] rate: [ 48000 ] format: S16LE layout: interleaved <snip> $ ----------------------------------------- If you fail to send the correct 2 channel, 48kHz audio you get an error something like; ----------------------------------------- Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... New clock: GstSystemClock ERROR: from element /GstPipeline:pipeline0/ffmux_dv:dvmux: Could not configure supporting library. Additional debug info: gstffmpegmux.c(665): gst_ffmpegmux_collected (): /GstPipeline:pipeline0/ffmux_dv:dvmux: Failed to write file header - check codec settings ----------------------------------------- ############################################## # Where are these caps coming from? ############################################## The caps come from the following function in gstavcodecmap.c; ----------------------------------------- static GstCaps * gst_ff_aud_caps_new (AVCodecContext * context, AVCodec * codec, enum AVCodecID codec_id, gboolean encode, const char *mimetype, const char *fieldname, ...) { ----------------------------------------- They seem to be from hitting a default else on the following lines in gstavcodecmap.c; ----------------------------------------- 706 } else { 707 gst_caps_set_simple (caps, "rate", GST_TYPE_INT_RANGE, 4000, 96000, NULL); 708 } ----------------------------------------- ############################################## # libavformat DV audio support info ############################################## From libavformat/dvenc.c ----------------------------------------- /* Some checks -- DV format is very picky about its incoming streams */ if (!vst || vst->codec->codec_id != AV_CODEC_ID_DVVIDEO) goto bail_out; for (i=0; i<c->n_ast; i++) { if (c->ast[i] && (c->ast[i]->codec->codec_id != AV_CODEC_ID_PCM_S16LE || c->ast[i]->codec->sample_rate != 48000 || c->ast[i]->codec->channels != 2)) goto bail_out; } ----------------------------------------- static int dv_write_header(AVFormatContext *s) { if (!dv_init_mux(s)) { av_log(s, AV_LOG_ERROR, "Can't initialize DV format!\n" "Make sure that you supply exactly two streams:\n" " video: 25fps or 29.97fps, audio: 2ch/48kHz/PCM\n" " (50Mbps allows an optional second audio stream)\n"); return -1; } return 0; } -----------------------------------------
Yes, I can confirm that. The problem is that gst_ffmpegmux_get_id_caps() calls gst_ffmpeg_codecid_to_caps(), and from there on the information is lost that this is for DV. So everything possible for the audio and video codec IDs is added to the caps, which is more than what DV can support. We would need a gst_ffmpeg_codecid_to_caps_for_format() that takes the container format type, has special cases for some combinations and otherwise just calls gst_ffmpeg_codecid_to_caps(). Want to provide a patch?
Created attachment 266855 [details] [review] Fix.
commit 520221c47a64e46c23cf120b9e8a497b6af157da Author: Tim 'mithro' Ansell <mithro@mithis.com> Date: Tue Jan 21 22:58:42 2014 +1100 avmux: Force DV audio input format to 48kHz, 2 channels libavformat only supports muxing 16bit, 48kHz stereo into DV containers. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=722672