Avidemux Forum

Participate => Documentation & Tips => Topic started by: mean on March 09, 2014, 07:24:33 AM

Title: Sample script : Convert a whole folder
Post by: mean on March 09, 2014, 07:24:33 AM
The attached script will prompt for a folder and re-encode all the mkv file in it
Additionnaly, it will deinterlace the video and encode it to h264

I use it to store some  DVDs of a sitcom i'm watching

The process is makemkv to extract the episods as-is + this script
Title: Re: Sample script : Convert a whole folder
Post by: I12learn on March 10, 2014, 12:27:08 AM
Sorry Mean,
the better reading, for that small  program, is to exceed not 80 columns width.
Also I don't get why not to put the encoding in a variable. Would be better if can be imported, too  8)
Title: Re: Sample script : Convert a whole folder
Post by: Jan Gruuthuse on March 10, 2014, 06:49:23 AM
As this is not a program but a script containing instructions, you can have issues with 80 columns width. If reading this script is an issue. You best you use a combined text and source code editor.
- Windows: notepad++ (http://notepad-plus-plus.org/)
- OS x: TextWrangler (http://www.barebones.com/products/textwrangler/download.html)
- Linux: Gedit
or similar program.

If issue while executing the script: command line instructions have to be in one line, nothing much could be done about this. (in my user experience)
Title: Re: Sample script : Convert a whole folder
Post by: I12learn on March 12, 2014, 12:34:02 PM
Editors like kate and gedit can cope for a width of 32768 characters, but i fairly hard to read.
Title: Re: Sample script : Convert a whole folder
Post by: Jan Gruuthuse on March 21, 2014, 03:04:22 PM
the point was these can show formated output instead of txt only
Title: Re: Sample script : Convert a whole folder
Post by: TheTooleMan on May 20, 2022, 03:03:09 PM
I am looking for a script to perform exactly the function described in the initial post. Apparently the attached script is no more. Any pointers to it or a more current version would be greatly appreciated.  8)
Title: Re: Sample script : Convert a whole folder
Post by: eumagga0x2a on May 20, 2022, 06:32:57 PM
You could start at https://avidemux.org/smif/index.php/topic,19456.msg91175.html#msg91175

To add Yadif filter outputting deinterlaced picture for each field, add

adm.addVideoFilter("yadif", "mode=1", "parity=0", "deint=0")
at the appropriate location (after adm.videoCodec()), paying attention to indentation (Python uses indentation for code nesting).

If you export to MP4, please note that the list of parameters has been extended in current nightlies:

adm.setContainer("MP4", "muxerType=0", "optimize=0", "forceAspectRatio=False", "aspectRatio=1", "displayWidth=1280", "rotation=0", "clockfreq=0")
(displayWidth added). "optimize=0" disables time-consuming rewrite of the entire output file at the cost of making it not fit for streaming.
Title: Re: Sample script : Convert a whole folder
Post by: TheTooleMan on June 25, 2022, 05:17:10 PM
Thanks for the pointer to your script! I will use it as the basis for my own with some additional settings for the video codec.

I still have a question, though. In the "convert" procedure, there isn't any code which sets markerA and markerB, and the ClearSegment and AddSegment statements are missing. Are segments and markers required for Avidemux to properly encode video? Every time I save a project, markers and segments are created.
Title: Re: Sample script : Convert a whole folder
Post by: eumagga0x2a on June 25, 2022, 06:45:59 PM
If the default segment layout fits the task (a single segment spanning the video file from the first keyframe to the end and the selection which extends from zero to the end of video), these statements can be skipped. Please note that the part with the default segment layout starting at the first keyframe PTS rather than at the zero time is relatively new.

Quote from: TheTooleMan on June 25, 2022, 05:17:10 PMEvery time I save a project, markers and segments are created.

Yes, this is fine this way, avoids ambiguity.
Title: Re: Sample script : Convert a whole folder
Post by: mosiclover on November 02, 2022, 02:55:21 PM
I cannot find your attachment?
Quote from: mean on March 09, 2014, 07:24:33 AMThe attached script will prompt for a folder and re-encode all the mkv file in it
Additionnaly, it will deinterlace the video and encode it to h264

I use it to store some  DVDs of a sitcom i'm watching

The process is makemkv to extract the episods as-is + this script