News:

--

Main Menu

audio - unknown codec

Started by Erik_P, January 09, 2019, 05:54:26 PM

Previous topic - Next topic

Erik_P

AviDemix 2.7 (64 bit Windows) does not recognize the audio codec.
Audio Output in AviDemux was set to 'copy'.

I have uploaded a sample file:
https://we.tl/t-VI4cAMfQzC

Help would be appreciated.

Thx
Erik_P

dosdan

#1
I tried this with the Win64 190108 nightly build.  File | Information reports that the audio code is "unknown'.

MediaInfo has the audio stream as PCM Little/Signed and 24-bit.

FFPROBE also reports it as 24-bit audio, which I'm sure ADM doesn't support. (It's supposed to be a simple program, not all-encompassing):

Stream #0:1: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s32 (24 bit), 2304 kb/s


Perhaps a warning message about this should be shown in ADM when this type of clip is loaded?

Dan.

Erik_P

Thx for your feedback.
I conclude that AviDemux will not support this type of avi-files, or more specifically this audio codec.

Erik_P

dosdan

#3
Quote from: Erik_P on January 10, 2019, 02:03:48 PM
I conclude that AviDemux will not support this type of avi-files, or more specifically this audio codec.

It supports Signed (S) 16-bit Little Endian (LE) PCM, but not the 24-bit version. To edit it in ADM, first use FFMPEG (https://ffmpeg.zeranoe.com/builds/) to convert the audio stream inside the AVI to S16LE PCM: 

ffmpeg -i "sample file.avi" -c:v copy -c:a pcm_s16le -ar 48000 "sample file (16-bit version).avi" 

Double inverted commas are needed around the filenames if they contain a space.

Note: -ar 48000  does not appear to be necessary. FFMPEG preserved the original audio stream's 48KHz sampling rate without including this parameter in the FFMPEG command line:

ffmpeg -i "sample file.avi" -c:v copy -c:a pcm_s16le "sample file (16-bit version).avi" 


Here's the converted AVI. It plays OK in ADM. The video stream has just been copied, so there is no video quality loss. This type of operation is very quick.

https://dl.dropbox.com/s/imtbi45eur01wgd/sample%20file%20%2816-bit%20version%29.avi

If you need to convert a lot of these 24-bit clips, it's not hard to make a batchfile for this and just drop-and-drop one or more files to be converted on to this batchfile's icon on the Windows desktop.

Dan.

dosdan

#4
Quote from: dosdan on January 10, 2019, 07:49:19 PM
If you need to convert a lot of these 24-bit clips, it's not hard to make a batchfile for this and just drop-and-drop one or more files to be converted on to this batchfile's icon on the Windows desktop.

Here's Find_Convert_24-bit_PCM_to_16-bit.bat which uses both ffprobe and ffmpeg:

@echo off
cls
if not exist "%%~dpFconverted\" md "%%~dpFconverted\
for %%F in (%*) do (
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF" | find "pcm_s24le">nul && ffmpeg -i "%%~dpnxF" -hide_banner -v error -y -c:v copy -c:a pcm_s16le "%%~dpFconverted\%%~nF.avi" && echo The 24-bit PCM audio stream in "%%~dpnxF" was converted to 16-bit PCM and the new AVI placed in "%%~dpFconverted"
shift
)
pause


I didn't have any other AVIs with 24-bit audio, so I copied/renamed your original 24-bit file and my converted (16-bit) version 3 times, including names with spaces and parentheses to test the parsing accuracy of the batchfile. Here's the batchfile, with "D:\" in front since the batchfile is not situating in the current directory or in a directory in the PATH list. I'm running it from the command line here so I can intersperse the AVIs filenames to test that it ignores the 16-bit versions without stopping. If a "converted" sub-directory does not exist below the current directory, it's first created, and the converted files end up there.

The display at the command prompt:

C:\Users\Dan\Downloads>d:\Find_Convert_24-bit_PCM_to_16-bit.bat 24_1.avi 16_1.avi "24 2.avi" "16 2.avi" "24 (3).avi" "16 (3).avi"


The 24-bit PCM audio stream in "C:\Users\Dan\Downloads\24_1.avi" was converted to 16-bit PCM and the new AVI placed in "C:\Users\Dan\Downloads\converted"
The 24-bit PCM audio stream in "C:\Users\Dan\Downloads\24 2.avi" was converted to 16-bit PCM and the new AVI placed in "C:\Users\Dan\Downloads\converted"
The 24-bit PCM audio stream in "C:\Users\Dan\Downloads\24 (3).avi" was converted to 16-bit PCM and the new AVI placed in "C:\Users\Dan\Downloads\converted"
Press any key to continue . . .



It would also be possible to delete each of the original 24-bit files once it was successfully converted. Also the converted files could be kept in the original directory and their filenames altered to indicate that they are converted versions.

Dan.

Erik_P

That helps.
Thanks for proposing a solution.

Erik_P

stehtischtennis

dosdan thank you so much for your solution!

I was so frustrated that I had to encode my video files recorded from my Fujifilm X-T3 into smaller proxy files to even cut and edit them.

Your simple audio convertion is blazing fast and enables me to simply cutting scenes out between keyframes in Avidemux and that is still the fastest solution I have ever encountered!

dosdan

#7
Quote from: stehtischtennis on July 23, 2020, 09:10:33 PM
Your simple audio conversion is blazing fast and enables me to simply cutting scenes out between keyframes in Avidemux and that is still the fastest solution I have ever encountered!

Ah, I'd forgotten about that.  I suppose I should explain its operation.

ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF" | find "pcm_s24le">nul && ffmpeg -i "%%~dpnxF" -hide_banner -v error -y -c:v copy -c:a pcm_s16le "%%~dpFconverted\%%~nF.avi" && echo The 24-bit PCM audio stream in "%%~dpnxF" was converted to 16-bit PCM and the new AVI placed in "%%~dpFconverted"

ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF"

This displays tag entries in the streams called "codec_name". An example using a clip with a 24-bit uncompressed audio stream:

ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 testfile.avi
codec_name=mjpeg    [the video stream codec used here]
codec_name=pcm_s24le    [the audio stream codec]

Instead of showing this on the screen, the result is piped ("|") into the Windows FIND utility:
| find "pcm_s24le">nul

The result (here, "codec_name=pcm_s24le") is hidden by redirecting STDOUT (Standard Output) to the NUL device (a black hole).

A successful result for a search in FIND will then conditionally execute ("&&") the next section. To test this use &&cls (i.e. if successful, clear the screen):

ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 testfile.avi | find "codec_name=pcm_s24le" && cls will clear the screen

ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 testfile.avi | find "codec_name=gibberish" && cls
won't clear the screen. (Use the Up Arrow at the cmd prompt to reuse old commands.)

The actual section being conditionally executed:

&& ffmpeg -i "C:\test\testfile.avi" -hide_banner -v error -y -c:v copy -c:a pcm_s16le "C:\test\converted\testfile.avi"

This copies the video stream without processing,  but rapidly converts the 24-bit little-endian uncompressed audio stream to 16-bit little-endian uncompressed by dropping off the lowest 8 bits from each 24-bit word.

If this operation concluded successful, another conditional execution occurs:

&& echo The 24-bit PCM audio stream in "C:\test\testfile.avi" was converted to 16-bit PCM and the new AVI placed in "C:\test\converted"

ECHO displays a line of text to STDOUT

Dan.