bbc / audiowaveform

C++ program to generate waveform data and render waveform images from audio files
https://waveform.prototyping.bbc.co.uk
GNU General Public License v3.0
1.89k stars 241 forks source link

Recoverable frame level error while processing MP3 file #196

Closed SolarGuy8 closed 6 months ago

SolarGuy8 commented 6 months ago

Hi!

I have a problem with file, which almost down our production env. It's an MP3 file and my processing command:

audiowaveform -i 3a13529c-bad0-4278-a0ff-17cefda8168b.mp3 --pixels-per-second 1 --bits 8 --output-format json

The result:

Recoverable frame level error: reserved sample frequency value
Recoverable frame level error: lost synchronization
Recoverable frame level error: forbidden bitrate value
Recoverable frame level error: reserved sample frequency value
Recoverable frame level error: forbidden bitrate value
Recoverable frame level error: forbidden bitrate value
...

Ffmpeg result:

[STREAM]
index=0
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=LC
codec_type=audio
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=fltp
sample_rate=44100
channels=2
channel_layout=stereo
bits_per_sample=0
initial_padding=0
id=0x1
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/44100
start_pts=0
start_time=0.000000
duration_ts=11140096
duration=252.609887
bit_rate=93609
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=10879
nb_read_frames=N/A
nb_read_packets=N/A
extradata_size=2
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:non_diegetic=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
TAG:language=und
TAG:handler_name=SoundHandler
TAG:vendor_id=[0][0][0][0]
[/STREAM]
[FORMAT]
filename=3a13529c-bad0-4278-a0ff-17cefda8168b.mp3
nb_streams=1
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=0.000000
duration=252.609887
size=3000205
bit_rate=95014
probe_score=100
TAG:major_brand=M4A 
TAG:minor_version=512
TAG:compatible_brands=isomiso2
TAG:encoder=Lavf57.28.100
TAG:comment=highlight_start:2193 highlight_end:28596 user_delay=0
[/FORMAT]

Could you help me? Cause I really don't know what I should do with this problem

chrisn commented 6 months ago

The ffmpeg output shows that this file isn't MP3 format, it's AAC, which audiowaveform doesn't support.

SolarGuy8 commented 6 months ago

@chrisn, could you please provide a list of supported codecs?

chrisn commented 6 months ago

The documentation for the --input-filename and --input-format command line options describe the supported formats.

SolarGuy8 commented 6 months ago

@chrisn, some of our tracks have mp3 extenstion, but codec:

codec_name=pcm_s16le
codec_long_name=PCM signed 16-bit little-endian

or

codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)

it's also not OK? We should have codec_name=mp3 for this case?

SolarGuy8 commented 6 months ago

And why audiowaveform doesn't throw an error in this case, but still tries to get the data and the process goes on forever? Interrupts only when I kill the instance myself

chrisn commented 6 months ago

audiowaveform will behave unexpectedly if the actual formal of the audio doesn't agree with the file extension or the --input-format option.

For formats that audiowaveform doesn't support, you could try converting using ffmpeg first, e.g:

ffmpeg -i test.mp4 -f wav - | audiowaveform --input-format wav --output-format json -b 8 > test.json
SolarGuy8 commented 6 months ago

Codec name should be mp3 only? Not pcm_s16le or aac

chrisn commented 6 months ago

This is described in the documentation I linked to: wav, mp3, flac, ogg, opus, raw.

chrisn commented 6 months ago

And why audiowaveform doesn't throw an error in this case, but still tries to get the data and the process goes on forever? Interrupts only when I kill the instance myself

This is something that could be improved, yes.

SolarGuy8 commented 6 months ago

Okay, thank you! I really enjoy your library, thank you for your help!

chrisn commented 6 months ago

Thanks! I appreciate your feedback.