Avidemux Forum

Avidemux => Main version 2.6 => Topic started by: Vendeur on June 06, 2016, 04:04:29 PM

Title: How to convert all files in a folder?
Post by: Vendeur on June 06, 2016, 04:04:29 PM
Hi,

I would like to convert about 250 video files (all episodes of TV Friends). At this moment I have to open every file, make changes and queue. After all I run jobs. But it takes a lot of time to open and queue each file.

Is there any option to apply changes to all folder or a big number of files?
Title: Re: How to convert all files in a folder?
Post by: mean on June 06, 2016, 04:22:30 PM
you can use a tinypy script, there is a topic about that somewhere

Title: Re: How to convert all files in a folder?
Post by: Jan Gruuthuse on June 06, 2016, 05:09:21 PM
Some info can be found here: Simple Command line usage with Tinpy Project (http://avidemux.org/smif/index.php/topic,16808.0.html), don't post in that posting, thank you!
If you have further questions, continue in this thread.
Title: Re: How to convert all files in a folder?
Post by: Vendeur on June 06, 2016, 06:20:53 PM
Thank you Jan!

So I need to edit Project saved before. I can do it. But what should I add in to this project to make Avidemux open file, and after converting, save it and open the second, third etc.. ?
Title: Re: How to convert all files in a folder?
Post by: Jan Gruuthuse on June 07, 2016, 06:35:37 AM
you don't add into project.
you use batch file (http://avidemux.org/smif/index.php/topic,16808.msg75023.html#msg75023) in Windows or bourne shell in Linux
Title: Re: How to convert all files in a folder?
Post by: Vendeur on June 07, 2016, 11:20:40 PM
Ok, I'm not good in this, will make in my style I think, file after file :/

BTW, how stupid is this, that such a good soft with so many possibilitys have no few so simples commands... Can not understand that.
Title: Re: How to convert all files in a folder?
Post by: mean on June 08, 2016, 04:17:24 AM
Sample tinypy script, that will load all file in c:\tmp with .mp4 extension
in the convert function, put what you do usually and end it by
adm.save(filein+".converted")

# Loas all mp4 files in intputFolder ending with extention mp4
# ...
#
ext="mp4"
inputFolder="c:\\tmp\\"
#
def convert(filein):   
    if(0 == adm.loadVideo(filein)):
        ui.displayError("oops","cannot load "+filein)
        raise
    print("Done")
   
#
# Main
#
ui=Gui()
adm=Avidemux()
#
list=get_folder_content(inputFolder,ext)
if(list is None):
    raise
for i in list:
        convert(i)
print("Done")

Title: Re: How to convert all files in a folder?
Post by: mean on June 08, 2016, 06:05:48 AM
I'm slowly updating the wiki
First entry : http://avidemux.org/admWiki/doku.php?id=tinypy:examples
Title: Re: How to convert all files in a folder?
Post by: EEMcGee on June 09, 2016, 08:57:43 PM
Thank you for the work on updating the Wiki.  Would it be difficult to add a batch processing menu item into Avidemux where it would just ask for the folder and type of files,  output folder, and which project file you want to use for all of them?  This kind of functionality could be a huge time saver for users.  I currently do it through batch files I made with Windows and it works well.  I do batch indexing of TS files and Processing Mpeg2 AVI files into MP4 with custom settings.
Title: Re: How to convert all files in a folder?
Post by: Jan Gruuthuse on June 10, 2016, 06:05:00 AM
you could of course use different workfolders to process your videos and have a fluent workflow process.
Separate folder for
avi to mp4 conversion
indexing ts
please also check this: Custom Menu and Saved projects (http://avidemux.org/smif/index.php/topic,10948.0.html)
Title: Re: How to convert all files in a folder?
Post by: EEMcGee on June 10, 2016, 07:14:57 AM
I just throw the PY and batch file into the directory I want to process then run the .bat file and walk away.  After all the files have been converted, I come back, select all of the original video files and delete them.  I don't know much about linux as to same functionality as batch files.  For those who don't know much about using .bat files in Windows I thought adding that functionality inside of avidemux might be a great option.

Here is a link to the thread with some batch files in it for converting folders in windows with a .bat file if you want to try that.  It's down toward the end of the thread.
http://avidemux.org/smif/index.php/topic,16769.msg74856.html#msg74856
Title: Re: How to convert all files in a folder?
Post by: mean on June 20, 2016, 06:16:54 AM
Some more documentation update
http://avidemux.org/admWiki/doku.php?id=tinypy:examples
http://avidemux.org/admWiki/doku.php?id=tinypy:tinypybatch2
Title: Re: How to convert all files in a folder?
Post by: mean on June 20, 2016, 04:06:50 PM
This is pretty good
https://www.youtube.com/watch?v=pxMeIU-ghXY
Title: Re: How to convert all files in a folder?
Post by: Vendeur on June 20, 2016, 07:58:57 PM
That video is just great, thank's for sharing it!
Title: Re: How to convert all files in a folder?
Post by: Vendeur on June 20, 2016, 10:56:53 PM
I made a project, but it doesn't working. What am I doing wrong?


#
# Load all the files with .mkv extension in a selected directory, convert with x265 video codec at 2000cbr, aac 128kb audio codec + noise reduction

#
gui = Gui()
adm = Avidemux()
ext = "mkv"
#
def convert(filein):   

    if(0 == adm.loadVideo(filein)):
        ui.displayError("oops","cannot load "+filein)
        raise
   adm.videoCodec("x265", "useAdvancedConfiguration=True", "general.params=CBR=2000", "general.poolThreads=0", "general.frameThreads=0", "general.preset=ultrafast", "general.tuning=psnr", "general.profile=main", "level=-1", "vui.sar_height=1"
, "vui.sar_width=1", "MaxRefFrames=3", "MinIdr=25", "MaxIdr=250", "i_scenecut_threshold=40", "MaxBFrame=3", "i_bframe_adaptive=1", "i_bframe_bias=0", "i_bframe_pyramid=2", "b_deblocking_filter=True", "interlaced_mode=0"
, "constrained_intra=False", "lookahead=40", "weighted_pred=2", "weighted_bipred=True", "cb_chroma_offset=0", "cr_chroma_offset=0", "me_method=3", "me_range=16", "subpel_refine=5", "trellis=1", "psy_rd=1.000000"
, "fast_pskip=True", "dct_decimate=True", "noise_reduction=0", "noise_reduction_intra=0", "noise_reduction_inter=0", "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "ratecontrol.qp_step=4", "ratecontrol.bitrate=0"
, "ratecontrol.rate_tolerance=1.000000", "ratecontrol.vbv_max_bitrate=0", "ratecontrol.vbv_buffer_size=0", "ratecontrol.vbv_buffer_init=0", "ratecontrol.ip_factor=1.400000", "ratecontrol.pb_factor=1.300000"
, "ratecontrol.aq_mode=2", "ratecontrol.aq_strength=1.000000", "ratecontrol.cu_tree=True", "ratecontrol.strict_cbr=False")

adm.addVideoFilter("fluxsmooth", "temporal_threshold=7", "spatial_threshold=7")
adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"unknown")
adm.audioAddTrack(0)
adm.audioCodec(0, "Faac", "bitrate=128");
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0,0)
adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280")
adm.save(filein + ".converted.mkv") # save the file
    print("Done")
 
#
# Main
#

inputFolder = gui.dirSelect("Select folder")
#
list=get_folder_content(inputFolder,ext)
if(list is None):
    raise
for i in list:
        convert(i)
print("Done")



(https://avidemux.org/smif/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FhDOtjPC.jpg&hash=3814a668eec6d6c5d046f8fd4989bd7cfc6e73b9)

Please help me.
Title: Re: How to convert all files in a folder?
Post by: mean on June 21, 2016, 04:49:02 AM
* indentation is wrong
* you forgot the \  at the end of the split lines

That seems to work


#
# Load all the files with .mkv extension in a selected directory, convert with x265 video codec at 2000cbr, aac 128kb audio codec + noise reduction

#
gui = Gui()
adm = Avidemux()
ext = "mkv"
#
def convert(filein):   

    if(0 == adm.loadVideo(filein)):
        ui.displayError("oops","cannot load "+filein)
        raise
    adm.videoCodec("x265", "useAdvancedConfiguration=True", "general.params=CBR=2000", "general.poolThreads=0", "general.frameThreads=0", "general.preset=ultrafast", "general.tuning=psnr", "general.profile=main", "level=-1", "vui.sar_height=1"\
, "vui.sar_width=1", "MaxRefFrames=3", "MinIdr=25", "MaxIdr=250", "i_scenecut_threshold=40", "MaxBFrame=3", "i_bframe_adaptive=1", "i_bframe_bias=0", "i_bframe_pyramid=2", "b_deblocking_filter=True", "interlaced_mode=0"\
, "constrained_intra=False", "lookahead=40", "weighted_pred=2", "weighted_bipred=True", "cb_chroma_offset=0", "cr_chroma_offset=0", "me_method=3", "me_range=16", "subpel_refine=5", "trellis=1", "psy_rd=1.000000"\
, "fast_pskip=True", "dct_decimate=True", "noise_reduction=0", "noise_reduction_intra=0", "noise_reduction_inter=0", "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "ratecontrol.qp_step=4", "ratecontrol.bitrate=0"\
, "ratecontrol.rate_tolerance=1.000000", "ratecontrol.vbv_max_bitrate=0", "ratecontrol.vbv_buffer_size=0", "ratecontrol.vbv_buffer_init=0", "ratecontrol.ip_factor=1.400000", "ratecontrol.pb_factor=1.300000"\
, "ratecontrol.aq_mode=2", "ratecontrol.aq_strength=1.000000", "ratecontrol.cu_tree=True", "ratecontrol.strict_cbr=False")
    adm.addVideoFilter("fluxsmooth", "temporal_threshold=7", "spatial_threshold=7")
    adm.audioClearTracks()
    adm.setSourceTrackLanguage(0,"unknown")
    adm.audioAddTrack(0)
    adm.audioCodec(0, "Faac", "bitrate=128");
    adm.audioSetDrc(0, 0)
    adm.audioSetShift(0, 0,0)
    adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280")
    adm.save(filein + ".converted.mkv") # save the file
    print("Done")
 
#
# Main
#

inputFolder = gui.dirSelect("Select folder")
#
list=get_folder_content(inputFolder,ext)
if(list is None):
    raise
for i in list:
        convert(i)
print("Done")

Title: Re: How to convert all files in a folder?
Post by: RoadRanger on June 22, 2016, 02:55:21 AM
I do this with just Ffmpeg, let me know what exactly you need to do and I'll try to adapt one - here's a sample batch file that creates small MP4 files from FLV files that already have a usable audio stream:

for /R %%f in (*.flv) do call :flv2mp4 "%%f"
goto :eof

:flv2mp4
start "FLV2MP4" /belownormal /min /wait C:/ffmpeg -i %1 -c:v libx264 -crf 30 -c:a copy -movflags +faststart %1.mp4
exit /b
Title: Re: How to convert all files in a folder?
Post by: Vendeur on June 22, 2016, 11:26:35 AM
Thank you mean, all is working now well!

I hope one day that simple option will be available just in menu.
Title: Re: How to convert all files in a folder?
Post by: Vendeur on May 11, 2021, 10:19:21 PM
Hello, again...

I'm trying to do same thing, as 5 years ago, just a little different. I saved new bath from new project, and inserted this bath code to the old one. But after starting it I'm getting error:

(https://i.imgur.com/eEyXaAa.jpg)


#
# Load all the files with .mp4 extension in a selected directory, convert with x264 video codec at 2000cbr, aac 128kb audio codec

#
gui = Gui()
adm = Avidemux()
ext = "mkv"
#
def convert(filein): 

    if(0 == adm.loadVideo(filein)):
        ui.displayError("oops","cannot load "+filein)
        raise
    aadm.videoCodec("x264", "useAdvancedConfiguration=True", "general.params=CBR=2000", "general.threads=0", "general.preset=ultrafast", "general.tuning=none", "general.profile=baseline", "general.fast_decode=False", "general.zero_latency=False"
, "general.fast_first_pass=True", "general.blueray_compatibility=False", "general.fake_interlaced=False", "level=-1", "vui.sar_height=1", "vui.sar_width=1", "MaxRefFrames=3", "MinIdr=25", "MaxIdr=250"
, "i_scenecut_threshold=40", "intra_refresh=False", "MaxBFrame=3", "i_bframe_adaptive=1", "i_bframe_bias=0", "i_bframe_pyramid=2", "b_deblocking_filter=True", "i_deblocking_filter_alphac0=0", "i_deblocking_filter_beta=0"
, "cabac=True", "interlaced=False", "constrained_intra=False", "tff=True", "fake_interlaced=False", "analyze.b_8x8=True", "analyze.b_i4x4=True", "analyze.b_i8x8=True", "analyze.b_p8x8=True", "analyze.b_p16x16=False"
, "analyze.b_b16x16=False", "analyze.weighted_pred=2", "analyze.weighted_bipred=True", "analyze.direct_mv_pred=1", "analyze.chroma_offset=0", "analyze.me_method=1", "analyze.me_range=16", "analyze.mv_range=-1"
, "analyze.mv_range_thread=-1", "analyze.subpel_refine=7", "analyze.chroma_me=True", "analyze.mixed_references=True", "analyze.trellis=1", "analyze.psy_rd=1.000000", "analyze.psy_trellis=0.000000", "analyze.fast_pskip=True"
, "analyze.dct_decimate=True", "analyze.noise_reduction=0", "analyze.psy=True", "analyze.intra_luma=11", "analyze.inter_luma=21", "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "ratecontrol.qp_min=10"
, "ratecontrol.qp_max=51", "ratecontrol.qp_step=4", "ratecontrol.bitrate=0", "ratecontrol.rate_tolerance=1.000000", "ratecontrol.vbv_max_bitrate=0", "ratecontrol.vbv_buffer_size=0", "ratecontrol.vbv_buffer_init=1"
, "ratecontrol.ip_factor=1.400000", "ratecontrol.pb_factor=1.300000", "ratecontrol.aq_mode=1", "ratecontrol.aq_strength=1.000000", "ratecontrol.mb_tree=True", "ratecontrol.lookahead=40")
adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"und")
adm.audioAddTrack(0)
adm.audioCodec(0, "LavAAC", "bitrate=128");
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0, 0)
adm.setContainer("MP4", "muxerType=0", "optimize=1", "forceAspectRatio=False", "aspectRatio=1", "rotation=0", "clockfreq=0")

    adm.save(filein + ".converted.mp4") # save the file
    print("Done")
 
#
# Main
#

inputFolder = gui.dirSelect("Select folder")
#
list=get_folder_content(inputFolder,ext)
if(list is None):
    raise
for i in list:
        convert(i)
print("Done")
Title: Re: How to convert all files in a folder?
Post by: butterw on May 11, 2021, 11:12:19 PM
Quote from: mean on June 21, 2016, 04:49:02 AM* indentation is wrong
Title: Re: How to convert all files in a folder?
Post by: Vendeur on May 12, 2021, 09:39:50 AM
What do you mean?
Title: Re: How to convert all files in a folder?
Post by: butterw on May 12, 2021, 10:13:27 AM
indentation is an element of syntax in python.

The content of the convert function needs to be indented with the same level of indentation throughout (and you can't mix tabs and spaces).

Select the bloc of text to indent + press tab in your text editor.
Title: Re: How to convert all files in a folder?
Post by: butterw on May 12, 2021, 10:40:27 AM
Quote from: Vendeur on June 22, 2016, 11:26:35 AMI hope one day that simple option will be available just in menu.

Batch processing could either be achieved with a project menu function that auto-generates a batch script based on the current settings.
or it could be an integrated job-list type feature (would make it simpler to cancel a started job).

scripts can be added to the custom menu in the Gui.
Title: Re: How to convert all files in a folder?
Post by: Vendeur on May 12, 2021, 07:25:13 PM
Quote from: butterw on May 12, 2021, 10:40:27 AM
Quote from: Vendeur on June 22, 2016, 11:26:35 AMI hope one day that simple option will be available just in menu.

Batch processing could either be achieved with a project menu function that auto-generates a batch script based on the current settings.
or it could be an integrated job-list type feature (would make it simpler to cancel a started job).

scripts can be added to the custom menu in the Gui.

Yeah, this is so stupid, that such a good software have not so simple feture to convert all files in the a folder... After so many years...

I still can't run .py file. Even tried the old one (above in the topic) and do not work.
I reworked on my new one (below) and still got some error:

(https://i.imgur.com/02woBGd.jpg)

#
# Load all the files with .mp4 extension in a selected directory, convert with x264 video codec at 2000cbr, aac 128kb audio codec

#
gui = Gui()
adm = Avidemux()
ext = "mkv"
#
def convert(filein):   

    if(0 == adm.loadVideo(filein)):
        ui.displayError("oops","cannot load "+filein)
        raise
    adm.videoCodec("x264", "useAdvancedConfiguration=True", "general.params=CBR=2000", "general.threads=0", "general.preset=ultrafast", "general.tuning=none", "general.profile=baseline", "general.fast_decode=False"\
, "general.zero_latency=False"
, "general.fast_first_pass=True", "general.blueray_compatibility=False", "general.fake_interlaced=False", "level=-1", "vui.sar_height=1", "vui.sar_width=1", "MaxRefFrames=3", "MinIdr=25", "MaxIdr=250"
\
, "i_scenecut_threshold=40", "intra_refresh=False", "MaxBFrame=3", "i_bframe_adaptive=1", "i_bframe_bias=0", "i_bframe_pyramid=2", "b_deblocking_filter=True", "i_deblocking_filter_alphac0=0", "i_deblocking_filter_beta=0"
, "cabac=True"\
, "interlaced=False", "constrained_intra=False", "tff=True", "fake_interlaced=False", "analyze.b_8x8=True", "analyze.b_i4x4=True", "analyze.b_i8x8=True", "analyze.b_p8x8=True", "analyze.b_p16x16=False"
, "analyze.b_b16x16=False"\
, "analyze.weighted_pred=2", "analyze.weighted_bipred=True", "analyze.direct_mv_pred=1", "analyze.chroma_offset=0", "analyze.me_method=1", "analyze.me_range=16", "analyze.mv_range=-1"
, "analyze.mv_range_thread=-1"\
, "analyze.subpel_refine=7", "analyze.chroma_me=True", "analyze.mixed_references=True", "analyze.trellis=1", "analyze.psy_rd=1.000000", "analyze.psy_trellis=0.000000", "analyze.fast_pskip=True"
, "analyze.dct_decimate=True"\
, "analyze.noise_reduction=0", "analyze.psy=True", "analyze.intra_luma=11", "analyze.inter_luma=21", "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "ratecontrol.qp_min=10"
, "ratecontrol.qp_max=51", "ratecontrol.qp_step=4"\
, "ratecontrol.bitrate=0", "ratecontrol.rate_tolerance=1.000000", "ratecontrol.vbv_max_bitrate=0", "ratecontrol.vbv_buffer_size=0", "ratecontrol.vbv_buffer_init=1"
, "ratecontrol.ip_factor=1.400000", "ratecontrol.pb_factor=1.300000"\
, "ratecontrol.aq_mode=1", "ratecontrol.aq_strength=1.000000", "ratecontrol.mb_tree=True", "ratecontrol.lookahead=40")

    adm.audioClearTracks()

    adm.setSourceTrackLanguage(0,"und")

    adm.audioAddTrack(0)

    adm.audioCodec(0,);

    adm.audioSetDrc(0, 0)

    adm.audioSetShift(0, 0, 0)
    adm.setContainer("MP4", "muxerType=0", "optimize=1", "forceAspectRatio=False", "aspectRatio=1", "rotation=0", "clockfreq=0")

    adm.save(filein + ".converted.mp4") # save the file
    print("Done")
 
#
# Main
#

inputFolder = gui.dirSelect("Select folder")
#
list=get_folder_content(inputFolder,ext)
if(list is None):
    raise
for i in list:
        convert(i)
print("Done")
Title: Re: How to convert all files in a folder?
Post by: eumagga0x2a on May 12, 2021, 07:59:59 PM
The exception is raised because the list, returned by get_folder_content is empty.
Title: Re: How to convert all files in a folder?
Post by: butterw on May 12, 2021, 08:06:10 PM
No mkv file in folder >> raise

raise("No file in folder !") in your script would be more helpful as it would provide a meaningful error message.

There are other errors in your script however:
adm.audioCodec(0, "FDK_AAC", "bitrate=128", "afterburner=True", "profile=2", "sbr=False")

ui.displayError should be gui.displayError
Title: Re: How to convert all files in a folder?
Post by: eumagga0x2a on May 12, 2021, 08:13:00 PM
Quote from: butterw on May 12, 2021, 08:06:10 PMraise("No file in folder !") in your script would be more helpful.

Or just avoiding raise alltogether, at least in the Main part:

inputFolder = gui.dirSelect("Select folder")
if inputFolder is None:
    return
list = get_folder_content(inputFolder, ext)
if list is None:
    gui.displayError("Error", "Folder \"" + inputFolder + "\" contains no files with ending \"" + ext + "\"")
    return
for i in list:
    convert(i)
gui.displayInfo("Info","Operation completed")

I posted more sophisticated scripts on different occasions, e.g. in https://avidemux.org/smif/index.php/topic,19507.0.html
Title: Re: How to convert all files in a folder?
Post by: Vendeur on May 12, 2021, 09:17:03 PM
Oh my god, I'm stupid... Forgot to change ext to mp4...

Final script seems working and looks like this:

THANK YOU for your help! :)

#
# Load all the files with .mp4 extension in a selected directory, convert with x264 video codec at 2000cbr, audio copy and set to polish.

#
gui = Gui()
adm = Avidemux()
ext = "mp4"
#
def convert(filein):   

    if(0 == adm.loadVideo(filein)):
        gui.displayError("oops","cannot load "+filein)
        raise
    adm.videoCodec("x264", "useAdvancedConfiguration=True", "general.params=CBR=2000", "general.threads=0", "general.preset=ultrafast", "general.tuning=none", "general.profile=baseline", "general.fast_decode=False"\
, "general.zero_latency=False"
, "general.fast_first_pass=True", "general.blueray_compatibility=False", "general.fake_interlaced=False", "level=-1", "vui.sar_height=1", "vui.sar_width=1", "MaxRefFrames=3", "MinIdr=25", "MaxIdr=250"
\
, "i_scenecut_threshold=40", "intra_refresh=False", "MaxBFrame=3", "i_bframe_adaptive=1", "i_bframe_bias=0", "i_bframe_pyramid=2", "b_deblocking_filter=True", "i_deblocking_filter_alphac0=0", "i_deblocking_filter_beta=0"
, "cabac=True"\
, "interlaced=False", "constrained_intra=False", "tff=True", "fake_interlaced=False", "analyze.b_8x8=True", "analyze.b_i4x4=True", "analyze.b_i8x8=True", "analyze.b_p8x8=True", "analyze.b_p16x16=False"
, "analyze.b_b16x16=False"\
, "analyze.weighted_pred=2", "analyze.weighted_bipred=True", "analyze.direct_mv_pred=1", "analyze.chroma_offset=0", "analyze.me_method=1", "analyze.me_range=16", "analyze.mv_range=-1"
, "analyze.mv_range_thread=-1"\
, "analyze.subpel_refine=7", "analyze.chroma_me=True", "analyze.mixed_references=True", "analyze.trellis=1", "analyze.psy_rd=1.000000", "analyze.psy_trellis=0.000000", "analyze.fast_pskip=True"
, "analyze.dct_decimate=True"\
, "analyze.noise_reduction=0", "analyze.psy=True", "analyze.intra_luma=11", "analyze.inter_luma=21", "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "ratecontrol.qp_min=10"
, "ratecontrol.qp_max=51", "ratecontrol.qp_step=4"\
, "ratecontrol.bitrate=0", "ratecontrol.rate_tolerance=1.000000", "ratecontrol.vbv_max_bitrate=0", "ratecontrol.vbv_buffer_size=0", "ratecontrol.vbv_buffer_init=1"
, "ratecontrol.ip_factor=1.400000", "ratecontrol.pb_factor=1.300000"\
, "ratecontrol.aq_mode=1", "ratecontrol.aq_strength=1.000000", "ratecontrol.mb_tree=True", "ratecontrol.lookahead=40")

    adm.audioClearTracks()

    adm.setSourceTrackLanguage(0,"pol")

    adm.audioAddTrack(0)

    adm.audioCodec(0, "copy")
    adm.audioSetDrc(0, 0)

    adm.audioSetShift(0, 0, 0)
    adm.setContainer("MP4", "muxerType=0", "optimize=1", "forceAspectRatio=False", "aspectRatio=1", "rotation=0", "clockfreq=0")

    adm.save(filein + ".converted.mp4") # save the file
    print("Done")
 
#
# Main
#

inputFolder = gui.dirSelect("Select folder")
if inputFolder is None:
    return
list = get_folder_content(inputFolder, ext)
if list is None:
    gui.displayError("Error", "Folder \"" + inputFolder + "\" contains no files with ending \"" + ext + "\"")
    return
for i in list:
    convert(i)
gui.displayInfo("Info","Operation completed")