asfdemux: Add byte rate based bitrate tag in case there are no audio props
authorCarlos Rafael Giani <dv@pseudoterminal.org>
Tue, 2 Aug 2016 11:38:25 +0000 (13:38 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 2 Aug 2016 11:41:31 +0000 (14:41 +0300)
https://bugzilla.gnome.org/show_bug.cgi?id=769418

gst/asfdemux/gstasfdemux.c

index f65bf82..283538c 100644 (file)
@@ -2625,6 +2625,27 @@ gst_asf_demux_add_audio_stream (GstASFDemux * demux,
     g_free (codec_name);
   }
 
+  if (audio->byte_rate > 0) {
+    /* Some ASF files have no bitrate props object (often seen with
+     * ASF files that contain raw audio data). Example files can
+     * be generated with FFmpeg (tested with v2.8.6), like this:
+     *
+     *   ffmpeg -i sine-wave.wav -c:a pcm_alaw file.asf
+     *
+     * In this case, if audio->byte_rate is nonzero, use that as
+     * the bitrate. */
+
+    guint bitrate = audio->byte_rate * 8;
+
+    if (tags == NULL)
+      tags = gst_tag_list_new_empty ();
+
+    /* Add bitrate, but only if there is none set already, since
+     * this is just a fallback in case there is no bitrate tag
+     * already present */
+    gst_tag_list_add (tags, GST_TAG_MERGE_KEEP, GST_TAG_BITRATE, bitrate, NULL);
+  }
+
   if (extradata)
     gst_buffer_unref (extradata);