Log in

View Full Version : Convert audio file


CapricornX10X
26th June 2022, 14:12
A bit delusional question ...

Is there any way to convert ac3 file to true-hd?

I know it's a bit ridiculous ... but I do not want it so that the audio quality is supposed to improve ...
I want to merge 2 audio files to 1 - and one is ac3 and the other is true-hd
And the part of the ac3 is something like 10 seconds ... so I have to change it to true-hd

tebasuna51
26th June 2022, 15:35
For free you can try:

ffmpeg -i "INPUT.ac3" -strict -2 -acodec truehd "OUTPUT.thd"

CapricornX10X
26th June 2022, 18:27
Where do I download the software ...
Can't find anywhere

CapricornX10X
26th June 2022, 18:56
For free you can try:

ffmpeg -i "INPUT.ac3" -strict -2 -acodec truehd "OUTPUT.thd"

you can guide me how to this

Barough
26th June 2022, 19:48
Where do I download the software ...
Can't find anywhere

You can grab FFmpeg from the link bellow
https://github.com/BtbN/FFmpeg-Builds/releases

CapricornX10X
26th June 2022, 20:23
You can grab FFmpeg from the link bellow
https://github.com/BtbN/FFmpeg-Builds/releases

I have no idea how to use it. I downloaded ..
And nothing can open

StainlessS
26th June 2022, 20:47
Ffmpeg, It's a command line program.
So, where Tebasuna51 posted

ffmpeg -i "INPUT.ac3" -strict -2 -acodec truehd "OUTPUT.thd"


you may need eg (unless you add path to FFMPEG to your system environment)

D:\SomePath\ffmpeg.EXE -i "D:\AudioInput\INPUT.ac3" -strict -2 -acodec truehd "D:\AudioOutput\OUTPUT.thd"


Also, Input.ac3 and output.thd are just filename examples.

StainlessS
26th June 2022, 21:12
You could maybe try this [should at least work for ac3, maybe also some other input formats, totally untested]

Bat file Batch Processes all audio files in INDIR folder that match the given file extensions, and converts into type thd in the OUTDIR folder.
AC3_To_THD.BAT

REM We DO NOT LIKE SPACES IN FILE NAMES (REM == REMark ie comment)
REM We DO NOT LIKE ACCENTS IN FILE NAMES.

setlocal

REM Where to Find ffmpeg
set FFMPEG="C:\BIN\ffmpeg.exe"

REM Where to get input file, No terminating Backslash, "." = current directory [EDIT: I.E., same as BAT File]
set INDIR="."


REM Where to place output file, No terminating Backslash. [EDIT: Or eg, set OUTDIR="D:\OUTPUT" ]
set OUTDIR=".\OUTPUT"

REM Can POSSIBLY add other file extensions to convert, SPACE separated eg " *.eac3", no idea if will work
FOR %%A IN ( *.ac3 ) DO (
%FFMPEG% -i "%INDIR%\%%A" -strict -2 -acodec truehd "%OUTDIR%\%%~nxA.THD"

)

Pause

Need to Edit Lines in BLUE, and can remove line in RED if required.

Extensions of input filetypes that are processed are shown in Purple [SPACE separated],
eg
*.ac3 *.eac3
(Where above we add SPACE separated " *.eac3", you can add more extensions in similar format,
NO IDEA if any extensions other than *.ac3 will work as required in the conversion, [I only ever bother with Stereo]).

Above bat file not tested. [I'm not sure what "-strict -2" does, or if applies to non ac3 input files]
(If it dont work with non *.ac3 extensions, then use only *.ac3 in Purple wildcard file extensions)

To use above (with 1st BLUE line edited to PATH to FFMPEG.EXE, other two BLUE lines untouched),
create some directory eg "CONVERT", inside it, put the bat file and also create an CONVERT\OUTPUT folder.
Copy ac3 input files to the CONVERT folder, run the bat file. Output thd files in CONVERT\OUTPUT.

Alternative additional mod, Change 2nd BLUE line Input Path to set INDIR=".\INPUT",
also create an CONVERT\INPUT folder, as well as CONVERT\OUTPUT. Put Input files in Input folder,
leaving CONVERT\ for conversion *.BAT files only.

EDIT:
This is similar style BAT file, Batch converts files of specified extensions, ALL to 16 bit Stereo WAV
Edit similar to above Bat.
Audio_to_16Bit_Stereo_WAV.BAT

REM Convert audio to 16 bit stereo
REM We DO NOT LIKE SPACES IN FILE NAMES (REM == REMark ie comment)
REM We DO NOT LIKE ACCENTS IN FILE NAMES.


setlocal

REM Where to Find ffmpeg
set FFMPEG="C:\BIN\ffmpeg.exe"

REM Where to get input file, No terminating Backslash, "." = current directory
set INDIR="."


REM Where to place output file, No terminating Backslash.
set OUTDIR=".\OUTPUT"


FOR %%A IN (*.thd *.dts *.ac3 *.w64 *.aac *.m4a *.eac3 *.wav) DO (
%FFMPEG% -i "%INDIR%\%%A" -vn -acodec pcm_s16le -ac 2 "%OUTDIR%\%%~nxA.WAV"

)

Pause


-vn = No video Output.
-acodec pcm_s16le = Pulse Code Modulated, 16 bit, Little Endian.
-ac 2 = 2 audio channels.
nxA.WAV = WAV file output.

StainlessS
27th June 2022, 21:24
CapricornX10X,
I answer you here instead of in PM.

Sorry, but now I've tried the BAT files, and have NOT been able to get them to work when anything other than INDIR=".",
Dont know what I've done to break them, think BAT template INDIR used to work years ago, but not now.
(Was shamlessly stolen from some good CLI Command guy's bat).

but here, this does work:- https://www.mediafire.com/file/dablj0085es5oiv/CONVERT.7z/file
Has

CONVERT\
CONVERT\BIN\
CONVERT\BIN\FFMPEG.Exe
CONVERT\OUTPUT\
CONVERT\Audio_to_16Bit_Stereo_WAV.BAT
CONVERT\AC3_To_THD.BAT [With *.ac3 and *.dts]

Must copy input files into CONVERT\ alongside the BAT files ::: Dont Change INDIR.

###################

Has anybody has a clue why the BAT file dont work when "Set INDIR=".\INPUT" (and also when CONVERT\INPUT\ exists with *.ac3 files) ?

The *.dts conversion thing shows something like "Only implemented fror Mono And Stereo" message when convert to THD,
maybe future version ffmpeg fixes that. (used version ffmpeg is only a few months old I think).

AC3_To_THD.BAT [With *.ac3 and *.dts]

REM We DO NOT LIKE SPACES IN FILE NAMES (REM == REMark ie comment)
REM We DO NOT LIKE ACCENTS IN FILE NAMES.

setlocal

REM Where to Find ffmpeg
set FFMPEG=".\BIN\ffmpeg.exe"

REM Where to get input file, No terminating Backslash, "." = current directory [EDIT: I.E., same as BAT File]
set INDIR="."

REM Where to place output file, No terminating Backslash. [EDIT: Or eg, set OUTDIR="D:\OUTPUT" ]
set OUTDIR=".\OUTPUT"

REM Can POSSIBLY add other file extensions to convert, SPACE separated eg " *.eac3", no idea if will work
FOR %%A IN ( *.ac3 *.dts ) DO (
%FFMPEG% -i "%INDIR%\%%A" -strict -2 -acodec truehd "%OUTDIR%\%%~nxA.THD"
)

Pause


Edited for wrap-around


C:\CONVERT>REM We DO NOT LIKE SPACES IN FILE NAMES (REM == REMark ie comment)

C:\CONVERT>REM We DO NOT LIKE ACCENTS IN FILE NAMES.

C:\CONVERT>setlocal

C:\CONVERT>REM Where to Find ffmpeg

C:\CONVERT>set FFMPEG=".\BIN\ffmpeg.exe"

C:\CONVERT>REM Where to get input file, No terminating Backslash, "." = current directory [EDIT: I.E., same as BAT File]

C:\CONVERT>set INDIR="."

C:\CONVERT>REM Where to place output file, No terminating Backslash. [EDIT: Or eg, set OUTDIR="D:\OUTPUT" ]

C:\CONVERT>set OUTDIR=".\OUTPUT"

C:\CONVERT>REM Can POSSIBLY add other file extensions to convert, SPACE separated eg " *.eac3", no idea if will work

C:\CONVERT>FOR %A IN (*.ac3 *.dts) DO (".\BIN\ffmpeg.exe" -i ""."\%A" -strict -2 -acodec truehd "".\OUTPUT"\%~nxA.THD" )

C:\CONVERT>(".\BIN\ffmpeg.exe" -i ""."\A.ac3" -strict -2 -acodec truehd "".\OUTPUT"\A.ac3.THD" )
ffmpeg version 5.0-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 11.2.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2
--enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray
--enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r
--enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec
--enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio
--enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame
--enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa
--enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
[ac3 @ 00000277505ace40] Estimating duration from bitrate, this may be inaccurate
Input #0, ac3, from '.\A.ac3':
Duration: 02:31:20.67, start: 0.000000, bitrate: 224 kb/s
Stream #0:0: Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (ac3 (native) -> truehd (native))
Press [q] to stop, [?] for help
Output #0, truehd, to '.\OUTPUT\A.ac3.THD':
Metadata:
encoder : Lavf59.16.100
Stream #0:0: Audio: truehd, 48000 Hz, stereo, s32 (24 bit), 128 kb/s
Metadata:
encoder : Lavc59.18.100 truehd
size= 1562240kB time=02:31:20.67 bitrate=1409.4kbits/s speed= 128x
video:0kB audio:1562240kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%

C:\CONVERT>Pause
Press any key to continue . . .

StainlessS
27th June 2022, 22:04
CapricornX10X, As said in PM, please post in thread.
I dont like PM, and am nearly always about 98%->99% full, and have to choose some PM's to get rid of, just to say post in thread.

You say that the batch file dont work.

Does line from post #7 work, ie [modded for your file and input / output directories of course]


D:\SomePath\ffmpeg.EXE -i "D:\AudioInput\INPUT.ac3" -strict -2 -acodec truehd "D:\AudioOutput\OUTPUT.thd"


Also, Does it convert to WAV via the CONVERT folder ? [EDIT: via CONVERT\Audio_to_16Bit_Stereo_WAV.BAT]

If not, does it play in some media player ?

What it does do might also be handy, ie error messages.

EDIT: It does have the ".ac3" extension, YES ? [EDIT: If not, then what extension]

CapricornX10X
27th June 2022, 22:12
I'm not the most knowledgeable in this environment of commands

I tried and failed, even with the file you sent for download

StainlessS
27th June 2022, 22:16
Does it have ac3 file extension ?
and if it fails, what does it do when it fails, what does it say ?

StainlessS
27th June 2022, 22:40
Can you down this small (4.6MB) AC3 file.
https://www.mediafire.com/file/svg2n5qjotcwnwf/A.AC3/file
and try again with the convert whotsit,
copy into the CONVERT folder, and
Double click "AC3_To_THD.BAT", output will be in OUTPUT folder.
Works here with exact same CONVERT folder upped to Mediafire several posts ago.

Source file was just 60 secs of mp3 podcast talking converted to AC3.

AC3

General
Complete name : C:\Z\A.AC3
Format : AC-3
Format/Info : Audio Coding 3
File size : 4.58 MiB
Duration : 1 min 0 s
Overall bit rate mode : Constant
Overall bit rate : 640 kb/s

Audio
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Duration : 1 min 0 s
Bit rate mode : Constant
Bit rate : 640 kb/s
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 44.1 kHz
Frame rate : 28.711 FPS (1536 spf)
Bit depth : 16 bits
Compression mode : Lossy
Stream size : 4.58 MiB (100%)


THD

General
Complete name : C:\CONVERT\OUTPUT\A.AC3.THD
Format : TrueHD
File size : 7.79 MiB
Overall bit rate mode : Variable

Audio
Format : TrueHD
Bit rate mode : Variable
Maximum bit rate : 9 597 kb/s
Channel(s) : 2 channels
Channel positions : Front: C
Sampling rate : 44.1 kHz
Frame rate : 1 102.500 FPS (40 spf)
Compression mode : Lossless

output above looks a bit strange, 2 channels, Center channel only.
Maybe I should have used (or converted to) AC3 to 48000Hz.

Anyways, it does convert whether complies with any kind of spec of not.

tebasuna51
28th June 2022, 01:12
...
The *.dts conversion thing shows something like "Only implemented fror Mono And Stereo" message when convert to THD,
maybe future version ffmpeg fixes that. (used version ffmpeg is only a few months old I think).
Work fine for 5.1 also:
General
Complete name : D:\Test\AudioD\Samples\ac3\6a321.ac3_.thd
Format : MLP FBA
Format/Info : Meridian Lossless Packing FBA
Commercial name : Dolby TrueHD
File size : 3.73 MiB
Overall bit rate mode : Variable

Audio
Format : MLP FBA
Format/Info : Meridian Lossless Packing FBA
Commercial name : Dolby TrueHD
Bit rate mode : Variable
Maximum bit rate : 9 597 kb/s
Channel(s) : 6 channels
Channel layout : L R C LFE Ls Rs
Sampling rate : 48.0 kHz
Frame rate : 1 200.000 FPS (40 SPF)
Compression mode : Lossless

Obtained with:

StainlessS
28th June 2022, 15:02
Thanks teb,
guess we just have to wait for CapricornX10X to show up.

CapricornX10X
28th June 2022, 15:57
Hi everyone friends ..
thanks very much
It took me a while to figure out ... but I eventually succeeded, along with useac3to

This allowed me to perform the conversion successfully.
But when I take the new thu file and put it in tsmuxer along with the video file.
And I mux ...
I play powerdvd and there is no audio

Thanks StainlessS
Thanks Barough
Thanks tebasuna51

CapricornX10X
30th June 2022, 18:44
So ... no one can help me?

SeeMoreDigital
30th June 2022, 20:29
Just so you know... The last time I tested the Dolby TrueHD audio encoder in FFmpeg, I wasn't able to hear them using my OPPO UDP-203 player!

You might be better off converting everything to 'lossy' Dolby Digital or even 'lossless' FLAC...

tebasuna51
1st July 2022, 03:02
So ... no one can help me?

I don't use Powerdvd, with mpc-hc the thd obtained with ffmpeg play fine.

Losko
5th July 2022, 10:17
You can grab FFmpeg from the link bellow
https://github.com/BtbN/FFmpeg-Builds/releases

Hey, this is worth bookmarking :thanks:

Barough
5th July 2022, 20:19
Just found a FFmpeg Audio Encoder GUI
https://github.com/jlw4049/FFMPEG-Audio-Encoder

Balling
5th October 2022, 22:19
Just so you know... The last time I tested the Dolby TrueHD audio encoder in FFmpeg, I wasn't able to hear them using my OPPO UDP-203 player!

You might be better off converting everything to 'lossy' Dolby Digital or even 'lossless' FLAC...

It works now, it was a bug in some old ffmpeg. Plex also did not like it and did not decode, but now it does. Some artefacts can still happen, even though ffmpeg decoder did not care.

SeeMoreDigital
9th October 2022, 10:39
It works now, it was a bug in some old ffmpeg. Plex also did not like it and did not decode, but now it does. Some artefacts can still happen, even though ffmpeg decoder did not care.Thanks for letting me know. I'll create some new encodes, test them on my OPPO's and report back...

SeeMoreDigital
13th October 2022, 15:01
Thanks for letting me know. I'll create some new encodes, test them on my OPPO's and report back...
I can confirm that after using 'ffmpeg-2022-10-10-git-f3b5277057-essentials_build' I have managed to generate an viable 2-channel TrueHD.thd stream (muxed within .mka) that works perfectly with my OPPO....

Roll on multi-channel TrueHD encoding ;)

Balling
6th October 2023, 20:26
I can confirm that after using 'ffmpeg-2022-10-10-git-f3b5277057-essentials_build' I have managed to generate an viable 2-channel TrueHD.thd stream (muxed within .mka) that works perfectly with my OPPO....

Roll on multi-channel TrueHD encoding ;)

Hi. We fixed stereo artefacts. Please verify it still works on Oppo, though Dolby Refernce player is perfect: https://github.com/FFmpeg/FFmpeg/commit/d7579189f762065f8efd63aea12e6e59c303d5ae

richardpl
21st October 2023, 10:35
The multi-channel TrueHD is now possible, 3.0, 2.1, 5.0, 5.1 layouts are already implemented and decodes fine with dolby decoder.
The compression ratio still have places to improve.