How to scan audio codecs with ffmpeg

Videos, guides, manuals, documents and tutorials about using tools and performing tasks
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

How to scan audio codecs with ffmpeg

Post by aluigi »

Sometimes you may have a file containing raw compressed audio.

Some audio codecs are easy to recognize because they use signatures (wma, mp3, ogg) and are supported by many programs.

But sometimes it may be difficult, moreover if it's an adpcm algorithm which is not the usual ima-adpcm.

The following is an helpful script for quickbms:

Code: Select all

# adpcm_4xm
# adpcm_adx
# adpcm_afc
# adpcm_ct
# adpcm_dtk
# adpcm_ea
# adpcm_ea_maxis_xa
# adpcm_ea_r1
# adpcm_ea_r2
# adpcm_ea_r3
# adpcm_ea_xas
# adpcm_g722
# adpcm_g726
# adpcm_g726le
# adpcm_ima_amv
# adpcm_ima_apc
# adpcm_ima_dk3
# adpcm_ima_dk4
# adpcm_ima_ea_eacs
# adpcm_ima_ea_sead
# adpcm_ima_iss
# adpcm_ima_oki
# adpcm_ima_qt
# adpcm_ima_rad
# adpcm_ima_smjpeg
# adpcm_ima_wav
# adpcm_ima_ws
# adpcm_ms
# adpcm_sbpro_2
# adpcm_sbpro_3
# adpcm_sbpro_4
# adpcm_swf
# adpcm_thp
# adpcm_vima
# adpcm_xa
# adpcm_yamaha

set MAX_OUTPUT_SECONDS long 3
set INPUT string "%1"
for
    get CODEC line
    if CODEC & "#"
        string CODEC R= "#" ""
        string CODEC R= " " ""
        print "ffmpeg -acodec %CODEC% -ac 2 -vn -f data -i %INPUT% -t %MAX_OUTPUT_SECONDS% %CODEC%.wav"
    else
        cleanexit
    endif
next

Now try to launch the script with quickbms from command-line dumping its content in a bat file:

Code: Select all

quickbms script.bms script.bms > scan.bat

And then launch the bat:

Code: Select all

scan.bat myfile.adpcm

It will create a bat file that automatically launch ffmpeg to convert the input file in a 16bit pcm file.

Unfortunately it's not possible to force the number of channels with ffmpeg if the input file has an header, while instead it's possible with ffplay.

Anyway if you want to force a certain number of channels you must add the -ac option, for example "-ac 1" for mono.

Technically the script is quite interesting, basically it reads its comments and use them to create the necessary command.

*edit* added "-ac 2 -vn -f data"
raykingnihong
Posts: 71
Joined: Fri Oct 24, 2014 3:13 pm

Re: How to scan audio codecs with ffmpeg

Post by raykingnihong »

Hi aluigi my good friend, very good tutorial and script, thanks for sharing
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: How to scan audio codecs with ffmpeg

Post by aluigi »

Just an update.
I guess that the current version of ffmpeg no longer works with that command-line and even adding other options doesn't change the situation.
I'm really disappointed by ffmpeg that is impossible to configure.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: How to scan audio codecs with ffmpeg

Post by AnonBaiter »

"Output file #0 does not contain any stream"
What should I do if ffmpeg doesn't support audio files that doesn't have any headers?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: How to scan audio codecs with ffmpeg

Post by aluigi »

The "-f data" option forces ffmpeg to work on raw data.
I guess that error is caused by a codec that requires some specific headers (even in raw mode?) or specific options to set some parameters.