Opened 5 years ago

Closed 5 years ago

#6319 closed defect (worksforme)

Raw audio is x2 times slower than it should be

Reported by: Thomas Thomas Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug: when converting mp3 file to raw audio file of format s16l and then converting it back to mp3, audio is slower x2 times.
How to reproduce:

ffprobe 1.mp3
ffmpeg -i 1.mp3 -y -f s16le 1.hex
ffmpeg -f s16le -i 1.hex -y 1.mp3
ffprobe 1.mp3

This is latest FFMPEG version. Output of ffprobe is:

Input #0, mp3, from '1.mp3':
    encoder         : Lavf57.57.100
  Duration: 00:00:03.02, start: 0.023021, bitrate: 128 kb/s
    Stream #0:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s
      encoder         : Lavc57.66


Input #0, mp3, from '1.mp3':
    encoder         : Lavf57.57.100
  Duration: 00:00:06.56, start: 0.025057, bitrate: 64 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, mono, s16p, 64 kb/s

If I change it to

ffmpeg -f s16le -ar 48000 -i 1.hex -y -b:a 128k 3.mp3

output frequency and bitrate are fixed, but audio is still x2 times slower (duration is still 6 seconds instead of 3). It should be 3.
I think there's no need to upload example mp3, because this bug appears with any mp3.

Change History (2)

comment:1 by Gyan, 5 years ago

Raw files contain no metadata to populate stream contexts, so those have to be specified. If not specified, ffmpeg falls back on default values. In this case, during conversion from raw to mp3, it's treating the input as mono, hence treating it as double the actual length.

Your third command should be ffmpeg -f s16le -ar 48000 -ac 2 -i 1.hex -y 1.mp3

comment:2 by Carl Eugen Hoyos, 5 years ago

Keywords: raw-audio removed
Priority: criticalnormal
Resolution: worksforme
Status: newclosed
Version: 3.2.4git-master
Note: See TracTickets for help on using tickets.