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 722672 - avmux_dv reports invalid audio caps
avmux_dv reports invalid audio caps
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-libav
git master
Other All
: Normal minor
: 1.2.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-01-21 05:36 UTC by Tim 'mithro' Ansell
Modified: 2014-02-04 15:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix. (1.03 KB, patch)
2014-01-21 12:02 UTC, Tim 'mithro' Ansell
committed Details | Review

Description Tim 'mithro' Ansell 2014-01-21 05:36:28 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;
}

-----------------------------------------
Comment 1 Sebastian Dröge (slomo) 2014-01-21 08:52:52 UTC
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?
Comment 2 Tim 'mithro' Ansell 2014-01-21 12:02:01 UTC
Created attachment 266855 [details] [review]
Fix.
Comment 3 Sebastian Dröge (slomo) 2014-01-21 12:23:37 UTC
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