[FFmpeg-trac] #3231(avcodec:new): Muxing libvorbis audio fails; no sound in the output file

FFmpeg trac at avcodec.org
Wed Dec 18 11:01:41 CET 2013


#3231: Muxing libvorbis audio fails; no sound in the output file
---------------------------------+---------------------------------------
             Reporter:  gyunaev  |                     Type:  defect
               Status:  new      |                 Priority:  normal
            Component:  avcodec  |                  Version:  unspecified
             Keywords:  vorbis   |               Blocked By:
             Blocking:           |  Reproduced by developer:  0
Analyzed by developer:  0        |
---------------------------------+---------------------------------------
 There seem to be an issue related to muxing vorbis audio in ffmpeg, both
 2.1.1 release and GIT head. The issue is fairly easy to reproduce with the
 muxing.c example in the FFmpeg doc/example directory by issuing the
 following command:

 {{{
 ./muxing test.webm
 }}}

 The resulting test.webm will play video fine with ffplay, and will have
 the audio track, but will output no sound. It does not generate any errors
 either.

 This issue is related to vorbis and not libvpx/webm container, which could
 be further proved by adding the following two lines to force muxing
 test.ogg into theora/vorbis:

 {{{
 --- muxing.c.orig       2013-12-18 01:25:24.126903125 -0800
 +++ muxing.c    2013-12-18 01:29:12.643882209 -0800
 @@ -487,6 +487,7 @@
      video_st = NULL;
      audio_st = NULL;

 +       fmt->audio_codec = AV_CODEC_ID_VORBIS;
      if (fmt->video_codec != AV_CODEC_ID_NONE) {
          video_st = add_stream(oc, &video_codec, fmt->video_codec);
      }
 }}}

 (this patch is necessary because by default it attempts to mux test.ogg
 into theora/flac - which by the way fails right away). And running make
 and executing as following:

 {{{
 ./muxing test.ogg
 }}}

 The resulted test.ogg will work exactly as test.webm above - ffplay will
 play only video and no sound.

 Further investigating this issue it looks like vorbis audio requires
 setting the frame->pts. Applying the following patch to muxing.c fixes the
 audio output:

 {{{
 --- muxing.c.orig       2013-12-18 01:25:24.126903125 -0800
 +++ muxing.c    2013-12-18 01:36:03.566844598 -0800
 @@ -258,6 +258,9 @@
          dst_nb_samples = src_nb_samples;
      }

 +    static int audio_pts = 0;
 +    frame->pts = audio_pts;
 +    audio_pts += dst_nb_samples;
      frame->nb_samples = dst_nb_samples;
      avcodec_fill_audio_frame(frame, c->channels, c->sample_fmt,
                               dst_samples_data[0], dst_samples_size, 0);
 }}}

 With this patch theora/vorbis audio mixes fine, and ./muxing test.ogg
 plays the sound. However this patch breaks muxing every other format - for
 example, .patched /muxing test.avi uses mpeg4/vorbis and loses sound after
 4 seconds. It is also seem to be exclusively vorbis-specific.
 libtheora+flac in ogg muxes without problem, while mpeg4+vorbis in AVI
 experiences the audio loss. More important, it doesn't fix webm
 libvpx/libvorbis, so it may be a different issue.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/3231>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list