News:

--

Main Menu

Add second audio track to MKV file

Started by Dewey, April 05, 2016, 04:13:12 PM

Previous topic - Next topic

mean

Each time you load a file, you reset a lot of settings
You should not have to do replace / by  \
If needed it should be \/ to //

Dewey

What's the syntax required for this line? I've tried as you suggested and I can't get it to work.

filein=filein.replace("\/", "/");


[Script] Tinypy INFO - E:/iPadConvCache/\Test.mkv=>E:/iPadConvCache/\Test.mkv.mkv

Since I think I'm trying to change the /\ string piece to just a forward / in the above logfile output, I also tried a few other options, but again I'm not really sure what I'm doing  :-\

filein=filein.replace(/\\/, "/");

googling it, it seems like my issue is related to the fact the / is seen as an escape character and I need to remove it, unfortunately I'm not a coder so I'm struggling with the syntax. Am I on the right track here?

Jan Gruuthuse

Windows \ (back slash): E:\iPadConvCache\Test.mkv.mkv
Linux / (forward slash): ~/Downloads/Test.mkv

Do note you have twice the file extension: .mkv.mkv

Dewey

Hi Jan, Under win10 x64 / (forward slash) seems to be the convention, which I thought was odd (I grew up with MSDOS) initially... Tested with backlashes early on and it failed.

The double mkv is just a place holder for the moment as I don't want to over write the original - eventually I want to move it into a sub directory but struggling at the moment to just get the file string in the right format :(

Any help with the syntax for the .replace would be great!

Cheers,
D

Jan Gruuthuse

Sorry m8, don't have windows to test on these.

Dewey

#20
no worries, appreciate the input so far.

@mean, any help with the syntax? I'm a little stuck :(

AQUAR

#21
The windows command line interpreter uses only \ slashes as path separators.
But windows itself accepts either (/ or \ as path separators (try it in windows explorer!).

For info wrt the post below: 
AddMP3Audio.bat = CLI script = only \
AddMP3Audio.py = tiny python script = windows API = \ or /

Dewey

oh dear... it's always the small bugs that seem to keep you hunting for days on end  :o

So, I finally got this working - yay!! - thanks @mean & @Jan Gruuthuse, your help was appreciated.

My issue in the end was with the slash convention (w10 x64 requires forward slashes for the file string '/') in the file string, as I'd started to suspect. However, rather than apply this change to my earlier tests (the soln was actually in post #3) I was plowing ahead with ever more complex options to try and resolve this.

For the Dev Team: What would be good here is if the error thrown could give more useful information. Like file not found, or something. Although I suspect because the backslash in the file string is an escape character you might not be able to catch this before it throws the error...

For any user stumbling across this thread:
First check the file string convention of your os, then you can implement as follows. Was all very minor code in the end;

Batch File: AddMP3Audio.bat
set avidemux="C:\Program Files\Avidemux\avidemux.exe"
for %%f in (*.mkv) do %avidemux% --load "%%f" --save-raw-audio "E:\iPadConvCache\audiodump" --run "AddMP3Audio.js" --save "Output\%%f" --quit


AVIdemux Script: AddMP3Audio.js
#PY  <- Needed to identify #
#--automatically built--

adm = Avidemux();
adm.audioAddExternal("E:/iPadConvCache/audiodump");
adm.audioAddTrack(1);
adm.audioCodec(1, "Lame", "bitrate=192", "preset=0", "quality=1", "disableBitReservoir=False");
adm.audioSetMixer(1, "STEREO");
adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280");


Simples  :P

Jan Gruuthuse

Nicely done, just one remark "AddMP3Audio.js" should be "AddMP3Audio.py". See 1st line of your script
Quote#PY  <- Needed to identify #
indicating Tinypy scripting is used. ;)

Dewey

Noted... and Changed. Script still works. Thanks again for your help.
D