Avidemux Forum

Avidemux => Unix-Like (Linux/Bsd/...) => Topic started by: I12learn on September 11, 2012, 09:16:44 AM

Title: [Solved] Batch conversion, avi 2 mp4
Post by: I12learn on September 11, 2012, 09:16:44 AM
Hello Forum,
I'm new here and I landed to this forum because I was trying several methods to convert my videos from avi to mp4, which also my TV would plays.
Maybe wouldn'd be long, may be I'll like to discuss this my new trend :D

The most reason, to choose mp4, is because makes smaller size and it plays fine on all DLNA connection, including Sony TV.
Till now I got to try with several bash tools such as mkmp4, MBox4tools, mencoder, neroenc, aacencplus, they fail and the sound is asyncronous and varying on volume. Also hard to set a smaller size. Then avidemux does it as I want it done.
Since I didn't know about batch scripting, I'm just runnin the GUI and wait when one convertion finish to start another  :-\  :-\. Some time goes late on the night  :P  :P. Then I found the scripting, but I'm facing a couple of problems:
Like it said here (http://www.avidemux.org/admWiki/doku.php?id=tutorial:batch_processing#js_scripting_ecmascript_only_batch_processing) it seems to me that I miss something to change for the first example on the page top or the something.js is not a linux script for the second chance and doesn't do for mp4 encoding.
I know some scripting in python or bash, but it's difficult to get EMACS and java scripts.



OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)
Title: Re: Batch conversion, avi 2 mp4
Post by: Jan Gruuthuse on September 11, 2012, 10:31:38 AM
something.js is a saved project. Make all required/needed settings in GUI.
Save project. Edit project: remove reference to loaded video and remove maker settings
and call that project from script.
See basic usage here: 2.6 audio track switching in job.py (http://www.avidemux.org/smf/index.php?topic=10499.0)
Title: Re: Batch conversion, avi 2 mp4
Post by: I12learn on September 11, 2012, 11:15:45 AM
As I wrote saving the job is crashing the app. Here's the report :
QuoteAssert failed :0
at line 386, file /build/src/avidemux_2.5.6/avidemux/ADM_encoder/adm_encConfig.cppADM_backTrack
videoCodecGetMode()
ADM_Composer::saveAsScript(char const*, char const*)
saveCrashProject()
ADM_backTrack
videoCodecGetMode()
ADM_Composer::saveAsScript(char const*, char const*)
A_saveWorkbench(char const*)
FileSel_ReadWrite(void (*)(char const*), int, char const*, char const*)
avidemux2_gtk() [0x52bf19]
HandleAction(Action)
guiCallback(_GtkMenuItem*, void*)
g_closure_invoke

g_signal_emit_valist
g_signal_emit
gtk_widget_activate
gtk_menu_shell_activate_item
Then I cannot get to the next step as you're suggesting.
This is what I get wrote, but is incomplete//AD  <- Needed to identify//
//--automatically built--
//--Project: /tmp/avid_prg

var app = new Avidemux();

//** Video **
// 01 videos source
app.load("/media/X&X&X/++++/*x*x*x.mp4");
//01 segments
app.clearSegments();
app.addSegment(0,0,148030);
app.markerA=0;
app.markerB=148029;

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

app.video.fps1000 = 23976;

//** Filters **
app.video.addFilter("mpresize","w=720","h=400","algo=0");

//** Video Codec conf **


The file was finish flawlessly, I was curious to know if was some problem around.


OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)
Title: Re: Batch conversion, avi 2 mp4
Post by: Jan Gruuthuse on September 11, 2012, 02:42:56 PM
Download attachment toAvcMp4.js and save it somewhere you find it back.
Load a small video in avidemux 2.5.6.  From main menu: Load/Run Project and select toAvcMp4.js
Did this work?
Title: Re: Batch conversion, avi 2 mp4
Post by: Jan Gruuthuse on September 11, 2012, 03:13:21 PM
the next step would be to have a script calling that project.
This script would search for all avi's in /Home/Videos and
#!/bin/bash
for FIL in `ls ~/Videos/*avi | sort` ; do
  /usr/bin/avidemux2_cli --force-alt-h264 --load "$FIL" --run ~/Videos/toAvcMp4.js --save ${FIL%.*}.mp4 --quit
done

you could exchange avidemux2_cli by avidemux2_gtk (for visual testing)
~/Videos/ would by the current users folder Videos in his/hers home folder where the videos are you want to process.
~/Videos/toAvcMp4.js if you use a different location for project, change accordingly.
Tested in Ubuntu 12.04 Terminal, could be small changes/convertion is needed for running in OS Archlinux.
Title: Re: Batch conversion, avi 2 mp4
Post by: I12learn on September 11, 2012, 05:16:09 PM
Quote from: Jan Gruuthuse on September 11, 2012, 02:42:56 PM
Download attachment toAvcMp4.js
Thank you so much. I've apreciated very much your help. Well, I still have to try it out.

I found a similar script on the here's windows forum, but there are some particulars that differ.

A small question, can the very long line broke down on several ones?
Bash, python and other scripting languages allow to brake the long line with/without a special placeholder.
A smaller question :), can I change AQ value for some either smaller or better results?
I just guest AQ is likely that one on mencoder settings :P


OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)
Title: Re: Batch conversion, avi 2 mp4
Post by: Jan Gruuthuse on September 11, 2012, 05:37:42 PM
Quote from: I12learn on September 11, 2012, 05:16:09 PM
A small question, can the very long line broke down on several ones?
I'm just a user, not a developer, programmer, script writer.
This one starting with: app.video.codecPlugin(... should be one line, I'm using gedit for these (ascii editor not word processor)
QuoteBash, python and other scripting languages allow to brake the long line with/without a special placeholder.
Not sure if this is possible, could be needed on one line as these are passed to encoder as parameter. Developers could perhaps enlighten us users on this one?
QuoteA smaller question :), can I change AQ value for some either smaller or better results?
I just guest AQ is likely that one on mencoder settings :P
AQ:  0 = High Quality, 51 = Low Quality. Looks like these are the minimum/maximum values for this setting in the filter.
Title: Re: Batch conversion, avi 2 mp4
Post by: I12learn on September 11, 2012, 06:29:14 PM
Quote from: Jan Gruuthuse on September 11, 2012, 05:37:42 PM
Quote from: I12learn on September 11, 2012, 05:16:09 PM
A small question, can the very long line broke down on several ones?
I'm just a user, not a developer, programmer, script writer.
Ok i spent some time and I can assure that we can. I enclosed my embellished version. That gives more readabilty on the xml data.
The rules are very same to the other scripting. That's mean we can use for separation any number of space or tab or newline, just to close the paired delimiter evenly.

Quote from: Jan Gruuthuse
AQ:  0 = High Quality, 51 = Low Quality. Looks like these are the minimum/maximum values for this setting in the filter.
Well mencoder values are floating point and starting from 0.1 to 50.0. Here I've to believe that you're right.
Low values means more accuracy, bigger file result, correct me if I'm wrong.

I also inform that I've tried the your setting. After loading the movie all gone well and I could add some of my liking, then I could save the project without crashes (including my own settings)
But I didn't see starting to save the conversion. I suppose that will go on the script.
...
/usr/bin/avidemux2_cli --force-alt-h264 --load "$FIL" --run ~/Videos/toAvcMp4.js --save ${FIL%.*}.mp4 --quit
...
EDIT
Finally I found the correct way to split long lines. It is like bash scripting or perhaps the readline library rule. The backslash "\" allows to move to the next line. There was the highlighting on gedit showing correctly that I was wrong, but I tought it was some strange behaviour of gedit. The attachment is the corrected one :P


OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)
Title: Re: Batch conversion, avi 2 mp4
Post by: Jan Gruuthuse on September 11, 2012, 06:48:08 PM
Yes, project loads only settings. When saving project, don't forget to remove references to current video loaded in avidemux_gtk. Bolded should be deleted.
Quote//** Video **
//** Video **
// 01 videos source
app.forceUnpack();
app.load("/media/DataSafe/Video/Wanderlust.avi");
//01 segments
app.clearSegments();
app.addSegment(0,0,140994);
app.markerA=0;
app.markerB=140993;
If problems remove app.forceUnpack(); to.
Title: Re: Batch conversion, avi 2 mp4
Post by: I12learn on September 11, 2012, 07:04:56 PM
Yeah
I found that stops the process.
I got another problem, but is not related to avidemux. Name with space   :-\ :-\


OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)
Title: Re: Batch conversion, avi 2 mp4
Post by: Jan Gruuthuse on September 11, 2012, 07:24:15 PM
Spaces in file and folder names are tricky. Same for foreign ascii: ß é ç ... Perhaps when enclosed in quotation marks?  ââ,¬Ëœ ââ,¬â,,¢ or ââ,¬Å" ââ,¬Â ?
Title: Re: Batch conversion, avi 2 mp4
Post by: I12learn on September 11, 2012, 07:41:28 PM
this will take to modify IFS before doing the script and restore it upon completion.
Well my polished version doesn't work  :'(. Maybe I confused to upload the project  during my test. I'm gonna check EMACS rules. I'd like to see is we can import the xml file and leave it somewhere else.
For unicode I haven't had into that. I'm rather aware to avoid these novelties that aren't so necessary. Perhaps I'll rename the files before and after :P
New problem
[Variable bit rate stream]. Now the GUI stops to ask me what to do. I miss the fully automation


OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)
Title: Re: Batch conversion, avi 2 mp4
Post by: Jan Gruuthuse on September 12, 2012, 06:14:36 AM
Do you have access to avidemux 2.6? If not can you build this yourself on archlinux? Think some issues do go away with this version.
Compiling Avidemux 2.6.x (http://www.avidemux.org/admWiki/doku.php?id=build:install_2.6)
Title: Re: Batch conversion, avi 2 mp4
Post by: I12learn on September 12, 2012, 08:05:46 AM
Archlinux has a very good felxibility. The package (https://aur.archlinux.org/packages.php?ID=54560) is ready. Also available the svn version :P
BTW, do you think there's some problem with my current version?
I'm asking because the option app.forceUnpack(); seems having no effects. Is the new version let me skip the dialog when uploading the avi with packed vbr?

Other interests are driving me to adopt the custom menu of avidemx_GUI. After I'd include the option to scan a directory and repeat the conversion, all from within GUI. (I've read some detail (http://www.avidemux.org/smf/index.php?board=10.0)). Supposed to widen the script with file/dir searching dialog box and the main loop all into the java script. But no time constrains (I should learn some more on java  ???  ???)


OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)
Title: Re: Batch conversion, avi 2 mp4
Post by: Jan Gruuthuse on September 12, 2012, 08:51:53 AM
My understanding is 2.6 should handle new videos / codecs / containers better. You should be able to run 2.6 alongside 2.5.6. Sometimes 2.6 isn't handling 2.5.6 stuff and reverse.
Projects are not interchangeable 2.5 <> 2.6. There is also a developer Avidemux 2.6 Scripting Reference in 2.6 main menu help. Should be great help as you have more experience with scripting then I have.
2.5.6 is called by avidemu2_**** , 2.6 by avidemu3_****
Title: Re: Batch conversion, avi 2 mp4
Post by: I12learn on September 13, 2012, 10:16:50 AM
Quote from: Jan Gruuthuse on September 12, 2012, 08:51:53 AMYou should be able to run 2.6 alongside 2.5.6.
I did the install. I got some confusion since the package is default to QT4. Not a big hassle, I could get it working without additional packages :P
Anyhow I resume to set for GTK and that's look fine.
Quote from: Jan GruuthuseProjects are not interchangeable 2.5 <> 2.6. There is also a developer Avidemux 2.6 Scripting Reference in 2.6 main menu help
Are you telling that scripting will differ for before?
I saw that we have 3 scripting type options. I'm more familiar with python, but those I looked at were not pythonic. I'd mistake, I think.

Remain for java script I got that one from this thread (http://www.avidemux.org/smf/index.php?topic=10292.0) which I'd like to modify for my tastes. But I didn't try it with avidemux3, yet. There are some othere and I rather opt to GUI decisions and operations than sending command from CLI. There would be also a script for the occasions which I'd like to have the processes out of X, to lighten the CPU load and let the job going overnight.



OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)
Title: Re: Batch conversion, avi 2 mp4
Post by: Jan Gruuthuse on September 13, 2012, 11:02:46 AM
Quote from: I12learn on September 13, 2012, 10:16:50 AM
I did the install. I got some confusion since the package is default to QT4. Not a big hassle, I could get it working without additional packages :P
Anyhow I resume to set for GTK and that's look fine.
Just keep in mind some stuff in GTK could be not available
QuoteAre you telling that scripting will differ for before?
I saw that we have 3 scripting type options. I'm more familiar with python, but those I looked at were not pythonic. I'd mistake, I think.
Not the scripting itself I think, but settings, labels and variables.
QuoteRemain for java script I got that one from this thread (http://www.avidemux.org/smf/index.php?topic=10292.0) which I'd like to modify for my tastes. But I didn't try it with avidemux3, yet. There are some othere and I rather opt to GUI decisions and operations than sending command from CLI. There would be also a script for the occasions which I'd like to have the processes out of X, to lighten the CPU load and let the job going overnight.

If you look in 2.6 QT Main Menu in Tools you can find the scripting tools. I don't see this in GTK.
If you run GUI there is an option --nogui: You can use ââ,¬â€œnogui option in case you want to suppress all dialogs (it must be first option!)
@ bottom page of : Batch processing (http://www.avidemux.org/admWiki/doku.php?id=tutorial:batch_processing)
Title: Re: Batch conversion, avi 2 mp4
Post by: I12learn on September 13, 2012, 07:16:11 PM
Quote from: Jan Gruuthuse on September 13, 2012, 11:02:46 AM
just keep in mind some stuff in GTK could be not available
::)  ::) I would say several  ::)  ::)
QuoteNot the scripting itself I think, but settings, labels and variables.
I think for GTK I'll need to wait some more.
QuoteIf you run GUI there is an option --nogui: You can use ââ,¬â€œnogui option in case you want to suppress it
I'm switching back to QT version. For the no_gui option it won't mean that will proceed for any missing given choice. Will it?
Maybe need a no-confirm option.
I propose to close this thread. Since it has fulfilled the need to know how to set up scripting.



OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)