[FFmpeg-trac] #5240(avcodec:new): opus encoded audio loses information about the original sample rate (unlike opusenc)

FFmpeg trac at avcodec.org
Tue Feb 16 19:35:54 CET 2016


#5240: opus encoded audio loses information about the original sample rate (unlike
opusenc)
---------------------------------+--------------------------------------
             Reporter:  redneb   |                     Type:  defect
               Status:  new      |                 Priority:  normal
            Component:  avcodec  |                  Version:  git-master
             Keywords:           |               Blocked By:
             Blocking:           |  Reproduced by developer:  0
Analyzed by developer:  0        |
---------------------------------+--------------------------------------
 Opus uses 48 kHz for all files. So when a file with a different sample
 rate is encoded, it has to be resampled to 48 kHz. But the resulting file
 contains information about the original sample rate. This way, when the
 file is decoded, it will be resampled to the original sample rate if
 necessary. Unfortunately, this doesn't happen with ffmpeg; an
 encode/decode cycle with ffmpeg will always result in a 48 kHz file.

 Here's an example.
 Let's create a 44.1 kHz file:
 {{{
 $ ffmpeg -filter_complex 'sine=d=30' sine.wav
 }}}
 Then let's encode it to opus using `opusenc`:
 {{{
 $ opusenc sine.wav sine1.opus
 }}}
 If we decode that file with `opusdec` we'll get a 44.1 kHz file:
 {{{
 $ opusdec sine1.opus sine1.wav
 Decoding to 44100 Hz (1 channel)
 [...]
 }}}
 This works because the `opusenc` stores the original sample rate in the
 resulting file:
 {{{
 $ opusinfo sine1.opus | grep 'Original sample rate'
         Original sample rate: 44100Hz
 }}}

 On the other hand, if we encode using `ffmpeg` this doesn't work:
 {{{
 $ ffmpeg -i sine.wav -c:a libopus sine2.opus
 ffmpeg version N-46907-g80580bb Copyright (c) 2000-2015 the FFmpeg
 developers
 [...]
 $ opusinfo sine2.opus | grep 'Original sample rate'
         Original sample rate: 48000Hz
 }}}

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


More information about the FFmpeg-trac mailing list