News:

--

Main Menu

batch processing with variable video codec

Started by seyar, December 01, 2018, 10:19:37 AM

Previous topic - Next topic

seyar

Hi guys,

I have a few video I would like to convert in batch from AC3 to AAC, without modifying the video codec.

Any idea how to do this ? Ideally I would just point to the folder and the script would detect if the audio is AC3 or not, if yes -> convert audio only.

Thanks for any help !

Kind Regards,
Alexandre

dosdan

#1
I worked out the detection side of this. This batchfile will show you only the flies containing AC3 audio streams in one or more directories.  In the example the files were a mixture of MTS and MP4s.

https://avidemux.org/smif/index.php/topic,18268.msg83705.html#msg83705

It would be easier, and less clunky, to do the whole test-for-AC3-and-convert outside ADM, using a batchfile running FIND (part of Windows/DOS), FFPROBE & FFMPEG.

Dan.

dosdan

#2
Here's a batchfile that, only if the original media file contains AC3, I've updated to copy the video steam and convert the audio stream from AC3 to AAC. I normally work with MP4 files from my camcorders. The only time I work with AC3 is when I set the camera to output AVCHD MTS files.The video streams in both container formats from these cameras is AVC. The AVCHD MTS files have either 2 (256kbps) or 5.1 channel AC3 (384kbps) and a subtitle stream (primitive date/time overlay). I've hardly every used AVCHD with these cameras.

Usage (one or more files): FIND_CONVERT AC3_TO_AAC  *.mp4  *.mts  Dancing.mts  d:\videos\test.mp4  "file has a space in the name.mts"

FIND_CONVERT AC3_TO_AAC.BAT
@echo off
cls
for %%F in (%*) do (
if not exist "%%~dpFconverted\" md "%%~dpFconverted\"
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1 "%%~dpnxF" | find "ac3">nul && ffmpeg -i "%%~dpnxF" -hide_banner -v error -y -c:v copy -c:a aac -b:a 256k "%%~dpFconverted\%%~nF.mp4" && echo The AC3 stream in "%%~dpnxF" was converted to 256K AAC and the new MP4 placed in "%%~dpFconverted"
shift
)
pause


The converted files are placed in a "converted" sub-directory below the original file(s) location. (Created if it does not exist.)

The original files in either MTS, M2TS or MP4 containers are recreated in the "converted" sub-directory. The output container format is MP4.

AAC is currently 256kbps. This should be OK for 2ch AC3. You could increase it to 384kbps (-b:a 384k) for 6ch (aka 5.1ch). There is no checking of the bitrate or channel count in the AC3.  6ch AC3 -> 6chl AAC inside the output MP4. I think this is non-standard usage and the MP4 may not play in normal MP4 players. There is no attempt to downmix from 6ch AC3 -> 2ch AAC. This will be possible, but I don't record 6ch AVCHD so I haven't bothered.

I tried to include the subtitle stream from the MTS (-c:s copy). This was not copied. It may be the PGS format used in the camcorder or trying to put it into an MP4 container. I don't convert downloaded movies so I normally don't work with subtitiles.

The convertor automatically overwrites the MP4 in "converted" if it already exists. Remove the "-y" switch from FFMPEG if you want to be prompted first.

Here is the test output display for a run using Find_Convert_AC3_to_AAC.bat  *.mts  "\test2\fred's clip.mts"

The AC3 stream in "D:\00000.MTS" was converted to 256K AAC and the new MP4 placed in "D:\converted"
The AC3 stream in "D:\Dancing.MTS" was converted to 256K AAC and the new MP4 placed in "D:\converted"
The AC3 stream in "D:\fred's clip.mts" was converted to 256K AAC and the new MP4 placed in "D:\converted"
The AC3 stream in "D:\test2\fred's clip.mts" was coverted to 256K AAC and the new MP4 placed in "D:\test2\converted"
Press any key to continue . . .


If you wanted, you could have it so that all output MP4s, regardless of their current directory, go into the same "converted" directory. (That's not normally the way I work.)

Dan.