News:

--

Main Menu

How to Batch process Audio tracks on avi files?

Started by Ogriv, May 23, 2016, 11:41:58 PM

Previous topic - Next topic

Ogriv

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!

Jan Gruuthuse

#1
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:
Quoteadm.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
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.

Ogriv

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

Sorry, I have no clue how to convert this to Mac.

Quotehow 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"
Quotehow 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:
cd \Videos
QuoteHow 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

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

#5
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
#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:
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 ;)

Ogriv

#6
Hi Jan,

Sorry for taking this long to respond.  I took a break from trying to get this going and forgot about it until recently when trying to watch these files again.

If you're still around, I tried the script again.  Running Avidemux 2.6.12 in Windows 7.  In Avidemux under File/Project Script/Run Project: selected "OneTrack" and I got the following error msg:

QuoteAssert failed :0 at line 16, file/home/fx/hudson/workspace/mingw32QT5/avidemux/qt4/common/ADM_editor/src/audio/ADM_edPoolOfAudioTracks.cpp

QuoteThe application has encountered a fatal problem
The current editing has been saved and will be reloaded at next start

QuoteADM_setCrashHook  [libADM_core6.dll]
ADM_backTrack  [libADM_core6.dll]
unknown function  [libADM_script_tinyPy.dll]
unknown function  [libADM_script_tinyPy.dll]
unknown function  [libADM_script_tinyPy.dll]
unknown function  [libADM_script_tinyPy.dll]

QuoteThis application has requested the Runtime to terminate in an unusual way.  Please contact the application's support team for more information

QuoteTinyPy:Exception

Exception: (_tp_dict_get) KeyError: nud BackTrack:
File:py2bc.py, line 51
File:py2bc.py, line 10
File:py2bc.py, line 424
File:py2bc.py, line 414
File:py2bc.py, line 199
File:py2bc.py, line 80
File:py2bc.py, line 63

Here's my OneTrack code:

Quote#PY
#--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")

and my MyJob.bat code:

QuoteSETLOCAL

set avidemux="C:\Program Files\Avidemux 2.6 - 32 bits

\avidemux.exe"
set outputfolder="C:\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

I don't get what I'm doing wrong, any help would be greatly appreciated - thanks again!

Jan Gruuthuse

Sorry, I can't help you any further with (virtual) windows / Mac OS.

Ogriv

I'm no longer using virtual windows.  The results posted above were from an actual pc.... 

eumagga0x2a

#9
Quote from: Ogriv on March 01, 2017, 01:33:50 AM
Running Avidemux 2.6.12 in Windows 7.

You should generally use at least the latest release (2.6.18), better the most recent nightly.

QuoteIn Avidemux under File/Project Script/Run Project: selected "OneTrack" and I got the following error msg:

QuoteAssert failed :0 at line 16, file/home/fx/hudson/workspace/mingw32QT5/avidemux/qt4/common/ADM_editor/src/audio/ADM_edPoolOfAudioTracks.cpp

This means you request from Avidemux an audio track with number exceeding the number of available audio tracks in the current video.

QuoteHere's my OneTrack code:

#PY

[...]
adm.audioAddTrack(1)

If the current video has only a single audio track, requesting a second one as above will crash Avidemux in the way you experience it.

edit: for clarity, tracks count starting with zero.

Ogriv

#10
Hi eumagga0x2a, thanks for your speedy response.  I grabbed the newer version of Avidemux v2.6.18.

The files I'm trying to process all have Italian on Audio Track 1 and English on Audio Track 2 so to save space I'd like to batch delete Audio track 1 (Italian) and keep Audio Track 2 (English).  I'm a newbie when it comes to programming so I'm not sure what code will do this


eumagga0x2a

Please post the output of MediaInfo or ffprobe for a file which triggers this crash (I'd like to verify that there are really two tracks).

Ogriv

okay, I'm assuming I just hit the icon with the "i" for info, if so, here it is:

Properties:

video

Code4CC: XVID
Image Size: 512x384
Aspect Ratio: 1:1 (1:1)
Frame Rate: 25.000 fps
total duration: 00:21:18:400

Extra video properties

ExtraDataSize: 00

Extra Data:

Audio

Codec: MP3
Channels Stereo
Bitrate: 1600Bps / s28 kbps
Viriable Bitrate:
Frequency: 48000 Hz
Total Duration: 00:21:18:408


eumagga0x2a

Avidemux prints info only about the first audio track, which is useless here. Please post the output of MediaInfo (or ffprobe) I have requested.

Ogriv

okay sorry, and how do I obtain this info in avidemux?  (sorry for my newbiness!)