Opened 36 hours ago

Last modified 35 hours ago

#11402 new defect

directly convert some mp4 audio to opus cannot be decoded with opus-tools

Reported by: Saafo Owned by:
Priority: normal Component: undetermined
Version: 7.1 Keywords:
Cc: Saafo Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Saafo)

Summary of the bug:
How to reproduce:

% ffmpeg -i audio.mp4 audio.opus
opusinfo audio.opus

The generated audio.opus cannot be decoded with opusdec provided by opus-tools(version: 0.2)

% opusdec audio.opus audio.wav
Failed to open 'audio.opus'.

Debugging with opusfile(underlying opusdec), the error is OP_EBADTIMESTAMP(The first or last granule position of a link failed basic validity checks.)

And with opusinfo provided by opus-tools, there are many warnings:

% opusinfo audio.opus
Processing file "audio.opus"...

New logical stream (#1, serial: 610d6c9d): type opus
Encoded with Lavf61.7.100
User comments section follows...
	language=und
	handler_name=SoundHandler
	vendor_id=[0][0][0][0]
	encoder=Lavc61.19.100 libopus
	major_brand=isom
	minor_version=512
	compatible_brands=isomiso2mp41
WARNING: Samples with negative granpos in stream 1
WARNING: Sample count behind granule (96000<96001) in stream 1
WARNING: Sample count ahead of granule (144960>144958) in stream 1
WARNING: Sample count ahead of granule (193920>193915) in stream 1
Opus stream 1:
	Pre-skip: 312
	Playback gain: 0 dB
	Channels: 1
	Original sample rate: 48000 Hz
	Packet duration:   20.0ms (max),   20.0ms (avg),   20.0ms (min)
	Page duration:   1020.0ms (max),  836.0ms (avg),  140.0ms (min)
	Total data length: 30465 bytes (overhead: 2.08%)
	Playback length: 0m:04.159s
	Average bitrate: 58.59 kbit/s, w/o overhead: 57.37 kbit/s
Logical stream 1 ended

ffmpeg info:

% ffmpeg version
ffmpeg version 7.1 Copyright (c) 2000-2024 the FFmpeg developers
  built with Apple clang version 16.0.0 (clang-1600.0.26.4)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/7.1_3 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic' --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
  libavutil      59. 39.100 / 59. 39.100
  libavcodec     61. 19.100 / 61. 19.100
  libavformat    61.  7.100 / 61.  7.100
  libavdevice    61.  3.100 / 61.  3.100
  libavfilter    10.  4.100 / 10.  4.100
  libswscale      8.  3.100 /  8.  3.100
  libswresample   5.  3.100 /  5.  3.100
  libpostproc    58.  3.100 / 58.  3.100
[AVFormatContext @ 0x145e068d0] Unable to choose an output format for 'version'; use a standard extension for the filename or specify the format manually.
[out#0 @ 0x6000017a03c0] Error initializing the muxer for version: Invalid argument
Error opening output file version.
Error opening output files: Invalid argument

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Attachments (1)

audio.mp4 (37.1 KB ) - added by Saafo 35 hours ago.

Download all attachments as: .zip

Change History (4)

by Saafo, 35 hours ago

Attachment: audio.mp4 added

comment:1 by Saafo, 35 hours ago

Description: modified (diff)

comment:2 by Saafo, 35 hours ago

Found another interesting thing: converting the mp4 file to wav, and convert wav to opus will be ok:

% ffmpeg audio.mp4 audio.wav
% ffmpeg audio.wav audio.opus

check with opus-tools:

% opusinfo audio.opus
Processing file "audio.opus"...

New logical stream (#1, serial: 3b8b7d6b): type opus
Encoded with Lavf61.7.100
User comments section follows...
	encoder=Lavc61.19.100 libopus
Opus stream 1:
	Pre-skip: 312
	Playback gain: 0 dB
	Channels: 1
	Original sample rate: 48000 Hz
	Packet duration:   20.0ms (max),   20.0ms (avg),   20.0ms (min)
	Page duration:   1000.0ms (max),  836.0ms (avg),  180.0ms (min)
	Total data length: 30213 bytes (overhead: 1.61%)
	Playback length: 0m:04.160s
	Average bitrate: 58.1 kbit/s, w/o overhead: 57.17 kbit/s
Logical stream 1 ended
% opusdec audio.opus audio.wav
Decoding to 48000 Hz (1 channel)
Encoded with Lavf61.7.100
encoder=Lavc61.19.100 libopus
Decoding complete.        

comment:3 by Saafo, 35 hours ago

Summary: opus file generated by ffmpeg cannot be decoded with opus-toolsdirectly convert some mp4 audio to opus cannot be decoded with opus-tools
Note: See TracTickets for help on using tickets.