Author Topic: Script mkv/ac3 to acc/mp4  (Read 11908 times)

Monkeyk

  • Newbie
  • *
  • Posts: 6
Script mkv/ac3 to acc/mp4
« on: April 14, 2012, 11:33:12 AM »
I love Avidemux but iam having one problem.
I trief alot of scripts  (bat) but i cant seem to get it to work.

Input: MKV AC3 5.1
Output: MP4 ACC stereo.

I want to copy the video part but re-encode the sound to mp3 or ACC stereo.
I can convert the video files with mp3 but cant get it to stereo.

Do any of u guys know how to script this (.bat)


Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6051
« Last Edit: April 14, 2012, 11:43:21 AM by Jan Gruuthuse »

Monkeyk

  • Newbie
  • *
  • Posts: 6
Re: Script mkv/ac3 to acc/mp4
« Reply #2 on: April 15, 2012, 12:18:04 PM »
Thanks,

I tried making a script with those links but as a nOOb i cant seem to get it right :(

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6051
Re: Script mkv/ac3 to acc/mp4
« Reply #3 on: April 15, 2012, 01:40:15 PM »
You do have a batch file processing the video files converting to mp3?
the section: "Combination of command-line and JS scripting"
Quote
You can create scripts quite easily by yourself. You can apply needed settings via GUI and then use File → Save Project As… to create text file that contains all settings. Then you can open that file in text editor and copy+paste needed stuff to new script (or replaces parts of other script).
Load same kind of video you want to convert in batch in avidemux
Set all parameters in Video, Audio and Output Format that you need for successful conversion and save the project something.js as described above. Edit that something.js
Remove lines where video is loaded and the markers are set.
You should have something similar as in the example.

This batch file uses the project you edited above.
Code: [Select]
set avidemux="C:\Program Files\Avidemux 2.5\avidemux2.exe"
for %%f in (*.mp4) do %avidemux% --force-alt-h264 --load "%%f" --run something.js --save "%%f.avi" --quit
replace bolded (*.mp4) by the video container you're processing.
replace bolded  --save "%%f.avi" by video container you want to save.

What works, what not, what happens ...

Monkeyk

  • Newbie
  • *
  • Posts: 6
Re: Script mkv/ac3 to acc/mp4
« Reply #4 on: April 15, 2012, 06:16:23 PM »
Hey jan thanks for the reply.

This is what i got, ive done this the way u told me (save as .js)
The strange thing is it doesnt show audio settings (i selected mp3 + stereo as filter)
It wil start converting but gives an error that the movie has more audio channels.
Ive i do the samething manually it works perfect but through the batch/js it doesnt....


//AD  <- Needed to identify//
//--automatically built--
//--Project: C:\Users\xbmc\Desktop\test.js

var app = new Avidemux();

//** Video **
// 01 videos source
app.load("C:/Users/xbmc/Desktop/Test-AC3.mkv");
//01 segments
app.clearSegments();
app.addSegment(0,0,28832);
app.markerA=0;
app.markerB=28831;

//** Postproc **
app.video.setPostProc(3,3,0);

app.video.fps1000 = 23976;

//** Filters **

//** Video Codec conf **
« Last Edit: April 15, 2012, 06:18:18 PM by Monkeyk »

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6051
Re: Script mkv/ac3 to acc/mp4
« Reply #5 on: April 16, 2012, 06:22:42 AM »
Before you save a project you need to set
in Audio: MP3(lame) and now in Filters: Window: Audio Filters: Mixer: Stereo
in Format: the wanted container format: MKV
Code: [Select]
//AD  <- Needed to identify//
//--automatically built--
//--Project: C:\Users\xbmc\Desktop\test.js

var app = new Avidemux();

//** Video **
// 01 videos source
app.load("C:/Users/xbmc/Desktop/Test-AC3.mkv");
//01 segments
app.clearSegments();
app.addSegment(0,0,4997);
app.markerA=0;
app.markerB=4996;

//** Postproc **
app.video.setPostProc(3,3,0);

app.video.fps1000 = 23976;

//** Filters **

//** Video Codec conf **
app.video.codec("Copy", "CQ=0", "0 ");

//** Audio **
app.audio.reset();
app.audio.codec("Lame",128,20,"80 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 00 00 00 00 ");
app.audio.normalizeMode=0;
app.audio.normalizeValue=0;
app.audio.delay=0;
app.audio.mixer="STEREO";
app.audio.scanVbr();
app.setContainer("MATROSKA");
setSuccess(1);
//app.Exit();

//End of script

Remove these:
Code: [Select]
app.load("C:/Users/xbmc/Desktop/Test-AC3.mkv");
Code: [Select]
app.addSegment(0,0,28832);
app.markerA=0;
app.markerB=28831;

Monkeyk

  • Newbie
  • *
  • Posts: 6
Re: Script mkv/ac3 to acc/mp4
« Reply #6 on: April 16, 2012, 08:12:52 AM »
Jan,

I made a script that works but when i play it the speed (frame rate) isnt correct.
Its playing really fast instead of the normal speed.
If i delete the segment part and leave the "app.clearSegments();" it doesnt do anything.
so i deleted that part and it will convert but with the speed problem

The strange thing is if i set all the audio options in avidemux and save the project as a JS file nothing of the audio filters i set is there...

Code: [Select]
//AD  <- Needed to identify//
//--automatically built--
//--Project: C:\Users\xbmc\Desktop\test.js

var app = new Avidemux();

//** Video **
// 01 videos source

//01 segments


//** Postproc **
app.video.setPostProc(3,3,0);
app.video.fps1000 = 23976;


//** Filters **
//** Video Codec conf **
app.video.codec("Copy", "CQ=0", "0 ");


//** Audio **
app.audio.reset();
app.audio.codec("Lame",128,20,"80 00 00 00 00 00 00 00 01 00 00 00 02 00 00 00 00 00 00 00 ");
app.audio.normalizeMode=0;
app.audio.normalizeValue=0;
app.audio.delay=0;
app.audio.mixer="STEREO";
app.audio.scanVbr();
app.setContainer("MATROSKA");
setSuccess(1);
//app.Exit();
//End of script
« Last Edit: April 16, 2012, 08:18:34 AM by Monkeyk »

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6051
Re: Script mkv/ac3 to acc/mp4
« Reply #7 on: April 16, 2012, 08:31:59 AM »
If i delete the segment part and leave the "app.clearSegments();" it doesnt do anything.
so i deleted that part and it will convert but with the speed problem
no the "app.clearSegments();" should stay there.

What version of avidemux are you running? 2.54, 2.55 or 2.5.6?
The source video's you use, different sources? Do these have have different frame rates? "app.video.fps1000 = 23976"; could be causing this to?  Don't know if removing this would help?

Monkeyk

  • Newbie
  • *
  • Posts: 6
Re: Script mkv/ac3 to acc/mp4
« Reply #8 on: April 16, 2012, 11:28:42 AM »
iam running 2.5.6 all files have different frame rates but the files iam testing with is the same as the one i made the js for!

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6051
Re: Script mkv/ac3 to acc/mp4
« Reply #9 on: April 17, 2012, 07:17:49 AM »
Try with 2.6 experimental, since yesterday it has the possibilities to re-encode the existing audiotrack from ac3 5.1 to stereo. Don't know yet if this works from script. See 1st if this works and produces the result you want in the GUI. If that works proceed with batch and save the job. It is somewhat different in operation but it should show itself.
This batch line:
Code: [Select]
set avidemux="C:\Program Files\Avidemux 2.5\avidemux2.exe"should be adapted to the new path where 2.6 is installed and the executable is "avidemux3.exe" or somewhat in that nature.
You can find 2.6 Beta Builds  http://avidemux.razorbyte.com.au/ or http://avidemux.org/nightly/
If running on 64-bit windows and you have problems running avidemux try with 32-bit version, some users reported this to solve some issues
« Last Edit: April 17, 2012, 08:35:00 AM by Jan Gruuthuse »

Monkeyk

  • Newbie
  • *
  • Posts: 6
Re: Script mkv/ac3 to acc/mp4
« Reply #10 on: April 17, 2012, 04:36:55 PM »
Hey Jan, the 2.6 works and saves the script like it should be.
The only problem iam having is the frame rate which isnt correct....

Iam beginning to think i want something what isnt realistic :(

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6051
Re: Script mkv/ac3 to acc/mp4
« Reply #11 on: April 17, 2012, 05:24:54 PM »
Can you try running mkvclean on a mkv before you process the file with avidemux?
http://www.matroska.org/downloads/mkclean.html
If that did not help, upload a 5 second clip (20MB max) somewhere and provide a link to it. Perhaps someone will have a look at it and tell what the problem could be?