Author Topic: How to Batch process Audio tracks on avi files?  (Read 931 times)

Ogriv

  • Newbie
  • *
  • Posts: 3
How to Batch process Audio tracks on avi files?
« on: May 23, 2016, 11:41:58 PM »
HI Everyone,

I'm new to this program and have a ton of avi files that I'd like to batch process.  These files all have Italian for the first Audio Track and English on the Second Audio Track so to save space and select the correct Audio track I'd like to batch process all files to delete track audio 2 and select Track 1 for Track 1 English.

Since I'm new to this, it would be much appreciated if step by step instructions could be provided - Any help would be greatly appreciated, Thanks in advance!
« Last Edit: May 24, 2016, 11:36:48 AM by Ogriv »

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 4886
Re: How to Batch process Audio tracks on avi files?
« Reply #1 on: May 24, 2016, 06:56:07 AM »
You can only batch process on similar video files
If you are certain all video files have
track 0 (1st track) Italian audio
track 1 (1st track) English audio
Simple Command line usage with Tinpy Project

in addition to that you would need to edit this block:
Quote
adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"und")
adm.setSourceTrackLanguage(1,"und")
adm.audioAddTrack(0)
adm.audioCodec(0, "LavAAC");
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0,0)
adm.audioAddTrack(1)
adm.audioCodec(1, "copy");
adm.audioSetDrc(1, 0)
adm.audioSetShift(1, 0,0)

the strikethrough lines should be deleted
you would end up with block simular to this
Code: [Select]
adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"und")adm.audioAddTrack(0)
adm.audioCodec(0, "LavAAC");
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0,0)

this only example, you need to load a video in to avidemux and then save in Tinypy Project and edit to reflect your settings. Best you set the Language label to italian.

If one video has an English track as track 0 and Italian in track 1, the batch processing would leave the English audio track and delete track 1 the italian one.
« Last Edit: May 28, 2016, 05:49:05 AM by Jan Gruuthuse »

Ogriv

  • Newbie
  • *
  • Posts: 3
Re: How to Batch process Audio tracks on avi files?
« Reply #2 on: May 24, 2016, 06:23:06 PM »
Hi Jan,

Thanks for your response.  Unfortunately I'm missing the basic knowledge of how to even use the script. When I search the forums it's too advanced. Plus, as I understand starting from a certain time the scripting in Avidemux also changed... no luck on Avidemux wiki or Youtube either..

Is there are step-by-step tutorial on how to batch process?
ie: 
how do I load the script? 
how do I choose the folder I want to batch process? 
How do I choose where it'll will output or if it can simply replace the file?
once all settings are set, how do I get the batch processing to start?

I'm using the mac version of Avidemux v2.6.

Any help would be greatly appreciated - Thanks in advance!

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 4886
Re: How to Batch process Audio tracks on avi files?
« Reply #3 on: May 25, 2016, 04:51:32 AM »
Sorry, I have no clue how to convert this to Mac.

Quote
how do I load the script?
tinypy script is loaded from command line like avidemux --run "x264-aac(lav).py"
see windows: --run "x264-aac(lav).py"
Quote
how do I choose the folder I want to batch process?
on command line you would change directory into the folder you want to process
windows:
Code: [Select]
cd \Videos
Quote
How do I choose where it'll will output or if it can simply replace the file?
you would add the output folder name in front of the filename.

Can't answer the other questions as they related specific to MAC OS, and no information was found on my side regarding this.

Ogriv

  • Newbie
  • *
  • Posts: 3
Re: How to Batch process Audio tracks on avi files?
« Reply #4 on: May 28, 2016, 02:13:43 AM »
HI Jan,

Thanks for your response and help.  I managed to get the windows version working via virtual pc on my mac.

I managed to save a project script as batch.py and it looks like this:

#PY  <- Needed to identify #
#--automatically built--

adm = Avidemux()
adm.loadVideo("Z:/MEDIA1/MEDIA1 TV SHOWS/Frasier Complete/Frasier Season 05/Frasier 5x02 - The
Gift Horse dvdmux ITA-ENG.avi")
adm.clearSegments()
adm.addSegment(0, 0, 1277400000)
adm.markerA = 0
adm.markerB = 1277400000
adm.videoCodec("Copy")
adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"unknown")
adm.setSourceTrackLanguage(1,"und")
adm.audioAddTrack(1)
adm.audioCodec(0, "copy");
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0,0)
adm.setContainer("AVI", "odmlType=1")

How do I have it process the entire folder as apposed to just the one file?

Where will it save the file to?

Can you help me write the proper code to do the above?

Your help is greatly appreciated!

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 4886
Re: How to Batch process Audio tracks on avi files?
« Reply #5 on: May 28, 2016, 07:44:42 AM »
not tested:
- test with a few short videos (1 minute) in one folder
- copy MyJob.bat into folder with videos to process
- windows is case sensitive (Aa)!
- in file and path names:
-- avoid spaces and none US ascii (éèõ ....)
-- keep names and paths short

OneTrack.py
Code: [Select]
#PY  <- Needed to identify #
#--automatically built--

adm = Avidemux()

adm.videoCodec("Copy")
adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"unknown")
adm.setSourceTrackLanguage(1,"und")
adm.audioAddTrack(1)
adm.audioCodec(0, "copy");
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0,0)
adm.setContainer("AVI", "odmlType=1")

Windows batch file:
MyJob.bat:
Code: [Select]
SETLOCAL

set avidemux="C:\Program Files\Avidemux 2.6\avidemux3.exe"
set outputfolder="D:\video\
set myjob="OneTrack.py"
for %%f in (*.avi) do %avidemux% --force-alt-h264 --load "%%f" --run OneTrack.py --save "%1%outputfolder%\%%f.avi" --quit

ENDLOCAL

these must reflect exactly
- where avidemux is on your system (location): set avidemux
- where you want to save the modified avi's: set outputfolder

hope I did not produce any errors

perhaps windows users could have a look at this? and verify what I've done ;)
« Last Edit: May 28, 2016, 07:46:24 AM by Jan Gruuthuse »