Advertisement
Guest User

4ffmpeg-8.178

a guest
Oct 12th, 2015
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 170.46 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. '''
  5. work in python2.7/3
  6. os: gnu/linux only
  7. need:
  8. python, gtk3 (3.14|3.16), cairo, pango, libvte (2.90|2.91)
  9. --------------------------------
  10. packages in debian could be:
  11. libgtk-3-0
  12. python-gi
  13. python-gi-cairo
  14. python-gobject
  15. gir1.2-pango-1.0
  16. libvte9
  17. libvte-2.90-9 | libvte-2.91-0
  18. gir1.2-vte-2.90 | gir1.2-vte-2.91
  19. ---------------------------------
  20. for ffmpeg:
  21. ffmpeg ffplay ffprobe >= 2.8
  22. build with libfaac, libaacplus, libfdk-aac,
  23. libmp3lame, postproc, avfilter, libx264, libx265 multilib (8-10bit)
  24. '''
  25. import gi
  26. try:
  27.         gi.require_version('Vte', '2.90')
  28. except:
  29.         pass
  30. from gi.repository import Gtk, GObject, Vte, GLib, Pango
  31. import os, sys, subprocess, threading, time, re
  32. from subprocess import call
  33. from math import pow
  34.                
  35. class reuse_init(object):
  36.  
  37.  
  38.         def make_label(self, text):
  39.                 label = Gtk.Label(text)
  40.                 label.set_use_underline(True)
  41.                 label.set_alignment(1.0, 0.5)
  42.                 label.show()
  43.                 return label
  44.  
  45.         def make_slider_and_spinner(self, init, min, max, step, page, digits):
  46.                 controls = {'adj':Gtk.Adjustment(init, min, max, step, page), 'slider':Gtk.HScale(), 'spinner':Gtk.SpinButton()}
  47.                 controls['slider'].set_adjustment(controls['adj'])
  48.                 controls['slider'].set_draw_value(False)
  49.                 controls['spinner'].set_adjustment(controls['adj'])
  50.                 controls['spinner'].set_digits(digits)
  51.                 controls['slider'].show()
  52.                 controls['spinner'].show()
  53.                 return controls
  54.        
  55.         def make_frame_ag(self, f_shadow_type, f_label, alig_pad, gri_row_sp, gri_colu_sp, gri_homog):
  56.                 controls =  {'frame':Gtk.Frame(), 'ali':Gtk.Alignment(), 'grid':Gtk.Grid()}
  57.                 controls['frame'].set_shadow_type(f_shadow_type) # 3 GTK_SHADOW_ETCHED_IN , 1 GTK_SHADOW_IN
  58.                 controls['frame'].set_label(f_label)
  59.                 controls['ali'].set_padding(alig_pad, alig_pad, alig_pad, alig_pad)
  60.                 controls['frame'].add(controls['ali'])
  61.                 controls['grid'].set_row_spacing(gri_row_sp)
  62.                 controls['grid'].set_column_spacing(gri_colu_sp)
  63.                 controls['grid'].set_column_homogeneous(gri_homog) # True
  64.                 controls['ali'].add(controls['grid'])
  65.                 controls['frame'].show()
  66.                 controls['ali'].show()
  67.                 controls['grid'].show()
  68.                 return controls
  69.        
  70.         def make_spinbut(self, init, min, max, step, page, digits, numeric):
  71.                 controls = {'adj':Gtk.Adjustment(init, min, max, step, page), 'spinner':Gtk.SpinButton()}
  72.                 controls['spinner'].set_adjustment(controls['adj'])
  73.                 controls['spinner'].set_digits(digits)
  74.                 controls['spinner'].set_numeric(numeric)
  75.                 controls['spinner'].show()
  76.                 return controls
  77.        
  78.         def make_combobox(self, *vals):
  79.                 controls = {'list':Gtk.ListStore(str), 'cbox':Gtk.ComboBox(), 'cellr':Gtk.CellRendererText()}
  80.                 for i, v in enumerate(vals):
  81.                         controls['list'].append([v])
  82.                 controls['cbox'].set_model(controls['list'])      
  83.                 controls['cbox'].pack_start(controls['cellr'], True)
  84.                 controls['cbox'].add_attribute(controls['cellr'], "text", 0)
  85.                 controls['cbox'].set_active(0)
  86.                 controls['cbox'].show()
  87.                 return controls
  88.        
  89.         def make_combobox_list(self, list):
  90.                 controls = {'list':Gtk.ListStore(str), 'cbox':Gtk.ComboBox(), 'cellr':Gtk.CellRendererText()}
  91.                 for i, v in enumerate(list):
  92.                         controls['list'].append([v])
  93.                 controls['cbox'].set_model(controls['list'])      
  94.                 controls['cbox'].pack_start(controls['cellr'], True)
  95.                 controls['cbox'].add_attribute(controls['cellr'], "text", 0)
  96.                 controls['cbox'].set_active(0)
  97.                 controls['cbox'].show()
  98.                 return controls
  99.        
  100.         def make_comboboxtext(self, list):
  101.                 comboboxtext = Gtk.ComboBoxText()
  102.                 for i, v in enumerate(list):
  103.                         comboboxtext.append_text(v)
  104.                 comboboxtext.set_active(0)
  105.                 return comboboxtext
  106.        
  107.  
  108. class my_utility():
  109.        
  110.         def hms2sec(self, hms):
  111.                 result = 0
  112.                 listin = hms.split(':')
  113.                 listin.reverse()
  114.                 for i in range(len(listin)):
  115.                         if listin[i].isdigit():
  116.                                 if i == 0:
  117.                                         mult = 1
  118.                                 if i == 1:
  119.                                         mult = 60
  120.                                 if i == 2:
  121.                                         mult = 3600
  122.                                 result = result + (int(listin[i])*mult)            
  123.                 return result
  124.        
  125.         def sec2hms(self, seconds):
  126.                 seconds = float(seconds)
  127.                 h = int(seconds/3600)
  128.                 if (h > 0):
  129.                         seconds = seconds - (h * 3600)
  130.                 m = int(seconds / 60)
  131.                 s = int(seconds - (m * 60))
  132.                 hms = "{0:0=2d}:{1:0=2d}:{2:0=2d}".format(h,m,s)
  133.                 return hms
  134.        
  135.         def check_out_file(self):
  136.                
  137.                 def check_codec_in_name(nameck):
  138.                         if 'x264' in nameck:
  139.                                 if (Vars.vcodec_is != "x264") and (Vars.vcodec_is != "vcopy"):
  140.                                         if Vars.vcodec_is == "x265":
  141.                                                 nameck = nameck.replace('x264', 'x265')
  142.                                         else:
  143.                                                 nameck = nameck.replace('x264', '')
  144.                         elif 'x265' in nameck:
  145.                                 if (Vars.vcodec_is != "x265") and (Vars.vcodec_is != "vcopy"):
  146.                                         if Vars.vcodec_is == "x264":
  147.                                                 nameck = nameck.replace('x265', 'x264')
  148.                                         else:
  149.                                                 nameck = nameck.replace('x265', '')
  150.                         else:
  151.                                 if Vars.vcodec_is == "x265":
  152.                                         nameck = nameck + " x265"
  153.                         return nameck
  154.                
  155.                 name = os.path.splitext(Vars.basename)[0]
  156.                 name = check_codec_in_name(name)
  157.                 newname = Vars.outdir + '/' + name + Vars.ext
  158.                 if os.path.exists(newname):                    
  159.                         for i in range(2,20):
  160.                                 newname = Vars.outdir + '/' + name + '_' + str(i) + '_' + Vars.ext
  161.                                 if (os.path.exists(newname) == False):
  162.                                                         newname = newname
  163.                                                         break
  164.                 else:
  165.                         newname = newname
  166.                        
  167.                 Vars.newname = newname
  168.                 self.f3_run_outdir_label.set_tooltip_text(Vars.newname)
  169.                
  170.         def humansize(self, namefile):
  171.                 try:
  172.                         nbytes = os.path.getsize(namefile)
  173.                 except:
  174.                         return '0'
  175.                 suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
  176.                 if nbytes == 0: return '0 B'
  177.                 i = 0
  178.                 while nbytes >= 1024 and i < len(suffixes)-1:
  179.                         nbytes /= 1024.
  180.                         i += 1
  181.                 f = "{0:0.1f}".format(nbytes)
  182.                 return "{0:>5s} {1:2s}".format(f, suffixes[i])
  183.        
  184.         def version_from_filename(self):
  185.                 '''
  186.                filename must be:
  187.                4FFmpeg-n.nnn.py
  188.                '''
  189.                 try:
  190.                         #version = str(sys.argv[0])
  191.                         #version = os.path.basename(sys.argv[0])
  192.                         version = os.path.realpath(sys.argv[0]) # work w symlink
  193.                         version = os.path.basename(version)
  194.                 except:
  195.                         version = 'N/A'
  196.                         return version
  197.                 try:
  198.                         version = version.split('-')[1]
  199.                 except:
  200.                         version = 'N/A'
  201.                         return version
  202.                 if version[-3:] == ".py":
  203.                         try:
  204.                                 version = version[:-3]
  205.                         except:
  206.                                 version = 'N/A'
  207.                                 return version          
  208.                 return version
  209.  
  210.         def is_number(self, string):
  211.                 num_format = re.compile("^[\-]?[1-9][0-9]*\.?[0-9]+$")
  212.                 isnumber = re.match(num_format,string)
  213.                 return isnumber
  214.  
  215.  
  216. class ui_elem_controller():
  217.        
  218.         def adj_change(self, adjustment, value, lower, upper , step_increment, page_increment):
  219.                 adjustment.set_value(value)
  220.                 adjustment.set_lower(lower)
  221.                 adjustment.set_upper(upper)
  222.                 adjustment.set_step_increment(step_increment)
  223.                 adjustment.set_page_increment(page_increment)
  224.                 #adjustment.set_page_size(page_size)
  225.        
  226.         def cboxtxt_change(self, the_cboxtext, the_function, item_list, item_selected, global_list, list_in_use):
  227.                 the_cboxtext.disconnect_by_func(the_function)
  228.                 the_cboxtext.remove_all()
  229.                 for i, v in enumerate(item_list):
  230.                                 the_cboxtext.append_text(v)
  231.                 the_cboxtext.connect("changed", the_function)
  232.                 the_cboxtext.set_active(item_selected)
  233.                 objname = global_list.split('.')[0]
  234.                 glist = global_list.split('.')[1]
  235.                 setattr(globals()[objname], glist, list_in_use)
  236.                
  237.         # old way ------------------------------------------------------------
  238.         #def x265_opt_list(self, selected):
  239.         #       self.box_3v_x264opts.disconnect_by_func(self.on_codec_clicked)
  240.         #       self.box_3v_x264opts.remove_all()
  241.         #       for i, v in enumerate(Vars.x265_opt):
  242.         #               self.box_3v_x264opts.append_text(v)
  243.         #       self.box_3v_x264opts.set_active(selected)
  244.         #       self.box_3v_x264opts.connect("changed", self.on_codec_clicked)
  245.         #       Vars.opt_list = 'x265'
  246.  
  247.  
  248. # Abstract struct class      
  249. class Struct:
  250.        
  251.         def __init__ (self, *argv, **argd):
  252.                 if len(argd):
  253.                         # Update by dictionary
  254.                         self.__dict__.update (argd)
  255.                 else:
  256.                         # Update by position
  257.                         #attrs = filter (lambda x: x[0:2] != "__", dir(self))
  258.                         #2to3 patch:
  259.                         attrs = [x for x in dir(self) if x[0:2] != "__"]
  260.                         for n in range(len(argv)):
  261.                                 setattr(self, attrs[n], argv[n])
  262.                
  263. class Tips(Struct):
  264.        
  265.         map_tooltip_str = ' use: 0:0  or  0:0,0:1,0:2 '
  266.         time_tooltip_str = '  use: 90  or  90.555  or  00:01:30  or  00:01:30.555   '
  267.         customscale_str = '   use:  scale=1014:432,setdar=235/100,setsar=1/1   '
  268.         time2frame_str = '  Convert time sec or hh:mm:ss (.decimal) to frames   '
  269.         black_dt_init_str = 'Detect black frames can take some time,\ndepending on the length of the video.'
  270.         compad_str = ' attacks attacks:decays decays: points dbin/dbout dbin/dbout:soft-knee:gain:initial volume:delay  '
  271.         dynaudnorm_str = ' f= 10 to 8000 - frame length ms (500)\n g= 3 to 301 - filter window size (31) must be odd number \n s= 3.00 to 30.0 - compress factor, 0 = disable, 3 = max comp \n p= 0 to 1 (0.95) - target peak value '
  272.         drc_str = '   -drc_scale percentage of dynamic range compression to apply (from 0 to 6) (default 1)   '
  273.         but_file_str = '  Choose input file   '
  274.         faac_q_str = ' faac vbr: q 80 ~96k, 90 ~100k, 100 ~118k, 120 ~128k, 160 ~156k, 330 ~270k, def:100 '
  275.         faac_cbr_str = " faac abr: 32-320 Kb/s def:112 "
  276.         lamecbr_str = " lame mp3: 32-320 Kb/s def:128 "
  277.         lamevbr_str = " lame mp3 vbr: q 0 ~245Kb/s, 5 ~130Kb/s, 6 ~115Kb/s, 9 ~65Kb/s, def:6 "
  278.         aac_cbr_str = " aac cbr: 32-320 Kb/s def:128 "
  279.         aak_cbr_str = " aac_fdk cbr: 64-320 Kb/s def:128 "
  280.         fdkaac_he_str = " aac_fdk_he1 cbr: 48-64 Kb/s def:64 "
  281.         fdkaac_vbr_str = " aac_fdk vbr: 5 ~160K, 4 ~120K, 3 ~100K, 2 ~80K, 1 ~70K"
  282.         audio_samp_str = ' audio samplerate '
  283.         audio_channels_str = ' audio channels '
  284.         subcopy_tooltip_srt = ' false= srt->ass '
  285.         nometa_tooltip_srt = ' true= --map_metadata -1 '
  286.         debug_tooltip_srt = ' only print command in terminal '
  287.         preset_tooltip_str = ' x264/5 preset '
  288.         tune_tooltip_str = ' x264/5 tune '
  289.         opt_tooltip_str = ' x264/5 options/params '
  290.         x265_optscustom_str = '  x265 custom opts, use: rd=3:aq-mode=3:zones=300,1000,b=1.5\/5000,6000,q=50   '
  291.         ffplay_tooltip_str = ' ffplay keys: \n f - full screen \n a - audio stream \n v - video stream \n s - sub stream \n arrows - seek '
  292.         out_dir_tooltip_str = '  Change current out dir   \n  Default: same as input   '
  293.         container_tooltip_srt = '  Change out container   '
  294.  
  295.  
  296. class Vars(Struct):
  297.        
  298.         ffmpeg_ex = 'ffmpeg'
  299.         ffplay_ex = 'ffplay'
  300.         ffprobe_ex = 'ffprobe'
  301.         final_vf_str = ""
  302.         final_af_str = ""
  303.         deint_str = ""
  304.         crop_str = ""
  305.         scalestr = ""
  306.         dn_str = ""
  307.         uns_str = ""
  308.         fr_str = ""
  309.         filter_test_str = ""
  310.         video_width = "0"
  311.         video_height = "0"
  312.         darin = "1"
  313.         add_1_1_dar = True
  314.         framerate = 25
  315.         maps_str = ""
  316.         time_final_str = ""
  317.         final_codec_str = ""
  318.         final_other_str = ""
  319.         acodec_is = ""
  320.         audio_channels = 0
  321.         audio_codec_str = ""
  322.         vcodec_is = ""
  323.         video_codec_str = ""
  324.         video_codec_str_more = ""
  325.         container_str = ""
  326.         info_str = ''
  327.         blackdet_is_run = False
  328.         compinit = '.3 .3:1 1:-90/-90 -60/-40 -39/-30 -20/-14 -9/-9 0/-3:6:-5:0:.5'
  329.         compand_data = ''
  330.         compand_time = 0
  331.         dynaudnorm = "f=500:g=31:s=18:p=0.80"
  332.         dynaudnorm_data = ''
  333.         time_start = 0 # for cropdetect and test
  334.         p3_command = ""
  335.         filename = ""
  336.         dirname = ""
  337.         basename = ""
  338.         in_file_size = ""
  339.         ext = ""
  340.         outdir = ""
  341.         indir = ""
  342.         newname = ""
  343.         duration = ""
  344.         duration_in_sec = 0
  345.         time_done = 0
  346.         time_done_1 = 0
  347.         out_file_size = ""
  348.         debug = 0
  349.         first_pass = 0
  350.         n_pass = 1
  351.         p3_comm_first_p = ""
  352.         final_command1 = ""
  353.         final_command2 = ""
  354.         eff_pass = 0
  355.         version = ""
  356.         BLACKDT_DONE = False
  357.         VOLDT_DONE = False
  358.         FRAMDT_DONE = False
  359.         ENCODING = False
  360.         ac3_drc = ""
  361.         mp4_acodec = [
  362.                 "libfaac quality (Q)",
  363.                 "libfaac ABR (Kb/s)",
  364.                 "aac native CBR (Kb/s)",
  365.                 "aac_fdk CBR (Kb/s)",
  366.                 "aac_fdk VBR (Q)",
  367.                 "aac_fdk HE v1 (Kb/s)",
  368.                 "aacplus (64 Kb/s)",
  369.                 "aacplus (32 Kb/s)",
  370.                 "lame mp3 CBR (Kb/s)",
  371.                 "lame mp3 VBR (Q)",
  372.                 "audio copy",
  373.                 "no audio"
  374.                 ]
  375.         mka_acodec = [
  376.                 "libfaac quality (Q)",
  377.                 "libfaac ABR (Kb/s)",
  378.                 "aac native CBR (Kb/s)",
  379.                 "aac_fdk CBR (Kb/s)",
  380.                 "aac_fdk VBR (Q)",
  381.                 "aac_fdk HE v1 (Kb/s)",
  382.                 "aacplus (64 Kb/s)",
  383.                 "aacplus (32 Kb/s)",
  384.                 "lame mp3 CBR (Kb/s)",
  385.                 "lame mp3 VBR (Q)",
  386.                 "audio copy"
  387.                 ]
  388.         avi_acodec = [
  389.                 "lame mp3 CBR (Kb/s)",
  390.                 "lame mp3 VBR (Q)",
  391.                 "audio copy",
  392.                 "no audio"
  393.                 ]
  394.         acodec_list = "mp4"
  395.        
  396.         mp4_vcodec = [
  397.                 "libx265",
  398.                 "libx264",
  399.                 "mpeg4",
  400.                 "video copy",
  401.                 "no video"
  402.                 ]
  403.         mkv_vcodec = [
  404.                 "libx265",
  405.                 "libx264",
  406.                 "mpeg4",
  407.                 "video copy"
  408.                 ]
  409.         avi_vcodec = [
  410.                 "mpeg4",
  411.                 "video copy"
  412.                 ]
  413.         none_vcodec = [
  414.                 "no video"
  415.                 ]
  416.         vcodec_list = "mp4"
  417.        
  418.         full_container = [
  419.                 "MKV",
  420.                 "MP4",
  421.                 "AVI",
  422.                 "MKA"
  423.                 ]
  424.        
  425.         x264_vrc = [
  426.                 "crf",
  427.                 "bitrate kb/s"
  428.                 ]
  429.         mpeg4_vrc = [
  430.                 "bitrate kb/s",
  431.                 "qscale (1-31)"
  432.                 ]
  433.         x265_vrc = [
  434.                 "crf",
  435.                 "bitrate kb/s"
  436.                 ]
  437.         vrc_list = 'x264'
  438.        
  439.         x264_preset = [
  440.                 "ultrafast",
  441.                 "superfast",
  442.                 "veryfast",
  443.                 "faster",
  444.                 "fast",
  445.                 "medium",
  446.                 "slow",
  447.                 "veryslow"
  448.                 ]
  449.         preset_list = 'x264'
  450.        
  451.         x264_tune = [
  452.                 "film",
  453.                 "animation",
  454.                 "grain",
  455.                 "stillimage"
  456.                 ]
  457.         x265_tune = [
  458.                 "none",
  459.                 "grain",
  460.                 "fastdecode",
  461.                 "zerolatency"
  462.                 ]
  463.         tune_list = 'x264'
  464.        
  465.         x264_opt = [
  466.                 "x264opts 1",
  467.                 "no opts (ssim)"
  468.                 ]
  469.         x265_opt = [
  470.                 "ssim",
  471.                 "db-4 psy0.5 no-sao",
  472.                 "db-3 no-sao",
  473.                 "1+aq-mode3",
  474.                 "1+aq-mode3 rd2",
  475.                 "custom ->"
  476.                 ]
  477.         opt_list = 'x264'
  478.        
  479.         audio_sample = [
  480.                 '48000',
  481.                 '44100'
  482.                 ]
  483.        
  484.        
  485. class ProgrammaGTK(reuse_init, ui_elem_controller, my_utility):
  486.        
  487.         ## version ---------------------------------
  488.         #Vars.version = '8.166s'
  489.         ## -----------------------------------------
  490.        
  491.  
  492.         def __init__(self):
  493.        
  494.                 # initialize variables
  495.                
  496.                 if Vars.version == '':
  497.                         Vars.version = self.version_from_filename()
  498.  
  499.                 self.make_ui()
  500.                
  501.                 Vars.outdir = os.getcwd()
  502.                 Vars.indir = Vars.outdir
  503.                
  504.                 self.on_codec_audio_changed(0)
  505.                 self.on_codec_video_changed(0)
  506.                 self.on_f3_other_clicked(0)
  507.                 self.on_container_changed(0)
  508.                
  509.                 if (len(sys.argv) == 2):
  510.                         try:
  511.                                 Vars.filename = (str(sys.argv[1]))
  512.                                 self.file_changed()
  513.                         except:
  514.                                 pass
  515.                
  516.                 # ----------------------------
  517.                
  518.                
  519.         def make_ui(self):
  520.  
  521.                 # ---------------------
  522.                 self.window =  Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
  523.                 self.window.connect("destroy", self.on_window_destroy)
  524.                 self.window.set_title("4FFmpeg")
  525.                 self.window.set_position(1) # 1 center, 0 none,
  526.                 self.window.set_border_width(3)
  527.                 self.window.set_default_size(500,-1)
  528.                 #----------------------------------
  529.                
  530.                 #page1 stuff VIDEO FILTERS------------------------------------------
  531.                                
  532.                 # page1 VBox -------------------------
  533.                 self.vbox1 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
  534.                 #self.vbox1.set_orientation(Gtk.Orientation.VERTICAL) # Gtk.Orientation.HORIZONTAL
  535.                 #self.vbox1.set_spacing(2)
  536.                
  537.                 # map --------------------------------------
  538.                 self.make_map()        
  539.                 # add map frame
  540.                 self.vbox1.pack_start(self.f_map['frame'], 1, 0, 0)
  541.                
  542.                 #time cut ------------------------------------
  543.                 self.make_time_cut()
  544.                 # add time frame
  545.                 self.vbox1.pack_start(self.f_time['frame'], 1, 0, 0)
  546.                
  547.                 # deinterlace -----------------------
  548.                 self.make_deinterlace()
  549.                 # add deinterlace frame
  550.                 self.vbox1.pack_start(self.f_deint['frame'], 1, 0, 0)
  551.                
  552.                 # crop ----------------------------------------
  553.                 self.make_crop()        
  554.                 # add crop frame -------------------
  555.                 self.vbox1.pack_start(self.frame_crop['frame'], 1, 0, 0)
  556.        
  557.                 # scale ------------------------------
  558.                 self.make_scale()
  559.                 # add scale frame------------------
  560.                 self.vbox1.pack_start(self.frame_scale['frame'], 1, 0, 0)
  561.  
  562.                 # denoise ----------------------------
  563.                 self.make_denoise()
  564.                 # add denoise frame------------------------
  565.                 self.vbox1.pack_start(self.frame_dn['frame'], 1, 0, 0)
  566.                
  567.                 #test-------------------
  568.                 #self.f_test = self.make_frame_ag(3, "TEST" , 6, 8, 8, True)
  569.                 #self.label_test = Gtk.Label("TEST")
  570.                 #self.f_test['grid'].attach(self.label_test, 0, 0, 1, 1)
  571.  
  572.                 #self.vbox1.pack_start(self.f_test['frame'], 1, 0, 0)
  573.                 #-------------------------------------
  574.                
  575.                 # page 1 output------------------------
  576.                 self.frame_out = self.make_frame_ag(3, '  FFmpeg video filter string:  ' , 12, 8, 8, True)
  577.                 self.labelout = Gtk.Label("")
  578.                 self.labelout.set_selectable(1)
  579.                 self.labelout.set_width_chars(120)
  580.                 self.labelout.set_max_width_chars(130)
  581.                 self.labelout.set_line_wrap(True)
  582.                 self.frame_out['grid'].attach(self.labelout, 0, 0, 1 ,1)
  583.                 # add output frame ---------------------
  584.                 self.vbox1.pack_start(self.frame_out['frame'], 1, 0, 0)
  585.                
  586.                 # end page1 stuff
  587.                
  588.                
  589.                 # page2 stuff  UTILITY ------------------------------------------
  590.                
  591.                 # page2 VBox -------------------------
  592.                 self.vbox_pg2 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
  593.                
  594.                 #volumedetect ------------------------------------
  595.                 self.make_volume_det()
  596.                 # add volumedetect frame        
  597.                 self.vbox_pg2.pack_start(self.f_volume_det['frame'], 1, 0, 0)
  598.                
  599.                 #frames detect
  600.                 self.make_frames_det()
  601.                 # add  frames detect frame      
  602.                 self.vbox_pg2.pack_start(self.f_frames_det['frame'], 1, 0, 0)
  603.                
  604.                
  605.                 #drc ------------------------------------
  606.                 self.make_volume_drc()
  607.                 # add volumedetect frame        
  608.                 self.vbox_pg2.pack_start(self.f_volume_drc['frame'], 1, 0, 0)
  609.                
  610.                 #compand ---------------------------------------
  611.                 self.make_compand()
  612.                 # add frame
  613.                 self.vbox_pg2.pack_start(self.f_compand['frame'], 1, 0, 0)
  614.                
  615.                 #dynaudnorm-------------------
  616.                 self.make_dynaudnorm()
  617.                 # add frame
  618.                 self.vbox_pg2.pack_start(self.f_dynaudnorm['frame'], 1, 0, 0)
  619.                
  620.                 # black detect ----------------------------------
  621.                 self.make_black_detect()
  622.                 # add black_detect frame
  623.                 self.vbox_pg2.pack_start(self.f_blackd['frame'], 1, 0, 0)
  624.                
  625.                 # info frame----------------------
  626.                 self.make_info_frame()
  627.                 # add info frame
  628.                 self.vbox_pg2.pack_start(self.f_info['frame'], 1, 0, 0)
  629.                
  630.                 # end page2 stuff
  631.                
  632.                 # page 3 stuff  ffmpeg commands -----------------------------------------
  633.                
  634.                 # page3 VBox -------------------------
  635.                 self.vbox_pg3 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
  636.                
  637.                 # audio codec -------------------
  638.                 self.make_audio_codec()
  639.                 #add frame audio codec
  640.                 self.vbox_pg3.pack_start(self.f_3acodec['frame'], 1, 0, 0)
  641.                
  642.                 # video codec -------------------
  643.                 self.make_video_codec()
  644.                 #add frame video codec
  645.                 self.vbox_pg3.pack_start(self.f_3vcodec['frame'], 1, 0, 0)
  646.                
  647.                 # other options ----------------
  648.                 self.make_other_opts()
  649.                 #add frame other options
  650.                 self.vbox_pg3.pack_start(self.f3_oth['frame'], 1, 0, 0)
  651.                
  652.                 # page3 output ---------------------
  653.                 self.f3_out = self.make_frame_ag(3, "  FFmpeg command  " , 6, 8, 8, True)
  654.                 self.f3_out_label = Gtk.Label("")
  655.                 self.f3_out_label.set_width_chars(106)
  656.                 self.f3_out_label.set_max_width_chars(106)
  657.                 self.f3_out_label.set_line_wrap(True)
  658.                 self.f3_out_label.set_selectable(1)
  659.                 self.f3_out['grid'].attach(self.f3_out_label, 0, 0, 1, 1)
  660.                 # add frame page3 output
  661.                 self.vbox_pg3.pack_start(self.f3_out['frame'], 1, 0, 0)
  662.                
  663.                 # run ffmpeg ---------------------------------
  664.                 self.make_run_ffmpeg()
  665.                 # add frame run ffmpeg
  666.                 self.vbox_pg3.pack_start(self.f3_run['frame'], 1, 0, 0)
  667.                
  668.                
  669.                 #---------------------------------------------------
  670.                 # main vbox
  671.                 self.main_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
  672.                
  673.                 # notebook      
  674.                 self.notebook = Gtk.Notebook()
  675.                 self.notebook.set_tab_pos(Gtk.PositionType.TOP)  #GTK_POS_LEFT = 0
  676.                 self.notebook.set_show_border (False)
  677.                 self.main_vbox.pack_start(self.notebook, 1, 0, 0)
  678.                
  679.                 #page 1
  680.                 self.tab1label = Gtk.Label("Video filters")
  681.                 self.page1_ali = Gtk.Alignment()
  682.                 self.page1_ali.set_padding(0, 6, 6, 6)
  683.                 self.page1_ali.add(self.vbox1)
  684.                 self.notebook.append_page(self.page1_ali, self.tab1label)
  685.                
  686.                 #page 2
  687.                 self.tab2label = Gtk.Label("Utility")
  688.                 self.page2_ali = Gtk.Alignment()
  689.                 self.page2_ali.set_padding(0, 6, 6, 6)
  690.                 self.page2_ali.add(self.vbox_pg2)
  691.                 self.notebook.append_page(self.page2_ali, self.tab2label)
  692.                
  693.                 #page 3
  694.                 self.tab3label = Gtk.Label("Encode")
  695.                 self.page3_ali = Gtk.Alignment()
  696.                 self.page3_ali.set_padding(0, 6, 6, 6)
  697.                 self.page3_ali.add(self.vbox_pg3)
  698.                 self.notebook.append_page(self.page3_ali, self.tab3label)
  699.                
  700.                 #---------------------------------------------------
  701.                
  702.                 # low part BUTTONS AND TERM --------------------------
  703.                 self.make_low_part()
  704.                 # add low part-----------------
  705.                 self.main_vbox.pack_start(self.gridterm, 1, 1, 0)
  706.                
  707.                 #---------------------------------------------------------
  708.                 self.window.add (self.main_vbox)
  709.                 #---------------------------------
  710.                 self.window.show_all()          
  711.  
  712.                
  713.         def make_deinterlace(self):
  714.                 self.f_deint = self.make_frame_ag(3, "" , 6, 8, 8, True)
  715.                 self.checkdeint = Gtk.CheckButton("deinterlace")
  716.                 self.checkdeint.connect("toggled", self.on_deint_clicked)
  717.                 self.f_deint['grid'].attach(self.checkdeint, 0, 0, 1, 1)
  718.                
  719.                 self.box_deint = self.make_combobox(
  720.                   "yadif",
  721.                   "postprocessing linear blend",
  722.                   "detect (use only with Test)"
  723.                   )
  724.                 self.f_deint['grid'].attach(self.box_deint['cbox'], 1, 0, 1, 1)
  725.                 self.box_deint['cbox'].connect("changed", self.on_deint_clicked)
  726.                 #
  727.                 self.f_deint['grid'].attach(self.make_label(""), 2, 0, 1, 1)
  728.        
  729.         def make_map(self):
  730.                 #
  731.                 self.f_map = self.make_frame_ag(3, "" , 6, 8, 8, False)
  732.                 #
  733.                 self.check_map = Gtk.CheckButton("map")
  734.                 self.check_map.connect("toggled", self.on_map_clicked) # toggled or activate (enter)
  735.                 self.f_map['grid'].attach(self.check_map, 0, 0, 1, 1)
  736.                 #
  737.                 self.mapstream_label = self.make_label("streams: ")
  738.                 self.f_map['grid'].attach(self.mapstream_label, 1, 0, 1, 1)
  739.                 #
  740.                 self.entry_map = Gtk.Entry()
  741.                 self.entry_map.set_tooltip_text(Tips.map_tooltip_str)
  742.                 self.entry_map.connect("changed", self.on_map_clicked)
  743.                 self.f_map['grid'].attach(self.entry_map, 2, 0, 1, 1)
  744.                 #
  745.                 self.map_label = Gtk.Label("")
  746.                 self.map_label.set_width_chars(70)
  747.                 self.f_map['grid'].attach(self.map_label, 3, 0, 2, 1)
  748.                 # placeholder
  749.                 self.f_map['grid'].attach(self.make_label("Version: " + Vars.version + "   "), 5, 0, 1, 1)
  750.                
  751.         def make_time_cut(self):
  752.                 #
  753.                 self.f_time = self.make_frame_ag(3, "" , 6, 8, 8, True)
  754.                 #
  755.                 self.check_time = Gtk.CheckButton("time")
  756.                 self.check_time.connect("toggled", self.on_time_clicked) # toggled or activate (enter)
  757.                 self.f_time['grid'].attach(self.check_time, 0, 0, 1, 1)
  758.                 #
  759.                 self.label_time_in = self.make_label("from: ")
  760.                 self.f_time['grid'].attach(self.label_time_in, 1, 0, 1, 1)
  761.                 self.entry_timein = Gtk.Entry()
  762.                 self.entry_timein.set_tooltip_text(Tips.time_tooltip_str)
  763.                 self.entry_timein.set_max_length(12)
  764.                 self.entry_timein.set_max_width_chars(12)
  765.                 self.entry_timein.set_width_chars(12)
  766.                 #self.entry_timein.set_halign(1)
  767.                 self.entry_timein.connect("changed", self.on_time_clicked)
  768.                 self.f_time['grid'].attach(self.entry_timein, 2, 0, 1, 1)
  769.                
  770.                 self.label_time_out = self.make_label("to: ")
  771.                 self.f_time['grid'].attach(self.label_time_out, 3, 0, 1, 1)
  772.                 self.entry_timeout = Gtk.Entry()
  773.                 self.entry_timeout.set_tooltip_text(Tips.time_tooltip_str)
  774.                 self.entry_timeout.set_max_length(12)
  775.                 self.entry_timeout.set_max_width_chars(12)
  776.                 self.entry_timeout.set_width_chars(12)
  777.                 self.entry_timeout.connect("changed", self.on_time_clicked)
  778.                 self.f_time['grid'].attach(self.entry_timeout, 4, 0, 1, 1)
  779.                 self.time_label = Gtk.Label('')
  780.                 self.f_time['grid'].attach(self.time_label, 5, 0, 2, 1)
  781.        
  782.         def make_scale(self):
  783.                 self.frame_scale = self.make_frame_ag(3, '  scale  ' , 6, 8, 8, False)
  784.                 # ------------------------------
  785.                 self.box1 = self.make_combobox(
  786.                   "None",
  787.                   "W",
  788.                   "H"
  789.                   )
  790.                 self.box1['cbox'].set_size_request(180,-1)
  791.                 self.frame_scale['grid'].attach(self.box1['cbox'], 0, 0, 1, 1)
  792.                 self.box1['cbox'].connect("changed", self.on_scale_clicked)
  793.                 #------------------------------------
  794.                 self.box2 = self.make_combobox(
  795.                   "16/9",
  796.                   "4/3",
  797.                   "2.35/1"
  798.                   )
  799.                 self.frame_scale['grid'].attach(self.box2['cbox'], 0, 1, 1, 1)
  800.                 self.box2['cbox'].connect("changed", self.on_scale_clicked)
  801.                 #-----------------------------------------
  802.                 self.size_spinner = self.make_slider_and_spinner(720, 200, 2000, 8, 32, 0)
  803.                 self.frame_scale['grid'].attach(self.size_spinner['slider'], 1, 0, 1, 1)
  804.                 self.frame_scale['grid'].attach(self.size_spinner['spinner'], 2, 0, 1, 1)
  805.                 self.size_spinner['slider'].set_size_request(200,-1)
  806.                 self.size_spinner['adj'].set_value(720.001) #mettere decimali se no non si vede
  807.                 self.size_spinner['adj'].connect("value-changed", self.on_scale_clicked)
  808.                 #-------------------------------------------------------
  809.                 self.check_round = Gtk.CheckButton("round 8")
  810.                 self.check_round.connect("toggled", self.on_scale_clicked)
  811.                 self.frame_scale['grid'].attach(self.check_round, 1, 1, 1, 1)
  812.                 #
  813.                 self.check = Gtk.CheckButton("lanczos")
  814.                 self.check.connect("toggled", self.on_scale_clicked)
  815.                 self.frame_scale['grid'].attach(self.check, 2, 1, 1, 1)
  816.                 #custom scale string
  817.                 self.label_scalecustom = self.make_label("Custom scale filter (override all scale settings):")
  818.                 self.label_scalecustom.set_alignment(0.5, 0.5)
  819.                 self.frame_scale['grid'].attach(self.label_scalecustom, 3, 0, 1, 1)
  820.                 self.entry_scalecustom = Gtk.Entry()
  821.                 self.entry_scalecustom.set_tooltip_text(Tips.customscale_str)
  822.                 self.entry_scalecustom.connect("changed", self.on_scale_clicked)
  823.                 self.entry_scalecustom.set_max_length(100)
  824.                 self.entry_scalecustom.set_max_width_chars(60)
  825.                 self.frame_scale['grid'].attach(self.entry_scalecustom, 3, 1, 1, 1)
  826.                
  827.                
  828.         def make_crop(self):
  829.                 self.frame_crop = self.make_frame_ag(3, '' , 6, 2, 0, True)
  830.                 # -------
  831.                 self.checkcr = Gtk.CheckButton("crop")
  832.                 self.checkcr.connect("toggled", self.on_crop_clicked)
  833.                 self.frame_crop['grid'].attach(self.checkcr, 0, 0, 1, 1)
  834.                 #----------
  835.                 self.butcrode = Gtk.Button(label="Crop detect")
  836.                 self.butcrode.connect("clicked", self.on_butcrode_clicked)
  837.                 self.butcrode.set_sensitive(False)
  838.                 self.frame_crop['grid'].attach(self.butcrode, 0, 1, 1, 1)
  839.                 #-----------
  840.                 self.labelcropinw = self.make_label("input W: ")
  841.                 self.frame_crop['grid'].attach(self.labelcropinw, 1, 0, 1, 1)
  842.                 self.labelcropinh = self.make_label("input H: ")
  843.                 self.frame_crop['grid'].attach(self.labelcropinh, 1, 1, 1, 1)
  844.                 #
  845.                 self.spincw = self.make_spinbut(640 , 100 , 1920 , 10 , 1 , 0, True )
  846.                 self.spincw["adj"].connect("value-changed", self.on_crop_clicked)
  847.                 self.frame_crop['grid'].attach(self.spincw["spinner"], 2, 0, 1, 1)
  848.                 #
  849.                 self.spinch = self.make_spinbut(480 , 100 , 1280 , 10 , 1 , 0, True )
  850.                 self.spinch["adj"].connect("value-changed", self.on_crop_clicked)
  851.                 self.frame_crop['grid'].attach(self.spinch["spinner"], 2, 1, 1, 1)
  852.                 #
  853.                
  854.                 self.labelcroptop = self.make_label("crop Top: ")
  855.                 self.frame_crop['grid'].attach(self.labelcroptop, 3, 0, 1, 1)
  856.                 self.labelcropbot = self.make_label("crop Bottom: ")
  857.                 self.frame_crop['grid'].attach(self.labelcropbot, 3, 1, 1, 1)
  858.                 #
  859.                
  860.                 self.spinct = self.make_spinbut(0 , 0 , 600 , 1 , 10 , 0, True )
  861.                 self.spinct["adj"].connect("value-changed", self.on_crop_clicked)
  862.                 self.frame_crop['grid'].attach(self.spinct["spinner"], 4, 0, 1, 1)
  863.                 #
  864.                 self.spincb = self.make_spinbut(0 , 0 , 600 , 1 , 10 , 0, True )
  865.                 self.spincb["adj"].connect("value-changed", self.on_crop_clicked)
  866.                 self.frame_crop['grid'].attach(self.spincb["spinner"], 4, 1, 1, 1)
  867.                 #
  868.                
  869.                 self.labelcroplef = self.make_label("crop Left: ")
  870.                 self.frame_crop['grid'].attach(self.labelcroplef, 5, 0, 1, 1)
  871.                 self.labelcroprig = self.make_label("crop Right: ")
  872.                 self.frame_crop['grid'].attach(self.labelcroprig, 5, 1, 1, 1)
  873.                 #
  874.                 self.spincl = self.make_spinbut(0 , 0 , 600 , 1 , 10 , 0, True )
  875.                 self.spincl["adj"].connect("value-changed", self.on_crop_clicked)
  876.                 self.frame_crop['grid'].attach(self.spincl["spinner"], 6, 0, 1, 1)
  877.                 #
  878.                 self.spincr = self.make_spinbut(0 , 0 , 600 , 1 , 10 , 0, True )
  879.                 self.spincr["adj"].connect("value-changed", self.on_crop_clicked)
  880.                 self.frame_crop['grid'].attach(self.spincr["spinner"], 6, 1, 1, 1)
  881.                
  882.                
  883.         def make_denoise(self):
  884.                 self.frame_dn = self.make_frame_ag(3, '  denoise / unsharp luma chroma / frame rate   ' , 6, 8, 8, True)
  885.                 # denoise ----------------------
  886.                 self.checkdn = Gtk.CheckButton("hqdn3d:")
  887.                 self.checkdn.set_alignment(1.0, 0.5)
  888.                 self.checkdn.set_halign(2)
  889.                 self.checkdn.connect("toggled", self.on_dn_clicked)
  890.                 self.frame_dn['grid'].attach(self.checkdn, 0, 0, 1, 1)
  891.                 #
  892.                 self.spindn = self.make_spinbut(4 , 2 , 8 , 1 , 10 , 0, True )
  893.                 self.spindn["adj"].connect("value-changed", self.on_dn_clicked)
  894.                 #self.spindn['spinner'].set_max_length(1)
  895.                 #self.spindn['spinner'].set_width_chars(1)
  896.                 self.frame_dn['grid'].attach(self.spindn["spinner"], 1, 0, 1, 1)
  897.                 # -----------------------
  898.                 # unsharp unsharp=5:5:luma:5:5:chroma, luma chroma -1.5 to 1.5
  899.                 self.checkuns = Gtk.CheckButton("unsharp l/c:")
  900.                 self.checkuns.set_alignment(1.0, 0.5)
  901.                 self.checkuns.set_halign(2)
  902.                 self.checkuns.connect("toggled", self.on_uns_clicked)
  903.                 self.frame_dn['grid'].attach(self.checkuns, 2, 0, 1, 1)
  904.                 self.spinunsl = self.make_spinbut(0.0 , -1.5 , 1.5 , .1 , .01 , 2, True )
  905.                 self.spinunsl["adj"].connect("value-changed", self.on_uns_clicked)
  906.                 self.frame_dn['grid'].attach(self.spinunsl["spinner"], 3, 0, 1, 1)
  907.                 self.spinunsc = self.make_spinbut(0.0 , -1.5 , 1.5 , .1 , .01 , 2, True )
  908.                 self.spinunsc["adj"].connect("value-changed", self.on_uns_clicked)
  909.                 self.frame_dn['grid'].attach(self.spinunsc["spinner"], 4, 0, 1, 1)
  910.                 # framerate --------------------------
  911.                 self.checkfr = Gtk.CheckButton("frame rate:")
  912.                 self.checkfr.set_alignment(1.0, 0.5)
  913.                 self.checkfr.set_halign(2)
  914.                 self.checkfr.connect("toggled", self.on_fr_clicked)
  915.                 self.frame_dn['grid'].attach(self.checkfr, 5, 0, 1, 1)
  916.                 self.spinfr = self.make_spinbut(0 , 0 , 100 , 1 , 10 , 2, True )
  917.                 self.spinfr["adj"].connect("value-changed", self.on_fr_clicked)
  918.                 self.frame_dn['grid'].attach(self.spinfr["spinner"], 6, 0, 1, 1)
  919.                
  920.         def make_low_part(self):
  921.                 # grid
  922.                 self.gridterm = Gtk.Grid()
  923.                 self.gridterm.set_row_spacing(2)
  924.                 self.gridterm.set_column_spacing(2)
  925.                 self.gridterm.set_column_homogeneous(True) # True
  926.                 # filechooserbutton
  927.                 self.but_file = Gtk.Button("Choose File")
  928.                 self.but_file.connect("clicked", self.on_but_file)
  929.                 self.but_file.set_tooltip_text(Tips.but_file_str)
  930.                 #ff command button
  931.                 self.butplay = Gtk.Button(label="FFplay")
  932.                 self.butplay.connect("clicked", self.on_butplay_clicked)
  933.                 self.butplay.set_sensitive(False)
  934.                 self.butplay.set_tooltip_text(Tips.ffplay_tooltip_str)
  935.                 #
  936.                 self.butprobe = Gtk.Button(label="FFprobe")
  937.                 self.butprobe.connect("clicked", self.on_butprobe_clicked)
  938.                 self.butprobe.set_sensitive(False)
  939.                 #
  940.                 self.buttest = Gtk.Button(label="Test")
  941.                 self.buttest.connect("clicked", self.on_buttest_clicked)
  942.                 self.buttest.set_sensitive(False)
  943.                 #
  944.                 self.buttestspl = Gtk.Button(label="Test split")
  945.                 self.buttestspl.connect("clicked", self.on_buttestspl_clicked)
  946.                 self.buttestspl.set_sensitive(False)
  947.                 # copy term button
  948.                 self.butt_vtecopy = Gtk.Button(label="Copy term")
  949.                 self.butt_vtecopy.connect("clicked", self.on_butt_vtecopy_clicked)
  950.                 # vte terminal
  951.                 self.terminal     = Vte.Terminal()
  952.                 try: # vte 2.90
  953.                         self.terminal.fork_command_full(
  954.                                 Vte.PtyFlags.DEFAULT, #default is fine
  955.                                 os.getcwd(), #where to start the command?   os.environ['HOME']
  956.                                 ["/bin/sh"], #where is the emulator?
  957.                                 [], #it's ok to leave this list empty
  958.                                 GLib.SpawnFlags.DO_NOT_REAP_CHILD,
  959.                                 None, #at least None is required
  960.                                 None,
  961.                         )
  962.                 except: # vte 2.91
  963.                         self.terminal.spawn_sync(
  964.                                 Vte.PtyFlags.DEFAULT, #default is fine
  965.                                 os.getcwd(), #where to start the command?   os.environ['HOME']
  966.                                 ["/bin/sh"], #where is the emulator?
  967.                                 [], #it's ok to leave this list empty
  968.                                 GLib.SpawnFlags.DO_NOT_REAP_CHILD,
  969.                                 None, #at least None is required
  970.                                 None,
  971.                                 )
  972.                 # scroller
  973.                 self.scroller = Gtk.ScrolledWindow()
  974.                 self.scroller.set_hexpand(True)
  975.                 self.scroller.set_vexpand(True)
  976.                 self.scroller.set_min_content_height(90)
  977.                 self.scroller.add(self.terminal)
  978.                 # attach to grid
  979.                 self.gridterm.attach(self.but_file, 0, 0, 2, 1)
  980.                 self.gridterm.attach(self.butprobe, 2, 0, 1, 1)
  981.                 self.gridterm.attach(self.butplay, 3, 0, 1, 1)
  982.                 self.gridterm.attach(self.buttest, 4, 0, 1, 1)
  983.                 self.gridterm.attach(self.buttestspl, 5, 0, 1, 1)
  984.                 self.gridterm.attach(self.butt_vtecopy, 6, 0, 1, 1)
  985.                 self.gridterm.attach(self.scroller, 0, 1, 7, 1)
  986.  
  987.         def make_volume_det(self):
  988.                 self.f_volume_det = self.make_frame_ag(3, "" , 6, 8, 8, True)
  989.                 #
  990.                 self.but_volume_det = Gtk.Button(label="Volume detect")
  991.                 self.but_volume_det.connect("clicked", self.on_but_volume_det_clicked)
  992.                 self.f_volume_det['grid'].attach(self.but_volume_det, 0, 0, 1, 1)
  993.                 self.but_volume_det.set_sensitive(False)
  994.                 #
  995.                 self.voldet_spin = Gtk.Spinner()
  996.                 self.voldet_spin.set_sensitive(False)
  997.                 self.f_volume_det['grid'].attach(self.voldet_spin, 1, 0, 1, 1)
  998.                 #
  999.                 self.label_maxvol = Gtk.Label("")
  1000.                 self.f_volume_det['grid'].attach(self.label_maxvol, 2, 0, 1, 1)
  1001.                 self.label_meanvol = Gtk.Label("")
  1002.                 self.f_volume_det['grid'].attach(self.label_meanvol, 3, 0, 1, 1)
  1003.                 #
  1004.                 self.check_vol = Gtk.CheckButton("volume")
  1005.                 self.check_vol.connect("toggled", self.on_volume_clicked)
  1006.                 self.f_volume_det['grid'].attach(self.check_vol, 0, 1, 1, 1)
  1007.                 #
  1008.                 self.label_db = self.make_label("dB: ")
  1009.                 self.f_volume_det['grid'].attach(self.label_db, 1, 1, 1, 1)
  1010.                 self.spin_db = self.make_spinbut(0 , -6 , 20 , 0.1 , 1 , 2, True )
  1011.                 self.spin_db["adj"].connect("value-changed", self.on_volume_clicked)
  1012.                 self.f_volume_det['grid'].attach(self.spin_db["spinner"], 2, 1, 1, 1)
  1013.                 self.label_ratio = self.make_label("ratio: ")
  1014.                 self.f_volume_det['grid'].attach(self.label_ratio, 3, 1, 1, 1)
  1015.                 self.label_ratio_val = Gtk.Label("1")
  1016.                 self.f_volume_det['grid'].attach(self.label_ratio_val, 4, 1, 1, 1)
  1017.                
  1018.         def make_frames_det(self):
  1019.                 self.f_frames_det = self.make_frame_ag(3, "" , 6, 8, 8, True)
  1020.                 #
  1021.                 self.but_frames_det = Gtk.Button(label="Total frames detect")
  1022.                 self.but_frames_det.connect("clicked", self.on_but_frames_det_clicked)
  1023.                 self.f_frames_det['grid'].attach(self.but_frames_det, 0, 0, 1, 1)
  1024.                 self.but_frames_det.set_sensitive(False)
  1025.                 #
  1026.                 self.framesdet_spin = Gtk.Spinner()
  1027.                 self.framesdet_spin.set_sensitive(False)
  1028.                 self.f_frames_det['grid'].attach(self.framesdet_spin, 1, 0, 1, 1)
  1029.                 #
  1030.                 self.label_framesdet = Gtk.Label("N/A")
  1031.                 self.f_frames_det['grid'].attach(self.label_framesdet, 2, 0, 1, 1)
  1032.                 self.label_framesdet.set_selectable(True)
  1033.                 #
  1034.                 #placeholder
  1035.                 #self.f_frames_det['grid'].attach(Gtk.Label(''), 3, 0, 2, 1)
  1036.                 ###
  1037.                 self.entry_time2frame = Gtk.Entry()
  1038.                 self.entry_time2frame.set_tooltip_text(Tips.time2frame_str)
  1039.                 self.entry_time2frame.set_max_length(12)
  1040.                 self.entry_time2frame.set_max_width_chars(12)
  1041.                 self.entry_time2frame.set_width_chars(12)
  1042.                 self.entry_time2frame.connect("changed", self.on_time2frame_clicked)
  1043.                 self.f_frames_det['grid'].attach(self.entry_time2frame, 3, 0, 1, 1)
  1044.                 self.label_time2frame = Gtk.Label('')
  1045.                 self.label_time2frame.set_selectable(True)
  1046.                 self.label_time2frame.set_tooltip_text(" calculated frames  ")
  1047.                 self.f_frames_det['grid'].attach(self.label_time2frame, 4, 0, 2, 1)
  1048.                
  1049.         def make_volume_drc(self):
  1050.                 self.f_volume_drc = self.make_frame_ag(3, "" , 6, 8, 8, True)
  1051.                 self.check_drc = Gtk.CheckButton("ac3 input drc scale")
  1052.                 self.check_drc.connect("toggled", self.on_drc_clicked)
  1053.                 self.f_volume_drc['grid'].attach(self.check_drc, 0, 0, 1, 1)
  1054.                 self.check_drc.set_sensitive(False)
  1055.                 #
  1056.                 self.spin_drc = self.make_spinbut(1 , 0 , 6 , 1 , 1 , 0, True )
  1057.                 self.spin_drc["adj"].connect("value-changed", self.on_drc_clicked)
  1058.                 self.spin_drc['spinner'].set_tooltip_text(Tips.drc_str)
  1059.                 self.f_volume_drc['grid'].attach(self.spin_drc["spinner"], 1, 0, 1, 1)
  1060.                 self.spin_drc["spinner"].set_sensitive(False)
  1061.                 #
  1062.                
  1063.                 #placeholder
  1064.                 self.f_volume_drc['grid'].attach(Gtk.Label(''), 2, 0, 3, 1)
  1065.                        
  1066.         def make_compand(self):
  1067.                 #
  1068.                 self.f_compand = self.make_frame_ag(3, "" , 6, 8, 8, False)
  1069.                 #
  1070.                 self.check_compand = Gtk.CheckButton("compand")
  1071.                 self.check_compand.connect("toggled", self.on_compand_clicked)
  1072.                 self.f_compand['grid'].attach(self.check_compand, 0, 0, 1, 1)
  1073.                 #
  1074.                 self.entry_compand = Gtk.Entry()
  1075.                 self.entry_compand.set_text(Vars.compinit)
  1076.                 self.entry_compand.set_width_chars(60)
  1077.                 self.entry_compand.connect("changed", self.on_compand_clicked)
  1078.                 self.entry_compand.set_tooltip_text(Tips.compad_str)
  1079.                 self.f_compand['grid'].attach(self.entry_compand, 1, 0, 2, 1)
  1080.                 #
  1081.                 self.compand_reset = Gtk.Button(label="reset")
  1082.                 self.compand_reset.set_size_request(110,-1)
  1083.                 self.compand_reset.connect("clicked", self.on_compand_reset)
  1084.                 self.f_compand['grid'].attach(self.compand_reset, 3, 0, 1, 1)
  1085.                 self.compand_test = Gtk.Button(label="test ebur128")
  1086.                 self.compand_test.set_size_request(110,-1)
  1087.                 self.compand_test.set_sensitive(False)
  1088.                 self.compand_test.connect("clicked", self.on_compand_test)
  1089.                 self.f_compand['grid'].attach(self.compand_test, 4, 0, 1, 1)
  1090.                 self.compand_volume = Gtk.Button(label="test volume")
  1091.                 self.compand_volume.set_size_request(110,-1)
  1092.                 self.compand_volume.set_sensitive(False)
  1093.                 self.compand_volume.connect("clicked", self.on_compand_volume)
  1094.                 self.f_compand['grid'].attach(self.compand_volume, 5, 0, 1, 1)
  1095.                
  1096.                
  1097.         def make_dynaudnorm(self):
  1098.                 #
  1099.                 self.f_dynaudnorm = self.make_frame_ag(3, "" , 6, 8, 8, False)
  1100.                 #
  1101.                 self.check_dynaudnorm = Gtk.CheckButton("dynaudnorm")
  1102.                 self.check_dynaudnorm.connect("toggled", self.on_dynaudnorm_clicked)
  1103.                 self.f_dynaudnorm['grid'].attach(self.check_dynaudnorm, 0, 0, 1, 1)
  1104.                 #
  1105.                 self.entry_dynaudnorm = Gtk.Entry()
  1106.                 self.entry_dynaudnorm.set_text(Vars.dynaudnorm)
  1107.                 self.entry_dynaudnorm.set_width_chars(57)
  1108.                 self.entry_dynaudnorm.connect("changed", self.on_dynaudnorm_clicked)
  1109.                 self.entry_dynaudnorm.set_tooltip_text(Tips.dynaudnorm_str)
  1110.                 self.f_dynaudnorm['grid'].attach(self.entry_dynaudnorm, 1, 0, 2, 1)
  1111.                 #
  1112.                 self.compand_dynaudnorm = Gtk.Button(label="reset")
  1113.                 self.compand_dynaudnorm.set_size_request(110,-1)
  1114.                 self.compand_dynaudnorm.connect("clicked", self.on_dynaudnorm_reset)
  1115.                 self.f_dynaudnorm['grid'].attach(self.compand_dynaudnorm, 3, 0, 1, 1)
  1116.                 self.dynaudnorm_test = Gtk.Button(label="test ebur128")
  1117.                 self.dynaudnorm_test.set_size_request(110,-1)
  1118.                 self.dynaudnorm_test.set_sensitive(False)
  1119.                 self.dynaudnorm_test.connect("clicked", self.on_dynaudnorm_test)
  1120.                 self.f_dynaudnorm['grid'].attach(self.dynaudnorm_test, 4, 0, 1, 1)
  1121.                 self.dynaudnorm_volume = Gtk.Button(label="test volume")
  1122.                 self.dynaudnorm_volume.set_size_request(110,-1)
  1123.                 self.dynaudnorm_volume.set_sensitive(False)
  1124.                 self.dynaudnorm_volume.connect("clicked", self.on_dynaudnorm_volume)
  1125.                 self.f_dynaudnorm['grid'].attach(self.dynaudnorm_volume, 5, 0, 1, 1)
  1126.  
  1127.         def make_black_detect(self):
  1128.                 self.f_blackd = self.make_frame_ag(3, "" , 6, 8, 8, True)
  1129.                 #
  1130.                 self.but_black_det = Gtk.Button(label="Black detect")
  1131.                 self.but_black_det.connect("clicked", self.on_but_black_det_clicked)
  1132.                 self.but_black_det.set_sensitive(False)
  1133.                 self.f_blackd['grid'].attach(self.but_black_det, 0, 0, 1, 1)
  1134.                 #
  1135.                 self.blackdet_spin = Gtk.Spinner()
  1136.                 self.blackdet_spin.set_sensitive(False)
  1137.                 self.f_blackd['grid'].attach(self.blackdet_spin, 1, 0, 1, 1)
  1138.                 #
  1139.                 scrolledwindow = Gtk.ScrolledWindow()
  1140.                 #scrolledwindow.set_hexpand(True)
  1141.                 scrolledwindow.set_vexpand(True)
  1142.                 scrolledwindow.set_min_content_height(60)
  1143.                 self.textview = Gtk.TextView()
  1144.                 self.textbuffer = self.textview.get_buffer()
  1145.                 self.textview.set_editable(False)
  1146.                 self.textview.set_cursor_visible(False)
  1147.                 self.textview.modify_font(Pango.font_description_from_string('Monospace 9'))
  1148.                 scrolledwindow.add(self.textview)
  1149.                 self.textbuffer.set_text(Tips.black_dt_init_str)
  1150.                 self.f_blackd['grid'].attach(scrolledwindow, 2, 0, 3, 3)
  1151.                 #
  1152.                 self.progressbar_black_det = Gtk.ProgressBar()
  1153.                 self.f_blackd['grid'].attach(self.progressbar_black_det, 0, 1, 1, 1)
  1154.                
  1155.         def make_info_frame(self):
  1156.                 self.f_info = self.make_frame_ag(3, "  info  " , 6, 8, 8, True)
  1157.                 scrolledwindow1 = Gtk.ScrolledWindow()
  1158.                 scrolledwindow1.set_hexpand(True)
  1159.                 scrolledwindow1.set_vexpand(True)
  1160.                 scrolledwindow1.set_min_content_height(50)
  1161.                 self.textview_info = Gtk.TextView()
  1162.                 self.textbuffer_info = self.textview_info.get_buffer()
  1163.                 self.textview_info.set_editable(False)
  1164.                 self.textview_info.set_cursor_visible(False)
  1165.                 self.textview_info.modify_font(Pango.font_description_from_string('Monospace 9'))
  1166.                 scrolledwindow1.add(self.textview_info)
  1167.                 self.f_info['grid'].attach(scrolledwindow1, 0, 0, 3, 3)
  1168.        
  1169.         def make_audio_codec(self):
  1170.                 #
  1171.                 self.f_3acodec = self.make_frame_ag(3, "  audio codec  " , 6, 8, 8, False)
  1172.                 #
  1173.                 self.box_ac = self.make_comboboxtext(Vars.mp4_acodec)
  1174.                 self.box_ac.set_active(4)
  1175.                 self.f_3acodec['grid'].attach(self.box_ac, 0, 0, 1, 1)
  1176.                 self.box_ac.connect("changed", self.on_codec_audio_changed)
  1177.                 #
  1178.                 self.spin_ac = self.make_spinbut(100 , 80 , 160 , 10 , 1 , 0, True )
  1179.                 self.spin_ac["adj"].connect("value-changed", self.on_audio_clicked)
  1180.                 self.f_3acodec['grid'].attach(self.spin_ac["spinner"], 1, 0, 1, 1)
  1181.                 self.spin_ac['spinner'].set_tooltip_text(Tips.faac_q_str)
  1182.                 #
  1183.                 label = self.make_label('sample: ')
  1184.                 self.f_3acodec['grid'].attach(label, 3, 0, 1, 1)
  1185.                 self.box_audio_rate = self.make_comboboxtext(Vars.audio_sample)
  1186.                 self.box_audio_rate.set_tooltip_text(Tips.audio_samp_str)
  1187.                 self.box_audio_rate.connect("changed", self.on_codec_audio_changed)
  1188.                 self.f_3acodec['grid'].attach(self.box_audio_rate, 4, 0, 1, 1)
  1189.                 #
  1190.                 label = self.make_label('ch: ')
  1191.                 self.f_3acodec['grid'].attach(label, 5, 0, 1, 1)
  1192.                 self.box_audio_ch = self.make_comboboxtext(
  1193.                         [
  1194.                         "2",
  1195.                         "1"
  1196.                         ]
  1197.                         )
  1198.                 self.box_audio_ch.set_tooltip_text(Tips.audio_channels_str)
  1199.                 self.box_audio_ch.connect("changed", self.on_codec_audio_changed)
  1200.                 self.f_3acodec['grid'].attach(self.box_audio_ch, 6, 0, 1, 1)
  1201.                 self.check_prologic = Gtk.CheckButton("prologic2")
  1202.                 self.check_prologic.set_sensitive(False)
  1203.                 self.check_prologic.connect("toggled", self.on_codec_audio_changed)
  1204.                 self.f_3acodec['grid'].attach(self.check_prologic, 7, 0, 1, 1)
  1205.                 self.check_afterb = Gtk.CheckButton("fdk afterburner")
  1206.                 self.check_afterb.set_active(True)
  1207.                 self.check_afterb.set_sensitive(False)
  1208.                 self.check_afterb.connect("toggled", self.on_codec_audio_changed)
  1209.                 self.f_3acodec['grid'].attach(self.check_afterb, 8, 0, 1, 1)
  1210.        
  1211.         def make_video_codec(self):
  1212.                 self.f_3vcodec = self.make_frame_ag(3, "  video codec  " , 6, 8, 8, False)
  1213.                 self.box_vcodec = self.make_comboboxtext(Vars.mp4_vcodec)
  1214.                 self.box_vcodec.set_size_request(180,-1)
  1215.                 self.f_3vcodec['grid'].attach(self.box_vcodec, 0, 0, 1, 1)
  1216.                 self.box_vcodec.connect("changed", self.on_codec_video_changed)
  1217.                 #
  1218.                 self.box_vrc = self.make_comboboxtext(Vars.x264_vrc)
  1219.                 self.box_vrc.set_size_request(180,-1)
  1220.                 self.f_3vcodec['grid'].attach(self.box_vrc, 1, 0, 1, 1)
  1221.                 self.box_vrc.connect("changed", self.on_codec_vrc_changed)
  1222.                 #
  1223.                 self.spin_vc = self.make_spinbut(21.3 , 15 , 40 , 0.1 , 1 , 1, True )
  1224.                 self.spin_vc["adj"].connect("value-changed", self.on_codec_vrc_value_change)
  1225.                 self.f_3vcodec['grid'].attach(self.spin_vc["spinner"], 2, 0, 1, 1)
  1226.                 #
  1227.                 # x265 pools 3 x264 threads
  1228.                 self.check_3v_pool = Gtk.CheckButton("threads/pools 3")
  1229.                 self.check_3v_pool.connect("toggled", self.on_codec_clicked)
  1230.                 self.f_3vcodec['grid'].attach(self.check_3v_pool, 3, 0, 1, 1)
  1231.                 # x26510bit
  1232.                 self.check_3v_10bit = Gtk.CheckButton("x265 10bit")
  1233.                 self.check_3v_10bit.connect("toggled", self.on_codec_clicked)
  1234.                 self.f_3vcodec['grid'].attach(self.check_3v_10bit, 4, 0, 1, 1)
  1235.                 # opencl
  1236.                 self.check_3v_opencl = Gtk.CheckButton("opencl")
  1237.                 self.check_3v_opencl.connect("toggled", self.on_codec_clicked)
  1238.                 self.f_3vcodec['grid'].attach(self.check_3v_opencl, 5, 0, 1, 1)
  1239.                 # x264 preset
  1240.                 self.box_3v_preset = self.make_comboboxtext(Vars.x264_preset)
  1241.                 #self.box_3v_preset.set_active(3)
  1242.                 self.box_3v_preset.set_tooltip_text(Tips.preset_tooltip_str)
  1243.                 self.f_3vcodec['grid'].attach(self.box_3v_preset, 0, 1, 1, 1)
  1244.                 self.box_3v_preset.connect("changed", self.on_preset_changed)
  1245.                 # x264 tune
  1246.                 self.box_3v_tune = self.make_comboboxtext(Vars.x264_tune) # film,animation,grain,stillimage
  1247.                 self.box_3v_tune.set_tooltip_text(Tips.tune_tooltip_str)
  1248.                 self.f_3vcodec['grid'].attach(self.box_3v_tune, 1, 1, 1, 1)
  1249.                 self.box_3v_tune.connect("changed", self.on_preset_changed)
  1250.                 # x264 opts
  1251.                 self.box_3v_x264opts = self.make_comboboxtext(Vars.x264_opt)
  1252.                 self.box_3v_x264opts.set_tooltip_text(Tips.opt_tooltip_str)
  1253.                 self.box_3v_x264opts.set_size_request(180,-1)
  1254.                 self.f_3vcodec['grid'].attach(self.box_3v_x264opts, 2, 1, 1, 1)
  1255.                 self.box_3v_x264opts.connect("changed", self.on_codec_clicked)
  1256.                 #opts custom
  1257.                 self.entry_optscustom = Gtk.Entry()
  1258.                 self.entry_optscustom.set_tooltip_text(Tips.x265_optscustom_str)
  1259.                 self.entry_optscustom.set_text("psnr=1")
  1260.                 self.entry_optscustom.connect("changed", self.on_codec_clicked)
  1261.                 self.f_3vcodec['grid'].attach(self.entry_optscustom, 3, 1, 3, 1)
  1262.                
  1263.                
  1264.        
  1265.         def make_other_opts(self):
  1266.                 #
  1267.                 self.f3_oth = self.make_frame_ag(3, "  other options  " , 6, 8, 8, True)
  1268.                 #
  1269.                 self.check_2pass = Gtk.CheckButton("2 pass")
  1270.                 self.check_2pass.connect("toggled", self.on_f3_other_clicked)
  1271.                 self.f3_oth['grid'].attach(self.check_2pass, 0, 0, 1, 1)
  1272.                 self.check_2pass.set_sensitive(False)
  1273.                 #
  1274.                 self.check_nometa = Gtk.CheckButton("no metatag")
  1275.                 self.check_nometa.set_active(True)
  1276.                 self.check_nometa.connect("toggled", self.on_f3_other_clicked)
  1277.                 self.check_nometa.set_tooltip_text(Tips.nometa_tooltip_srt)
  1278.                 self.f3_oth['grid'].attach(self.check_nometa, 1, 0, 1, 1)
  1279.                 #
  1280.                 #
  1281.                 self.check_scopy = Gtk.CheckButton("sub copy")
  1282.                 self.check_scopy.connect("toggled", self.on_f3_other_clicked)
  1283.                 self.check_scopy.set_tooltip_text(Tips.subcopy_tooltip_srt)
  1284.                 self.f3_oth['grid'].attach(self.check_scopy, 2, 0, 1, 1)
  1285.                 #
  1286.                 self.check_debug = Gtk.CheckButton("debug")
  1287.                 self.check_debug.connect("toggled", self.on_f3_other_clicked)
  1288.                 self.check_debug.set_tooltip_text(Tips.debug_tooltip_srt)
  1289.                 self.f3_oth['grid'].attach(self.check_debug, 4, 0, 1, 1)
  1290.                 #
  1291.                 self.box_oth_container = self.make_comboboxtext(Vars.full_container)
  1292.                 self.box_oth_container.set_tooltip_text(Tips.container_tooltip_srt)
  1293.                 self.box_oth_container.set_active(0)
  1294.                 self.f3_oth['grid'].attach(self.box_oth_container, 5, 0, 1, 1)
  1295.                 self.box_oth_container.connect("changed", self.on_container_changed)
  1296.                
  1297.         def make_run_ffmpeg(self):
  1298.                 self.f3_run = self.make_frame_ag(3, "  execute in terminal  " , 6, 8, 8, True)
  1299.                 #
  1300.                 self.f3_run_indir_label = Gtk.Label("")
  1301.                 self.f3_run['grid'].attach(self.f3_run_indir_label, 0, 0, 1, 1)
  1302.                 self.f3_run_file = Gtk.Label("no input file")
  1303.                 self.f3_run_file.set_tooltip_text('')
  1304.                 self.f3_run['grid'].attach(self.f3_run_file, 1, 0, 2, 1)
  1305.                 self.f3_dur_file = Gtk.Label("")
  1306.                 self.f3_run['grid'].attach(self.f3_dur_file, 3, 0, 1, 1)
  1307.                 #
  1308.                 self.but_f3_run = Gtk.Button(label="RUN")
  1309.                 self.but_f3_run.connect("clicked", self.on_but_f3_run_clicked)
  1310.                 self.but_f3_run.set_sensitive(False)
  1311.                 self.f3_run['grid'].attach(self.but_f3_run, 3, 1, 1, 1)
  1312.                 #
  1313.                 #self.f3_run_outdir_label = Gtk.Label("out dir:  " + os.getcwd())
  1314.                 self.f3_run_outdir_label = Gtk.Label("")
  1315.                 self.f3_run_outdir_label.set_markup("<b>out dir:  </b>" + os.getcwd())
  1316.                 self.f3_run['grid'].attach(self.f3_run_outdir_label, 0, 1, 2, 1)
  1317.                 # filechooserbutton
  1318.                 self.but_folder = Gtk.Button("Choose out dir")
  1319.                 self.but_folder.set_tooltip_text(Tips.out_dir_tooltip_str)
  1320.                 self.but_folder.connect("clicked", self.on_folder_clicked)
  1321.                 self.f3_run['grid'].attach(self.but_folder, 2, 1, 1, 1)
  1322.                 #
  1323.                 self.reportdata = Gtk.Label('')
  1324.                 self.f3_run['grid'].attach(self.reportdata, 0, 3, 4, 1)
  1325.                
  1326.                
  1327.         # event handlers -----------------------------------------------
  1328.        
  1329.         def on_window_destroy(self, *args):
  1330.                 Gtk.main_quit(*args)
  1331.        
  1332.         def on_scale_clicked(self, button):
  1333.                 customscale_in = ""
  1334.                 customscale_in = self.entry_scalecustom.get_chars(0, -1)
  1335.                 if customscale_in != "":
  1336.                         Vars.scalestr = customscale_in
  1337.                         self.outfilter()
  1338.                 elif (self.box1['cbox'].get_active() != 0):
  1339.                         self.scale_calc()
  1340.                 else:
  1341.                         Vars.scalestr = ""
  1342.                         self.outfilter()
  1343.                  
  1344.         def on_deint_clicked(self, button):
  1345.                 Vars.deint_str = ""
  1346.                 if self.checkdeint.get_active():
  1347.                         deint_val = self.box_deint['cbox'].get_active()
  1348.                         if (deint_val == 0):
  1349.                                 Vars.deint_str = "yadif"
  1350.                         elif (deint_val == 1):
  1351.                                 Vars.deint_str = "pp=lb"
  1352.                         elif (deint_val == 2):
  1353.                                 Vars.deint_str = "idet"
  1354.                 self.outfilter()
  1355.                        
  1356.         def on_dn_clicked(self, button):
  1357.                 Vars.dn_str = ""
  1358.                 if self.checkdn.get_active():
  1359.                         dn_val = int( self.spindn['adj'].get_value() )
  1360.                         Vars.dn_str = "hqdn3d=" + str(dn_val)
  1361.                 self.outfilter()
  1362.                
  1363.         def on_uns_clicked(self, button):
  1364.                 Vars.uns_str = ""
  1365.                 if self.checkuns.get_active():
  1366.                         luma = self.spinunsl['adj'].get_value()
  1367.                         chroma = self.spinunsc['adj'].get_value()
  1368.                         Vars.uns_str = "unsharp=5:5:" + "{0:0.2f}".format(luma) + ":5:5:" + "{0:0.2f}".format(chroma)
  1369.                 self.outfilter()
  1370.                        
  1371.         def on_fr_clicked(self, button):
  1372.                 Vars.fr_str = ""
  1373.                 if self.checkfr.get_active():
  1374.                         fr_val = self.spinfr['adj'].get_value()
  1375.                         Vars.fr_str = "-r " + "{0:0.2f}".format(fr_val)
  1376.                 self.outfilter()
  1377.                    
  1378.         def on_crop_clicked(self, button):
  1379.                 ok = 0
  1380.                 Vars.crop_str = ""
  1381.                 if self.checkcr.get_active():
  1382.                         ok = 1
  1383.                 if ok:
  1384.                         inW = int(self.spincw['adj'].get_value())
  1385.                         inH = int(self.spinch['adj'].get_value())
  1386.                         crT = int(self.spinct['adj'].get_value())
  1387.                         crB = int(self.spincb['adj'].get_value())
  1388.                         crL = int(self.spincl['adj'].get_value())
  1389.                         crR = int(self.spincr['adj'].get_value())      
  1390.                         finW = inW - crL - crR
  1391.                         finH = inH - crT - crB
  1392.                         if ( (finW < 100) or (finH < 100) ):
  1393.                                 Vars.crop_str = ""
  1394.                         else:
  1395.                                 Vars.crop_str = "crop=" + str(finW) + ":" \
  1396.                                  + str(finH) + ":" \
  1397.                                  + str(crL)  + ":" \
  1398.                                  + str(crT)
  1399.                 if (self.box2['cbox'].get_active() != 2):
  1400.                         self.outfilter()
  1401.                 else:
  1402.                         self.on_scale_clicked(button)
  1403.                
  1404.         def on_but_file(self,button):
  1405.                 if Vars.ENCODING:
  1406.                                 return
  1407.                 dialog = Gtk.FileChooserDialog("Please choose a file", self.window,
  1408.                 Gtk.FileChooserAction.OPEN,
  1409.                 ("_Cancel", Gtk.ResponseType.CANCEL,
  1410.                 "_Open", Gtk.ResponseType.OK))
  1411.                 #
  1412.                 filter = Gtk.FileFilter()
  1413.                 filter.set_name("Video")
  1414.                 filter.add_mime_type("video/x-matroska")
  1415.                 filter.add_mime_type("video/mp4")
  1416.                 filter.add_mime_type("video/x-flv")
  1417.                 filter.add_mime_type("video/avi")
  1418.                 filter.add_mime_type("video/mpg")
  1419.                 filter.add_mime_type("video/mpeg")
  1420.                 filter.add_mime_type("video/x-ms-wmv")
  1421.                 filter.add_mime_type("video/webm")
  1422.                 filter.add_mime_type("video/ogg")
  1423.                 filter.add_mime_type("video/quicktime")
  1424.                 dialog.add_filter(filter)
  1425.                 #
  1426.                 dialog.set_current_folder(Vars.indir)
  1427.                 response = dialog.run()
  1428.                 if response == Gtk.ResponseType.OK:
  1429.                         Vars.filename = dialog.get_filename()
  1430.                         self.file_changed()
  1431.                 dialog.destroy()
  1432.  
  1433.         def file_changed(self):
  1434.                
  1435.                 def reduce_string(the_string, left_part, right_part):
  1436.                         a = the_string[:left_part]
  1437.                         b = '...'
  1438.                         c = the_string[-right_part:]
  1439.                         rlabel = a + b + c
  1440.                         return rlabel
  1441.                
  1442.                 self.butplay.set_sensitive(True) # low part ---------
  1443.                 self.butprobe.set_sensitive(True)
  1444.                 self.preview_logic() # test and testsplit
  1445.                 self.check_time.set_active(False)
  1446.                 self.butcrode.set_sensitive(True) # crop ----------
  1447.                 self.spinct['adj'].set_value(0)
  1448.                 self.spincb['adj'].set_value(0)
  1449.                 self.spincl['adj'].set_value(0)
  1450.                 self.spincr['adj'].set_value(0)                
  1451.                 self.but_volume_det.set_sensitive(True) # volume detect
  1452.                 Vars.VOLDT_DONE = False
  1453.                 #self.but_volume_det.set_label("Volume detect")
  1454.                 self.label_meanvol.set_label("")
  1455.                 self.label_maxvol.set_label("")
  1456.                 self.check_vol.set_active(False) #volume
  1457.                 self.spin_db["adj"].set_value(0)
  1458.                 # framesdet
  1459.                 Vars.FRAMDT_DONE = False
  1460.                 self.but_frames_det.set_sensitive(True)
  1461.                 self.label_framesdet.set_label("N/A")
  1462.                 self.label_time2frame.set_label('')
  1463.                 #
  1464.                 self.check_drc.set_active(False) #drc
  1465.                 self.check_drc.set_sensitive(False)
  1466.                 self.spin_drc["adj"].set_value(1)
  1467.                 self.spin_drc["spinner"].set_sensitive(False)
  1468.                 Vars.ac3_drc = ""
  1469.                 self.compand_test.set_sensitive(True) #compand test
  1470.                 self.compand_volume.set_sensitive(True)
  1471.                 if self.check_compand.get_active():
  1472.                         self.check_compand.set_active(False)
  1473.                 self.dynaudnorm_test.set_sensitive(True) #dynaudnorm test
  1474.                 self.dynaudnorm_volume.set_sensitive(True)
  1475.                 if self.check_dynaudnorm.get_active():
  1476.                         self.check_dynaudnorm.set_active(False)
  1477.                 self.but_black_det.set_sensitive(True) # black  detect
  1478.                 self.but_black_det.set_label("Black detect")
  1479.                 self.textbuffer.set_text(Tips.black_dt_init_str)
  1480.                 self.progressbar_black_det.set_fraction(0.0)
  1481.                 self.check_prologic.set_sensitive(False) #check_prologic
  1482.                 self.check_prologic.set_active(False)
  1483.                 self.but_f3_run.set_sensitive(True) # ffmpeg run
  1484.                 Vars.BLACKDT_DONE = False
  1485.                 #
  1486.                 command = "clear" + "\n"
  1487.                 length = len(command)
  1488.                 self.terminal.feed_child(command, length)
  1489.                 Vars.dirname = os.path.dirname(Vars.filename)
  1490.                 Vars.basename = os.path.basename(Vars.filename)
  1491.                 Vars.indir = os.path.dirname(Vars.filename)
  1492.                 #out same as in
  1493.                 Vars.outdir = Vars.indir
  1494.                 command = "cd " + "\"" + Vars.outdir + "\"" + "\n"
  1495.                 length = len(command)
  1496.                 self.terminal.feed_child(command, length)
  1497.                 # label outdir
  1498.                 if len(Vars.outdir) > 24:
  1499.                         self.f3_run_outdir_label.set_markup("<b>out dir:  </b>" + reduce_string(Vars.outdir, 12, 14))
  1500.                 else:
  1501.                         self.f3_run_outdir_label.set_markup("<b>out dir:  </b>" + Vars.outdir)
  1502.                 #
  1503.                 self.check_out_file()
  1504.                 # label indir
  1505.                 if len(Vars.dirname) > 30:
  1506.                         self.f3_run_indir_label.set_label(reduce_string(Vars.dirname, 15, 12))
  1507.                 else:
  1508.                         self.f3_run_indir_label.set_label(Vars.dirname)
  1509.                 self.f3_run_indir_label.set_tooltip_text(Vars.dirname)
  1510.                 # label filename
  1511.                 if (len(Vars.basename) > 45):
  1512.                         self.f3_run_file.set_label(reduce_string(Vars.basename, 36, 4))
  1513.                 else:
  1514.                         self.f3_run_file.set_label(Vars.basename)
  1515.                 # label button openfile
  1516.                 if (len(Vars.basename) > 36):
  1517.                         self.but_file.set_label(Vars.basename[0:33] + '...')
  1518.                 else:
  1519.                         self.but_file.set_label(Vars.basename)
  1520.                 #
  1521.                 self.but_f3_run.set_tooltip_text("")
  1522.                 self.reportdata.set_text('')
  1523.                 command = [Vars.ffprobe_ex, '-show_format', '-show_streams', '-pretty', '-loglevel', 'quiet', Vars.filename]
  1524.                 p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  1525.                 out, err =  p.communicate()
  1526.                 out = out.decode() # python3
  1527.                 self.get_info(out)
  1528.  
  1529.         def get_info(self, out):
  1530.                
  1531.                 def form_to_3(in_str):
  1532.                         '''
  1533.                        bitrate and size info formatting
  1534.                        '''
  1535.                         a = in_str.split(' ')[0]
  1536.                        
  1537.                         if len(in_str.split(' ')) == 2:
  1538.                                 b = in_str.split(' ')[1]
  1539.                                 a = float(a)
  1540.                                 result = "{0:.3f}".format(a ) + " " + b
  1541.                         else:
  1542.                                 result = 'N/A'
  1543.                         return result
  1544.                
  1545.                
  1546.                 def set_w_h_video_scale():
  1547.                         self.spincw['adj'].set_value(float(Vars.video_width)) #mettere decimali se no non si vede
  1548.                         self.spincw['spinner'].set_sensitive(False)
  1549.                         self.spinch['adj'].set_value(float(Vars.video_height)) #mettere decimali se no non si vede
  1550.                         self.spinch['spinner'].set_sensitive(False)
  1551.                         if Vars.add_1_1_dar:
  1552.                                 self.box2['list'].append(["as input"])
  1553.                         Vars.add_1_1_dar = False        
  1554.                
  1555.                 def set_dar_in(info):
  1556.                         try:
  1557.                                 darw = info.split(':')[0]
  1558.                                 darh = info.split(':')[1]
  1559.                                 darw = int(darw)
  1560.                                 darh = int(darh)
  1561.                                 if darh > 0 and darw > 0:
  1562.                                         darin = float(darw)/darh
  1563.                                         Vars.darin = "{0:.3f}".format(darin)
  1564.                                 else:
  1565.                                         darin = float(Vars.video_width)/float(Vars.video_height)
  1566.                                         Vars.darin = "{0:.3f}".format(darin)
  1567.                         except:
  1568.                                 darin = float(Vars.video_width)/float(Vars.video_height)
  1569.                                 Vars.darin = "{0:.3f}".format(darin)
  1570.                
  1571.  
  1572.                 #x Vars.info_str
  1573.                 Vars.info_str = ""
  1574.                 is_stream = 0
  1575.                 is_format = 0
  1576.                 is_video = 0
  1577.                 for line in out.split('\n'):
  1578.                         line = line.strip()
  1579.                         if line.startswith('[STREAM]'):
  1580.                                 Vars.info_str = Vars.info_str + "STREAM "
  1581.                                 is_stream = 1
  1582.                         elif line.startswith('[/STREAM]'):
  1583.                                 Vars.info_str = Vars.info_str + "\n"
  1584.                                 is_stream = 0
  1585.                         elif (line.startswith('index=') and (is_stream == 1)):
  1586.                                 s = line
  1587.                                 info = s.split('=')[1]  
  1588.                                 Vars.info_str = Vars.info_str + info + ": "
  1589.                         elif (line.startswith('codec_name=') and (is_stream == 1)):
  1590.                                 s = line
  1591.                                 info = s.split('=')[1]
  1592.                                 if info == 'ac3':
  1593.                                         self.check_drc.set_sensitive(True)
  1594.                                         self.spin_drc["spinner"].set_sensitive(True)
  1595.                                 Vars.info_str = Vars.info_str + info + "  "
  1596.                         elif (line.startswith('profile=') and (is_stream == 1)):
  1597.                                 s = line
  1598.                                 info = s.split('=')[1]  
  1599.                                 Vars.info_str = Vars.info_str + "profile=" +info + "  "
  1600.                         elif (line.startswith('codec_type=') and (is_stream == 1)):
  1601.                                 s = line
  1602.                                 info = s.split('=')[1]
  1603.                                 if info == 'video':
  1604.                                         is_video = 1
  1605.                                 else:
  1606.                                         is_video = 0
  1607.                                 Vars.info_str = Vars.info_str + info + "  "
  1608.                         elif (line.startswith('width=') and (is_stream == 1)):
  1609.                                 s = line
  1610.                                 info = s.split('=')[1]
  1611.                                 if is_video:
  1612.                                         Vars.video_width = info
  1613.                                         Vars.info_str = Vars.info_str + info + "x"
  1614.                         elif (line.startswith('height=') and (is_stream == 1)):
  1615.                                 s = line
  1616.                                 info = s.split('=')[1]
  1617.                                 if is_video:
  1618.                                         Vars.video_height = info
  1619.                                         Vars.info_str = Vars.info_str + info + "  "
  1620.                         elif (line.startswith('sample_aspect_ratio=') and (is_stream == 1)):
  1621.                                 s = line
  1622.                                 if is_video:
  1623.                                         info = s.split('=')[1]  
  1624.                                         Vars.info_str = Vars.info_str + "SAR=" + info + "  "
  1625.                         elif (line.startswith('display_aspect_ratio=') and (is_stream == 1)):
  1626.                                 s = line
  1627.                                 if is_video:
  1628.                                         info = s.split('=')[1]  
  1629.                                         Vars.info_str = Vars.info_str + "DAR=" + info + "  "
  1630.                                         set_dar_in(info)
  1631.                         elif (line.startswith('pix_fmt=') and (is_stream == 1)):
  1632.                                 s = line
  1633.                                 if is_video:
  1634.                                         info = s.split('=')[1]  
  1635.                                         Vars.info_str = Vars.info_str + info + "  "
  1636.                         elif (line.startswith('sample_rate=') and (is_stream == 1)):
  1637.                                 s = line
  1638.                                 info = s.split('=')[1]
  1639.                                 info = form_to_3(info)
  1640.                                 Vars.info_str = Vars.info_str + "samplerate=" + info + "  "
  1641.                         elif (line.startswith('channels=') and (is_stream == 1)):
  1642.                                 s = line
  1643.                                 info = s.split('=')[1]
  1644.                                 Vars.audio_channels = int(info)
  1645.                                 Vars.info_str = Vars.info_str + "channels=" + info + "  "
  1646.                                 if Vars.audio_channels == 6:
  1647.                                         self.check_prologic.set_sensitive(True)
  1648.                                         self.check_prologic.set_active(True)
  1649.                         elif (line.startswith('r_frame_rate=') and (is_stream == 1)):
  1650.                                 if is_video:
  1651.                                         s = line
  1652.                                         info = s.split('=')[1]
  1653.                                         a = info.split('/')[0]
  1654.                                         b = info.split('/')[1]
  1655.                                         a = float(a)
  1656.                                         b = float(b)
  1657.                                         if ((a > 0) and (b > 0)):
  1658.                                                 c = float(a)/float(b)
  1659.                                                 Vars.framerate = c
  1660.                                                 info = "{0:0.2f}".format(c)
  1661.                                                 self.spinfr["adj"].set_value(c)
  1662.                                                 Vars.info_str = Vars.info_str + info + " fps  "
  1663.                         elif (line.startswith('bit_rate=') and (is_stream == 1)):
  1664.                                 s = line
  1665.                                 info = s.split('=')[1]
  1666.                                 info = form_to_3(info)
  1667.                                 Vars.info_str = Vars.info_str + "bitrate=" + info + "  "
  1668.                         elif (line.startswith('TAG:language=') and (is_stream == 1)):
  1669.                                 s = line
  1670.                                 info = s.split('=')[1]  
  1671.                                 Vars.info_str = Vars.info_str + "lang=" + info + "  "
  1672.                         elif line.startswith('[FORMAT]'):
  1673.                                 Vars.info_str = Vars.info_str + "FORMAT "
  1674.                                 is_format = 1
  1675.                         elif line.startswith('[/FORMAT]'):
  1676.                                 #Vars.info_str = Vars.info_str + "/n"
  1677.                                 is_format = 0
  1678.                         elif (line.startswith('nb_streams=') and (is_format == 1)):
  1679.                                 s = line
  1680.                                 info = s.split('=')[1]  
  1681.                                 Vars.info_str = Vars.info_str + "streams=" + info + "  "
  1682.                         elif (line.startswith('duration=') and (is_format == 1)):
  1683.                                 s = line
  1684.                                 infoor = s.split('=')[1]        
  1685.                                 info = infoor.split('.')[0]
  1686.                                 Vars.duration_in_sec = self.hms2sec(info)
  1687.                                 Vars.duration = info
  1688.                                 if len (infoor.split('.')) == 2:
  1689.                                         decimal = infoor.split('.')[1][:3]
  1690.                                         info = info + '.' + decimal
  1691.                                         Vars.duration = info
  1692.                                         decimal = float('0.' + decimal)
  1693.                                         Vars.duration_in_sec = Vars.duration_in_sec + decimal
  1694.                                 self.entry_timein.set_text('0')
  1695.                                 self.entry_timeout.set_text(info)
  1696.                                 Vars.info_str = Vars.info_str + "duration=" + info + "  "
  1697.                         elif (line.startswith('size=') and (is_format == 1)):
  1698.                                 s = line
  1699.                                 info = s.split('=')[1]
  1700.                                 info = form_to_3(info)
  1701.                                 Vars.info_str = Vars.info_str + "size=" + info + "  "
  1702.                         elif (line.startswith('bit_rate=') and (is_format == 1)):
  1703.                                 s = line
  1704.                                 info = s.split('=')[1]
  1705.                                 info = form_to_3(info)
  1706.                                 Vars.info_str = Vars.info_str + "bitrate=" + info
  1707.                                
  1708.                 set_w_h_video_scale()
  1709.                 self.f3_dur_file.set_label(Vars.duration)
  1710.                 self.textbuffer_info.set_text(Vars.info_str)
  1711.                 self.f3_run_file.set_tooltip_text(Vars.info_str)
  1712.                 self.check_map.set_tooltip_text(Vars.info_str)
  1713.                 self.check_time.set_tooltip_text(Vars.info_str)
  1714.                 Vars.in_file_size = self.humansize(Vars.filename)
  1715.        
  1716.         def on_butplay_clicked(self, button):
  1717.                 if Vars.ENCODING:
  1718.                         return
  1719.                 command = Vars.ffplay_ex + " -hide_banner" + " \"" + Vars.filename + "\"" +"\n"
  1720.                 length = len(command)
  1721.                 self.terminal.feed_child(command, length)
  1722.                
  1723.         def on_butprobe_clicked(self, button):
  1724.                 if Vars.ENCODING:
  1725.                         return
  1726.                 command = Vars.ffprobe_ex + " \"" + Vars.filename + "\""  + " 2>&1 | grep 'Input\|Duration\|Stream'" + "\n"
  1727.                 length = len(command)
  1728.                 self.terminal.feed_child(command, length)        
  1729.                
  1730.         def on_butcrode_clicked(self, button):
  1731.                 self.butcrode.set_sensitive(False)
  1732.                 if (Vars.time_start == 0):
  1733.                         command = Vars.ffmpeg_ex + " -i " + "\"" + Vars.filename + "\"" + " -ss 60 -t 1 -vf cropdetect -f null - 2>&1 | awk \'/crop/ { print $NF }\' | tail -1"
  1734.                 else:
  1735.                         command = Vars.ffmpeg_ex + " -i " + "\"" + Vars.filename + "\"" + " -ss " + str(Vars.time_start) + " -t 1 -vf cropdetect -f null - 2>&1 | awk \'/crop/ { print $NF }\' | tail -1"
  1736.                 p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
  1737.                 out, err =  p.communicate()
  1738.                 out = out.decode()
  1739.                 for line in out.split('\n'):
  1740.                         line = line.strip()
  1741.                         if "crop=" in line:  
  1742.                                 aa = line.split('crop=', 1)
  1743.                                 aaa = aa[1]
  1744.                                 listdata = aaa.split(':')
  1745.                                 w = listdata[0]
  1746.                                 h = listdata[1]
  1747.                                 offx = listdata[2]
  1748.                                 offy = listdata[3]
  1749.                                 ctop = int(offy)
  1750.                                 cbot = int(Vars.video_height) - int(offy) -int(h)
  1751.                                 cleft = int(offx)
  1752.                                 cright = int(Vars.video_width) - int(offx) -int(w)
  1753.                                 self.spinct['adj'].set_value(float(ctop))
  1754.                                 self.spincb['adj'].set_value(float(cbot))
  1755.                                 self.spincl['adj'].set_value(float(cleft))
  1756.                                 self.spincr['adj'].set_value(float(cright))  
  1757.                                 break
  1758.                 self.butcrode.set_sensitive(True)
  1759.                
  1760.         def on_buttest_clicked(self, button):
  1761.                 if Vars.ENCODING:
  1762.                         return
  1763.                 # -map preview: only with none -vf option  
  1764.                 if (Vars.maps_str == ""):
  1765.                         command = Vars.ffplay_ex + " -hide_banner" + " \"" + Vars.filename + "\" " \
  1766.                          + " " + Vars.time_final_str + " " \
  1767.                          + "-vf "  + Vars.filter_test_str + "\n"
  1768.                 else:
  1769.                         command = Vars.ffmpeg_ex + " -i \"" + Vars.filename + "\" " \
  1770.                          + Vars.maps_str  + " " + Vars.time_final_str + " "
  1771.                         if (Vars.filter_test_str != ""):
  1772.                                 command = command + " -vf "  + Vars.filter_test_str
  1773.                         command = command +  " -c copy -f matroska - | ffplay -" + "\n"
  1774.                 length = len(command)
  1775.                 self.terminal.feed_child(command, length)
  1776.                
  1777.         def on_buttestspl_clicked(self, button):
  1778.                 if Vars.ENCODING:
  1779.                         return
  1780.                 command = Vars.ffplay_ex + " -hide_banner" + " \"" + Vars.filename + "\" " \
  1781.                   + " " + Vars.time_final_str + " " \
  1782.                   + " -vf \"split[a][b]; [a]pad=iw:(ih*2)+4:color=888888 [src]; [b]" \
  1783.                   + Vars.filter_test_str + " [filt]; [src][filt]overlay=((main_w - w)/2):main_h/2\"" + "\n"
  1784.                 length = len(command)
  1785.                 self.terminal.feed_child(command, length)
  1786.                
  1787.         def on_butt_vtecopy_clicked(self, widget):
  1788.                 self.terminal.select_all()
  1789.                 self.terminal.copy_clipboard()
  1790.                 try: # only vte2.9
  1791.                         self.terminal.select_none()
  1792.                 except:
  1793.                         return
  1794.        
  1795.         def on_but_volume_det_clicked(self, button):
  1796.                
  1797.                 def set_other_butt(boolean):
  1798.                         if Vars.FRAMDT_DONE != True:
  1799.                                 self.but_frames_det.set_sensitive(boolean)
  1800.                         if Vars.BLACKDT_DONE != True:
  1801.                                 self.but_black_det.set_sensitive(boolean)
  1802.  
  1803.                 def finish_voldet(meanv, maxv, max_vol_det):
  1804.                         self.voldet_spin.stop()
  1805.                         self.voldet_spin.set_sensitive(False)
  1806.                         self.but_volume_det.set_label("Volume detect")
  1807.                         set_other_butt(True)
  1808.                         self.label_meanvol.set_label(meanv)
  1809.                         self.label_maxvol.set_label(maxv)
  1810.                         max_vol_det = max_vol_det.split(' ')[1]
  1811.                         volgain = float(max_vol_det) + 0.9
  1812.                         if volgain < -0.75:
  1813.                                 volgain=abs(volgain)
  1814.                                 volgain=float(volgain)
  1815.                                 self.spin_db["adj"].set_value(volgain)
  1816.  
  1817.                        
  1818.                 def my_thread_voldet():
  1819.                         command = [Vars.ffmpeg_ex, '-i', Vars.filename, '-vn', '-af', 'volumedetect', '-f', 'null', '/dev/null']
  1820.                         p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
  1821.                         GLib.idle_add(self.but_volume_det.set_label, "Wait")
  1822.                         GLib.idle_add(set_other_butt, False)
  1823.                         time.sleep(0.02)
  1824.                         while True:
  1825.                                 line = p.stderr.read()
  1826.                                 if not line:
  1827.                                         break
  1828.                                 out = line.decode()
  1829.                                 for line in out.split('\n'):
  1830.                                         line = line.strip()
  1831.                                         if "mean_volume:" in line:  
  1832.                                                 aa = line.split('mean_volume:', 1)
  1833.                                                 mea_vol_det = aa[1]
  1834.                                                 meanv = "Mean vol: " + mea_vol_det
  1835.                                         if "max_volume:" in line:  
  1836.                                                 aa = line.split('max_volume:', 1)
  1837.                                                 max_vol_det = aa[1]
  1838.                                                 maxv = "Max vol: " + max_vol_det
  1839.                         p.communicate()
  1840.                         GLib.idle_add(finish_voldet, meanv, maxv, max_vol_det)
  1841.                         time.sleep(0.1)
  1842.                
  1843.                 if Vars.VOLDT_DONE:
  1844.                         return
  1845.                 Vars.VOLDT_DONE = True
  1846.                 self.voldet_spin.set_sensitive(True)
  1847.                 self.voldet_spin.start()
  1848.                 thread=threading.Thread(target=my_thread_voldet)
  1849.                 thread.daemon = True
  1850.                 thread.start()
  1851.                
  1852.                
  1853.         def on_but_frames_det_clicked(self, button):
  1854.                        
  1855.                 def finish_framesdet(frames):
  1856.                         self.label_framesdet.set_label(frames)
  1857.                         self.framesdet_spin.stop()
  1858.                         self.framesdet_spin.set_sensitive(False)
  1859.                         self.but_frames_det.set_label("Total frames detect")
  1860.                         set_other_butt(True)
  1861.  
  1862.                 def set_other_butt(boolean):
  1863.                         if Vars.VOLDT_DONE != True:
  1864.                                 self.but_volume_det.set_sensitive(boolean)
  1865.                         if Vars.BLACKDT_DONE != True:
  1866.                                 self.but_black_det.set_sensitive(boolean)
  1867.  
  1868.                 def my_thread_framedet():
  1869.                         #ffprobe2 -show_packets  ac3-sd.mkv  2>/dev/null | grep video | wc -l
  1870.                         command = Vars.ffprobe_ex + " -show_packets  \"" + Vars.filename + "\" 2>/dev/null | grep video | wc -l"
  1871.                         p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
  1872.                         GLib.idle_add(self.but_frames_det.set_label, "Wait")
  1873.                         GLib.idle_add(set_other_butt, False)
  1874.                         time.sleep(0.02)
  1875.                         while True:
  1876.                                 line = p.stdout.read()
  1877.                                 if not line:
  1878.                                         break
  1879.                                 out = line.decode()
  1880.                                 for line in out.split('\n'):
  1881.                                         if line != "":
  1882.                                                 line = line.strip()
  1883.                                                 frames = line
  1884.                         p.communicate()
  1885.                         GLib.idle_add(finish_framesdet, frames)
  1886.                         time.sleep(0.3)
  1887.                
  1888.                 if Vars.FRAMDT_DONE:
  1889.                         return
  1890.                 Vars.FRAMDT_DONE = True
  1891.                 self.framesdet_spin.set_sensitive(True)
  1892.                 self.framesdet_spin.start()    
  1893.                 thread=threading.Thread(target=my_thread_framedet)
  1894.                 thread.daemon = True
  1895.                 thread.start()
  1896.  
  1897.         def on_time2frame_clicked(self, button):
  1898.                 timein_ent = self.entry_time2frame.get_chars(0, -1)
  1899.                 if (timein_ent != ""):                  
  1900.                         if self.is_number(timein_ent):
  1901.                                 timein = float(timein_ent.split('.')[0])
  1902.                                 if len (timein_ent.split('.')) == 2:
  1903.                                         decimal = timein_ent.split('.')[1][:3]
  1904.                                         decimal = float('0.' + decimal)
  1905.                                         timein = timein + decimal
  1906.                                 if Vars.duration_in_sec != 0:
  1907.                                         if timein > Vars.duration_in_sec:
  1908.                                                 self.entry_timein.set_text(str(Vars.duration_in_sec -1))
  1909.                                                 return
  1910.                         else:  
  1911.                                 timein = float(self.hms2sec(timein_ent.split('.')[0]))
  1912.                                 if len (timein_ent.split('.')) == 2:
  1913.                                         decimal = timein_ent.split('.')[1][:3]
  1914.                                         decimal = float('0.' + decimal)
  1915.                                         timein = timein + decimal
  1916.                                 if Vars.duration_in_sec != 0:
  1917.                                         if timein > Vars.duration_in_sec:
  1918.                                                 self.entry_timein.set_text(str(self.sec2hms(Vars.duration_in_sec -1)))
  1919.                                                 return
  1920.                         t2frames = int(round(float(timein)*Vars.framerate))
  1921.                         self.label_time2frame.set_label(str(t2frames))
  1922.  
  1923.         def on_volume_clicked(self, button):
  1924.                 ratio = 1
  1925.                 self.label_ratio_val.set_label("1")
  1926.                 Vars.final_af_str = ""
  1927.                 db = self.spin_db["adj"].get_value()
  1928.                 if (db != 0.00):
  1929.                         ratio = pow(10, (db/20.0))
  1930.                         ratio = float("{0:.3f}".format(ratio))    
  1931.                         self.label_ratio_val.set_label(str(ratio))
  1932.                         if self.check_vol.get_active():
  1933.                                 Vars.final_af_str = "volume=" + str(ratio)
  1934.                         else:
  1935.                                 Vars.final_af_str = ""
  1936.                 self.make_p3_out_command()
  1937.  
  1938.         def on_drc_clicked(self, buttom):
  1939.                 Vars.ac3_drc = ""
  1940.                 if self.check_drc.get_active():
  1941.                         val = self.spin_drc["adj"].get_value()
  1942.                         Vars.ac3_drc = "-drc_scale " + str(int(val))
  1943.                        
  1944.         def on_compand_reset(self, button):
  1945.                 self.entry_compand.set_text(Vars.compinit)
  1946.                 self.on_compand_clicked(button)
  1947.  
  1948.         def on_compand_clicked(self, button):
  1949.                 Vars.compand_data = ""
  1950.                 if self.check_compand.get_active():
  1951.                         if self.check_dynaudnorm.get_active():
  1952.                                 self.check_dynaudnorm.set_active(False)
  1953.                         compand_data = self.entry_compand.get_chars(0, -1)
  1954.                         if Vars.audio_channels == 6:
  1955.                                 Vars.compand_data = "aformat=channel_layouts=stereo,aresample=matrix_encoding=dplii,compand=" + compand_data
  1956.                         else:
  1957.                                 Vars.compand_data = "aformat=channel_layouts=stereo,compand=" + compand_data
  1958.                 self.make_p3_out_command()
  1959.  
  1960.         def on_compand_test(self, button):
  1961.                 if Vars.compand_data != "":
  1962.                         command = Vars.ffplay_ex + " -hide_banner" + " -f lavfi \'amovie=" + Vars.filename + " :sp=" + str(Vars.time_start) + " , " + Vars.compand_data + "  ,ebur128=video=1:meter=18:peak=true [out0][out1]\'" + "\n"
  1963.                 else:
  1964.                         command = Vars.ffplay_ex + " -hide_banner" + " -f lavfi \'amovie=" + Vars.filename + " :sp=" + str(Vars.time_start) + "  ,ebur128=video=1:meter=18:peak=true [out0][out1]\'" + "\n"
  1965.                 length = len(command)
  1966.                 self.terminal.feed_child(command, length)
  1967.  
  1968.         def on_compand_volume(self, button):
  1969.                 if Vars.compand_data != "":                    
  1970.                         command = \
  1971.                         Vars.ffplay_ex + " -hide_banner" + " -f lavfi \'movie=" + Vars.filename + ":sp=" + str(Vars.time_start) + "[vid];"\
  1972.                         + "amovie=" + Vars.filename + ":sp=" + str(Vars.time_start) + "[aud];"\
  1973.                         + "[aud]asplit=[2][3];"\
  1974.                         + "[2]aformat=channel_layouts=stereo,showvolume=h=20:t=0[volin];"\
  1975.                         + "[3]" + Vars.compand_data + ",asplit[c2][out1];"\
  1976.                         + "[c2]showvolume=h=40[volout];"\
  1977.                         + "[vid][volin]overlay=6:6[int1];"\
  1978.                         + "[int1][volout]overlay=6:56,setdar=" + Vars.darin + "[out]\'"\
  1979.                         + " -window_title \"compand test, volume in,out\"" + "\n"
  1980.                 else:
  1981.                         command = Vars.ffplay_ex + " -hide_banner" + " -f lavfi \'movie=" + Vars.filename + ":sp=" + str(Vars.time_start)\
  1982.                         + "[vid];amovie=" + Vars.filename + ":sp=" + str(Vars.time_start) + "[aud];"\
  1983.                         + "[aud]aformat=channel_layouts=stereo,"\
  1984.                         + "asplit[out1][2] ; [2]showvolume=h=60[3]; [vid][3]overlay=6:6,setdar=" + Vars.darin + "[out]\'"\
  1985.                         + " -window_title \"input volume\"" + "\n"
  1986.                 length = len(command)
  1987.                 self.terminal.feed_child(command, length)
  1988.                
  1989.         def on_dynaudnorm_reset(self, button):
  1990.                 self.entry_dynaudnorm.set_text(Vars.dynaudnorm)
  1991.                 self.on_dynaudnorm_clicked(button)
  1992.  
  1993.         def on_dynaudnorm_clicked(self, button):
  1994.                 Vars.dynaudnorm_data = ""
  1995.                 if self.check_dynaudnorm.get_active():
  1996.                         if self.check_compand.get_active():
  1997.                                 self.check_compand.set_active(False)
  1998.                         dynaudnorm_data = self.entry_dynaudnorm.get_chars(0, -1)
  1999.                         if Vars.audio_channels == 6:
  2000.                                 Vars.dynaudnorm_data = "aformat=channel_layouts=stereo,aresample=matrix_encoding=dplii,dynaudnorm=" + dynaudnorm_data
  2001.                         else:
  2002.                                 Vars.dynaudnorm_data = "aformat=channel_layouts=stereo,dynaudnorm=" + dynaudnorm_data
  2003.                 self.make_p3_out_command()
  2004.  
  2005.         def on_dynaudnorm_test(self, button):
  2006.                 if Vars.dynaudnorm_data != "":
  2007.                         command = Vars.ffplay_ex + " -hide_banner" + " -f lavfi \'amovie=" + Vars.filename + " :sp=" + str(Vars.time_start) + " , " + Vars.dynaudnorm_data + "  ,ebur128=video=1:meter=18:peak=true [out0][out1]\'" + "\n"
  2008.                 else:
  2009.                         command = Vars.ffplay_ex + " -hide_banner" + " -f lavfi \'amovie=" + Vars.filename + " :sp=" + str(Vars.time_start) + "  ,ebur128=video=1:meter=18:peak=true [out0][out1]\'" + "\n"
  2010.                 length = len(command)
  2011.                 self.terminal.feed_child(command, length)
  2012.  
  2013.         def on_dynaudnorm_volume(self, button):
  2014.                 if Vars.dynaudnorm_data != "":
  2015.                         command = Vars.ffplay_ex + " -hide_banner" + " -f lavfi \'movie=" + Vars.filename + ":sp=" + str(Vars.time_start)\
  2016.                         + "[vid];amovie=" + Vars.filename + ":sp=" + str(Vars.time_start) + "[aud];"\
  2017.                         + "[aud]" + Vars.dynaudnorm_data \
  2018.                         + ", asplit[out1][2];"\
  2019.                         + "[2]showvolume=h=15:w=240:f=120:r=15:t=0,"\
  2020.                         + "drawgrid=width=15:height=30:thickness=2:color=white@0.2,crop=225:31:0:0[3];"\
  2021.                         + "[vid][3]overlay=6:6:format=yuv420,setdar=" + Vars.darin +"[out]\'"\
  2022.                         + " -window_title \"dynaudnorm test, volume out\"" + "\n"
  2023.                 else:
  2024.                         command = Vars.ffplay_ex + " -hide_banner" + " -f lavfi \'movie=" + Vars.filename + ":sp=" + str(Vars.time_start)\
  2025.                         + "[vid];amovie=" + Vars.filename + ":sp=" + str(Vars.time_start) + "[aud];"\
  2026.                         + "[aud]aformat=channel_layouts=stereo,"\
  2027.                         + "asplit[out1][2] ; [2]showvolume=h=60[3]; [vid][3]overlay=6:6,setdar=" + Vars.darin +"[out]\'"\
  2028.                         + " -window_title \"input volume\"" + "\n"
  2029.                 length = len(command)
  2030.                 self.terminal.feed_child(command, length)
  2031.  
  2032.         def on_map_clicked(self, button):
  2033.                 self.map_label.set_label("")
  2034.                 Vars.maps_str = ""
  2035.                 if self.check_map.get_active():
  2036.                         map_in = self.entry_map.get_chars(0, -1)
  2037.                         if (map_in != ""):
  2038.                                 map_l = map_in.split(",")
  2039.                                 for i in range(len(map_l)):
  2040.                                         if Vars.maps_str == "":
  2041.                                                 Vars.maps_str = Vars.maps_str + "-map " + map_l[i]
  2042.                                         else:
  2043.                                                 Vars.maps_str = Vars.maps_str + " -map " + map_l[i]
  2044.                                 self.map_label.set_label(Vars.maps_str)
  2045.                 self.outfilter()
  2046.                 self.make_p3_out_command()
  2047.  
  2048.         def on_time_clicked(self, button):
  2049.                 Vars.time_final_str = ""
  2050.                 Vars.time_start = 0
  2051.                 if self.check_time.get_active():
  2052.                         timein = 0
  2053.                         timeout = 0
  2054.                         timedur = 0
  2055.                         timein_ent = self.entry_timein.get_chars(0, -1)
  2056.                         if (timein_ent != ""):
  2057.                                 if self.is_number(timein_ent):
  2058.                                         timein = float(timein_ent.split('.')[0])
  2059.                                         if len (timein_ent.split('.')) == 2:
  2060.                                                 decimal = timein_ent.split('.')[1][:3]
  2061.                                                 decimal = float('0.' + decimal)
  2062.                                                 timein = timein + decimal
  2063.                                         if Vars.duration_in_sec != 0:
  2064.                                                 if timein > Vars.duration_in_sec:
  2065.                                                         self.entry_timein.set_text(str(Vars.duration_in_sec -1))
  2066.                                                         return
  2067.                                 else:  
  2068.                                         timein = float(self.hms2sec(timein_ent.split('.')[0]))
  2069.                                         if len (timein_ent.split('.')) == 2:
  2070.                                                 decimal = timein_ent.split('.')[1][:3]
  2071.                                                 decimal = float('0.' + decimal)
  2072.                                                 timein = timein + decimal
  2073.                                         if Vars.duration_in_sec != 0:
  2074.                                                 if timein > Vars.duration_in_sec:
  2075.                                                         self.entry_timein.set_text(str(self.sec2hms(Vars.duration_in_sec -1)))
  2076.                                                         return
  2077.                         timeout_ent = self.entry_timeout.get_chars(0, -1)
  2078.                         if (timeout_ent != ""):
  2079.                                 if self.is_number(timeout_ent):
  2080.                                         timeout = float(timeout_ent.split('.')[0])
  2081.                                         if len (timeout_ent.split('.')) == 2:
  2082.                                                 decimal = timeout_ent.split('.')[1][:3]
  2083.                                                 decimal = float('0.' + decimal)
  2084.                                                 timeout = timeout + decimal
  2085.                                         if Vars.duration_in_sec != 0:
  2086.                                                 if timeout > Vars.duration_in_sec:
  2087.                                                         self.entry_timeout.set_text(str(Vars.duration_in_sec))
  2088.                                                         return
  2089.                                                 if timeout == Vars.duration_in_sec:
  2090.                                                         timeout = 0
  2091.                                         timedur = timeout - timein
  2092.                                 else:  
  2093.                                         timeout = float(self.hms2sec(timeout_ent.split('.')[0]))
  2094.                                         if len (timeout_ent.split('.')) == 2:
  2095.                                                 decimal = timeout_ent.split('.')[1][:3]
  2096.                                                 decimal = float('0.' + decimal)
  2097.                                                 timeout = timeout + decimal
  2098.                                         if Vars.duration_in_sec != 0:
  2099.                                                 if timeout > Vars.duration_in_sec:
  2100.                                                         self.entry_timeout.set_text(Vars.duration)
  2101.                                                         return
  2102.                                                 if timeout == Vars.duration_in_sec:
  2103.                                                         timeout = 0
  2104.                                         timedur = timeout - timein
  2105.                         if (timein != 0):
  2106.                                 Vars.time_final_str = Vars.time_final_str + " -ss " + str(timein)
  2107.                                 Vars.time_start = timein
  2108.                         if (timedur > 0):
  2109.                                 Vars.time_final_str = Vars.time_final_str + " -t " + str(timedur)
  2110.                 self.time_label.set_text(Vars.time_final_str)
  2111.                 self.outfilter()
  2112.                 self.make_p3_out_command()
  2113.  
  2114.         def on_audio_clicked(self, button):
  2115.                 #audio
  2116.                 Vars.audio_codec_str = self.audio_codec()
  2117.                 self.make_p3_out_command()
  2118.  
  2119.         def on_codec_audio_changed(self, button):
  2120.                
  2121.                 def no_afterburn():
  2122.                         if self.check_afterb.get_sensitive():
  2123.                                 self.check_afterb.set_active(True)
  2124.                                 self.check_afterb.set_sensitive(False)
  2125.                         return
  2126.                
  2127.                 def yes_afterburn():
  2128.                         self.check_afterb.set_sensitive(True)
  2129.                         return
  2130.                
  2131.                 audio_codec = self.box_ac.get_active_text()
  2132.                 self.spin_ac['spinner'].set_sensitive(True)
  2133.                 self.box_audio_ch.set_sensitive(True)
  2134.                 self.box_audio_rate.set_sensitive(True)
  2135.                 if (audio_codec == "libfaac quality (Q)"): # aaq
  2136.                         if Vars.acodec_is != "faaq":
  2137.                                 self.adj_change(self.spin_ac['adj'], 100, 80, 330, 10, 1)
  2138.                                 self.spin_ac['adj'].set_value(100.0)
  2139.                                 self.spin_ac['spinner'].set_tooltip_text(Tips.faac_q_str)
  2140.                         no_afterburn()
  2141.                         Vars.acodec_is = "faaq"
  2142.                 elif (audio_codec == "libfaac ABR (Kb/s)"): # aac faac cbr 64-320 def 112
  2143.                         if Vars.acodec_is != "faacb":
  2144.                                 self.adj_change(self.spin_ac['adj'], 112, 64, 320, 8, 2)
  2145.                                 self.spin_ac['adj'].set_value(112.0)
  2146.                                 self.spin_ac['spinner'].set_tooltip_text(Tips.faac_cbr_str)
  2147.                         no_afterburn()
  2148.                         Vars.acodec_is = "faacb"
  2149.                 elif (audio_codec == "aac_fdk CBR (Kb/s)"): # aac_fdk cbr 64-320 def 128
  2150.                         if Vars.acodec_is != "fdkaac":
  2151.                                 self.adj_change(self.spin_ac['adj'], 128, 64, 320, 8, 2)
  2152.                                 self.spin_ac['adj'].set_value(128.0)
  2153.                                 self.spin_ac['spinner'].set_tooltip_text(Tips.aak_cbr_str)
  2154.                         yes_afterburn()
  2155.                         Vars.acodec_is = "fdkaac"
  2156.                 elif (audio_codec == "lame mp3 CBR (Kb/s)"): # lame cbr 32 - 320 def 128
  2157.                         if Vars.acodec_is != "lame":
  2158.                                 self.adj_change(self.spin_ac['adj'], 128, 32, 320, 8, 2)
  2159.                                 self.spin_ac['adj'].set_value(128.0)
  2160.                                 self.spin_ac['spinner'].set_tooltip_text(Tips.lamecbr_str)
  2161.                         no_afterburn()
  2162.                         Vars.acodec_is = "lame"
  2163.                 elif (audio_codec == "lame mp3 VBR (Q)"): # lame vbr 0 - 9 def 6
  2164.                         if Vars.acodec_is != "lameq":
  2165.                                 self.adj_change(self.spin_ac['adj'], 6, 0, 9, 1, 1)
  2166.                                 self.spin_ac['adj'].set_value(6.0)
  2167.                                 self.spin_ac['spinner'].set_tooltip_text(Tips.lamevbr_str)
  2168.                         no_afterburn()
  2169.                         Vars.acodec_is = "lameq"
  2170.                 elif (audio_codec == "aac native CBR (Kb/s)"): # aac cbr 32 - 320 def 128
  2171.                         if Vars.acodec_is != "aacn":
  2172.                                 self.adj_change(self.spin_ac['adj'], 128, 32, 320, 8, 2)
  2173.                                 self.spin_ac['adj'].set_value(128.0)
  2174.                                 self.spin_ac['spinner'].set_tooltip_text(Tips.aac_cbr_str)
  2175.                         no_afterburn()
  2176.                         Vars.acodec_is = "aacn"
  2177.                 elif (audio_codec == "audio copy"): # copy
  2178.                         self.spin_ac['spinner'].set_sensitive(False)
  2179.                         self.spin_ac['spinner'].set_tooltip_text('')
  2180.                         self.box_audio_ch.set_sensitive(False)
  2181.                         self.box_audio_rate.set_sensitive(False)
  2182.                         no_afterburn()
  2183.                         Vars.acodec_is = "acopy"
  2184.                 elif (audio_codec == "no audio"): # none
  2185.                         self.spin_ac['spinner'].set_sensitive(False)
  2186.                         self.spin_ac['spinner'].set_tooltip_text('')
  2187.                         self.box_audio_ch.set_sensitive(False)
  2188.                         self.box_audio_rate.set_sensitive(False)
  2189.                         no_afterburn()
  2190.                         Vars.acodec_is = "anone"
  2191.                 elif (audio_codec == "aacplus (32 Kb/s)"): # aac+32
  2192.                         if Vars.acodec_is != "aap32":
  2193.                                 self.spin_ac['spinner'].set_sensitive(False)
  2194.                                 self.spin_ac['spinner'].set_tooltip_text('')
  2195.                                 self.box_audio_ch.set_sensitive(False)
  2196.                                 self.box_audio_ch.set_active(0)
  2197.                         no_afterburn()
  2198.                         Vars.acodec_is = "aap32"
  2199.                 elif (audio_codec == "aacplus (64 Kb/s)"): # aac+64
  2200.                         if Vars.acodec_is != "aap64":
  2201.                                 self.spin_ac['spinner'].set_sensitive(False)
  2202.                                 self.spin_ac['spinner'].set_tooltip_text('')
  2203.                                 self.box_audio_ch.set_sensitive(False)
  2204.                                 self.box_audio_ch.set_active(0)
  2205.                         no_afterburn()
  2206.                         Vars.acodec_is = "aap64"
  2207.                 elif (audio_codec == "aac_fdk HE v1 (Kb/s)"): # fkd_he v1
  2208.                         if Vars.acodec_is != "fdkaac_he":
  2209.                                 self.adj_change(self.spin_ac['adj'], 64, 48, 64, 2, 2)
  2210.                                 self.spin_ac['adj'].set_value(64.0)
  2211.                                 self.spin_ac['spinner'].set_tooltip_text(Tips.fdkaac_he_str)
  2212.                                 self.box_audio_ch.set_sensitive(False)
  2213.                                 self.box_audio_ch.set_active(0)
  2214.                         yes_afterburn()
  2215.                         Vars.acodec_is = "fdkaac_he"
  2216.                 elif (audio_codec == "aac_fdk VBR (Q)"): # fdk vbr 1-5
  2217.                         if Vars.acodec_is != "fdkaac_vbr":
  2218.                                 self.adj_change(self.spin_ac['adj'], 2, 1, 5, 1, 1)
  2219.                                 self.spin_ac['adj'].set_value(2.0)
  2220.                                 self.spin_ac['spinner'].set_tooltip_text(Tips.fdkaac_vbr_str)
  2221.                         yes_afterburn()
  2222.                         Vars.acodec_is = "fdkaac_vbr"
  2223.                 self.on_audio_clicked(button)
  2224.  
  2225.         def audio_codec(self):
  2226.                 # channels
  2227.                 audio_codec_str = ""
  2228.                 channel_str = "-ac 2"
  2229.                 channel = self.box_audio_ch.get_active_text()
  2230.                 if channel == "1":
  2231.                         channel_str = "-ac 1"
  2232.                 # sample rate
  2233.                 sample_str = "-ar 48k"
  2234.                 sample = self.box_audio_rate.get_active_text()
  2235.                 if sample == "44100":
  2236.                         sample_str = "-ar 44.1k"
  2237.                 #prologic2
  2238.                 if (Vars.audio_channels == 6) and (self.box_audio_ch.get_active_text() == '2'):
  2239.                         self.check_prologic.set_sensitive(True)
  2240.                 else:
  2241.                         self.check_prologic.set_sensitive(False)
  2242.                 # acodec
  2243.                 def on_afterburner(ac_str):
  2244.                         if (self.check_afterb.get_active() == False):
  2245.                                 ac_str = ac_str + " -afterburner 0 "
  2246.                         return ac_str
  2247.                
  2248.                 if (Vars.acodec_is == "faaq"):
  2249.                         audio_codec_str = "-c:a libfaac -q:a "
  2250.                         quality_faac = self.spin_ac['adj'].get_value()
  2251.                         audio_codec_str = audio_codec_str + str(int(quality_faac)) + " " + sample_str + " " + channel_str
  2252.                 elif (Vars.acodec_is == "faacb"):
  2253.                         audio_codec_str = "-c:a libfaac -b:a "
  2254.                         faacbr = self.spin_ac['adj'].get_value()
  2255.                         audio_codec_str = audio_codec_str + str(int(faacbr)) + "k " + sample_str + " " + channel_str
  2256.                 elif (Vars.acodec_is == "aap64"):
  2257.                         audio_codec_str = "-c:a libaacplus -b:a 64k" + " " + sample_str + " " + channel_str
  2258.                 elif (Vars.acodec_is == "aap32"):
  2259.                         audio_codec_str = "-c:a libaacplus -b:a 32k" + " " + sample_str + " " + channel_str
  2260.                 elif (Vars.acodec_is == "anone"):
  2261.                         audio_codec_str = "-an"
  2262.                         self.check_prologic.set_sensitive(False)
  2263.                 elif (Vars.acodec_is == "acopy"):
  2264.                         audio_codec_str = "-c:a copy"
  2265.                         self.check_prologic.set_sensitive(False)
  2266.                 elif (Vars.acodec_is == "fdkaac"):
  2267.                         audio_codec_str = "-c:a libfdk_aac -b:a "
  2268.                         aakcbr = self.spin_ac['adj'].get_value()
  2269.                         audio_codec_str = audio_codec_str + str(int(aakcbr)) + "k " + sample_str + " " + channel_str
  2270.                         audio_codec_str = on_afterburner(audio_codec_str)              
  2271.                 elif (Vars.acodec_is == "lame"):
  2272.                         audio_codec_str = "-c:a libmp3lame -b:a "
  2273.                         lamecbr = self.spin_ac['adj'].get_value()
  2274.                         audio_codec_str = audio_codec_str + str(int(lamecbr)) + "k " + sample_str + " " + channel_str
  2275.                 elif (Vars.acodec_is == "lameq"):
  2276.                         audio_codec_str = "-c:a libmp3lame -q:a "  
  2277.                         lamevbr = self.spin_ac['adj'].get_value()
  2278.                         audio_codec_str = audio_codec_str + str(int(lamevbr)) + " " + sample_str + " " + channel_str
  2279.                 elif (Vars.acodec_is == "aacn"):
  2280.                         audio_codec_str = "-c:a aac -strict -2 -b:a "
  2281.                         aaccbr = self.spin_ac['adj'].get_value()
  2282.                         audio_codec_str = audio_codec_str + str(int(aaccbr)) + "k " + sample_str + " " + channel_str
  2283.                 elif (Vars.acodec_is == "fdkaac_he"):
  2284.                         audio_codec_str = "-c:a libfdk_aac -profile:a aac_he -b:a "
  2285.                         aakcbr = self.spin_ac['adj'].get_value()
  2286.                         audio_codec_str = audio_codec_str + str(int(aakcbr)) + "k " + sample_str + " " + channel_str
  2287.                         audio_codec_str = on_afterburner(audio_codec_str)
  2288.                 elif (Vars.acodec_is == "fdkaac_vbr"):
  2289.                         audio_codec_str = "-c:a libfdk_aac -vbr "
  2290.                         aakvbr = self.spin_ac['adj'].get_value()
  2291.                         audio_codec_str = audio_codec_str + str(int(aakvbr)) + " " + sample_str + " " + channel_str
  2292.                         audio_codec_str = on_afterburner(audio_codec_str)
  2293.                 return audio_codec_str
  2294.  
  2295.         def on_codec_video_changed(self, button):
  2296.                 self.on_codec_clicked(button)
  2297.  
  2298.         def on_preset_changed(self, button):
  2299.                 self.on_codec_clicked(button)
  2300.  
  2301.         def on_codec_clicked(self, button):
  2302.                 Vars.final_codec_str = ""
  2303.                 # video
  2304.                 video_codec = self.box_vcodec.get_active_text() #0 x264, 1 -vcopy
  2305.                 if (video_codec == "video copy"):
  2306.                         Vars.video_codec_str_more = self.v_codec_vcopy()
  2307.                         Vars.vcodec_is = "vcopy"
  2308.                 elif (video_codec == "mpeg4"): #mpeg4
  2309.                         Vars.video_codec_str_more = self.v_codec_mpeg4()
  2310.                         Vars.vcodec_is = "mpeg4"
  2311.                 elif (video_codec == "libx264"):
  2312.                         #libx264
  2313.                         Vars.video_codec_str_more = self.v_codec_x264()
  2314.                         Vars.vcodec_is = "x264"
  2315.                 elif (video_codec == "libx265"):
  2316.                         #libx264
  2317.                         Vars.video_codec_str_more = self.v_codec_x265()
  2318.                         Vars.vcodec_is = "x265"
  2319.                 elif (video_codec == "no video"):
  2320.                         #-vn
  2321.                         Vars.video_codec_str_more = self.v_codec_vn()
  2322.                         Vars.vcodec_is = "none"
  2323.                 #
  2324.                 self.check_out_file()
  2325.                 self.on_codec_vrc_value_change(button)
  2326.  
  2327.         def on_codec_vrc_changed(self, button):
  2328.                 video_rc = self.box_vrc.get_active_text() #0 crf, 1 kb/s
  2329.                 video_codec = self.box_vcodec.get_active_text()
  2330.                 if (video_rc == 'crf') and (video_codec == "libx265"):
  2331.                         self.adj_change(self.spin_vc['adj'], 28.0, 15, 40, 0.1, 1)
  2332.                         self.spin_vc['adj'].set_value(22.8)
  2333.                         self.check_2pass.set_active(False)
  2334.                         self.check_2pass.set_sensitive(False)
  2335.                         self.check_3v_10bit.set_sensitive(True)
  2336.                         self.check_3v_pool.set_sensitive(True)
  2337.                 elif (video_rc == 'crf') and (video_codec == "libx264"):
  2338.                         self.adj_change(self.spin_vc['adj'], 21.3, 15, 40, 0.1, 1)
  2339.                         self.spin_vc['adj'].set_value(21.3)
  2340.                         self.check_2pass.set_active(False)
  2341.                         self.check_2pass.set_sensitive(False)
  2342.                         self.check_3v_10bit.set_sensitive(False)
  2343.                         self.check_3v_pool.set_sensitive(True)
  2344.                 elif (video_rc == 'bitrate kb/s') and (video_codec == "mpeg4" ):
  2345.                         self.adj_change(self.spin_vc['adj'], 1200, 300, 5000, 100, 100)
  2346.                         self.spin_vc['adj'].set_value(1200.0)
  2347.                         self.check_2pass.set_sensitive(True)
  2348.                         self.check_3v_10bit.set_sensitive(False)
  2349.                         self.check_3v_pool.set_sensitive(False)
  2350.                 elif (video_rc == 'qscale (1-31)') and (video_codec == "mpeg4" ):
  2351.                         self.adj_change(self.spin_vc['adj'], 5, 1, 31, 1, 1)
  2352.                         self.spin_vc['adj'].set_value(5.0)
  2353.                         self.check_2pass.set_active(False)
  2354.                         self.check_2pass.set_sensitive(False)
  2355.                         self.check_3v_10bit.set_sensitive(False)
  2356.                         self.check_3v_pool.set_sensitive(False)
  2357.                 elif (video_rc == 'bitrate kb/s'):
  2358.                         self.adj_change(self.spin_vc['adj'], 730, 100, 4000, 10, 100)
  2359.                         self.spin_vc['adj'].set_value(730.0)
  2360.                         self.check_2pass.set_sensitive(True)
  2361.                         if (video_codec == "libx265"):
  2362.                                 self.check_3v_10bit.set_sensitive(True)
  2363.                         else:
  2364.                                 self.check_3v_10bit.set_sensitive(False)
  2365.                         self.check_3v_pool.set_sensitive(True)
  2366.  
  2367.         def on_codec_vrc_value_change(self, button):
  2368.                 Vars.video_codec_str = ""
  2369.                 video_rc = self.box_vrc.get_active_text() #0 crf, 1 kb/s
  2370.                 if (Vars.vcodec_is == "x264"): #x264
  2371.                         #rc
  2372.                         if (video_rc == "crf"):
  2373.                                 video_codec_str = "-c:v libx264 " + "-crf:v " + str(self.spin_vc['adj'].get_value()) + " " + Vars.video_codec_str_more
  2374.                         elif (video_rc == "bitrate kb/s"):
  2375.                                 video_codec_str = "-c:v libx264 " + "-b:v " + str(int(self.spin_vc['adj'].get_value())) + "k " + Vars.video_codec_str_more
  2376.                 elif (Vars.vcodec_is == "mpeg4"):
  2377.                         if (video_rc == "bitrate kb/s"):
  2378.                                 video_codec_str = "-c:v mpeg4 -mpv_flags strict_gop " + "-b:v " + str(int(self.spin_vc['adj'].get_value())) + "k"
  2379.                         else:
  2380.                                 video_codec_str = "-c:v mpeg4 -mpv_flags strict_gop " + "-q:v " + str(int(self.spin_vc['adj'].get_value()))
  2381.                 elif (Vars.vcodec_is == "x265"):
  2382.                         if (video_rc == "crf"):
  2383.                                 video_codec_str = "-c:v libx265 " + "-x265-params crf=" + str(self.spin_vc['adj'].get_value()) + Vars.video_codec_str_more
  2384.                         elif (video_rc == "bitrate kb/s"):
  2385.                                 video_codec_str = "-c:v libx265 " + "-x265-params bitrate=" + str(int(self.spin_vc['adj'].get_value()))  + Vars.video_codec_str_more
  2386.                 else:
  2387.                         video_codec_str = Vars.video_codec_str_more
  2388.                        
  2389.                 Vars.video_codec_str = video_codec_str
  2390.                 self.make_p3_out_command()
  2391.                
  2392.  
  2393.  
  2394.         def v_codec_vcopy(self):
  2395.                 self.box_vrc.set_sensitive(False)
  2396.                 self.spin_vc['spinner'].set_sensitive(False)
  2397.                 self.box_3v_preset.set_active(2)
  2398.                 self.box_3v_preset.set_sensitive(False)
  2399.                 self.box_3v_tune.set_active(0)
  2400.                 self.box_3v_tune.set_sensitive(False)
  2401.                 self.box_3v_x264opts.set_active(0)
  2402.                 self.box_3v_x264opts.set_sensitive(False)
  2403.                 self.check_3v_opencl.set_active(False)
  2404.                 self.check_3v_opencl.set_sensitive(False)
  2405.                 self.check_2pass.set_active(False)
  2406.                 self.check_2pass.set_sensitive(False)
  2407.                 self.check_3v_10bit.set_sensitive(False)
  2408.                 self.check_3v_pool.set_sensitive(False)
  2409.                 video_codec_str = "-c:v copy"
  2410.                 return video_codec_str
  2411.  
  2412.         def v_codec_vn(self):
  2413.                 self.box_vrc.set_sensitive(False)
  2414.                 self.spin_vc['spinner'].set_sensitive(False)
  2415.                 self.box_3v_preset.set_active(2)
  2416.                 self.box_3v_preset.set_sensitive(False)
  2417.                 self.box_3v_tune.set_active(0)
  2418.                 self.box_3v_tune.set_sensitive(False)
  2419.                 self.box_3v_x264opts.set_active(0)
  2420.                 self.box_3v_x264opts.set_sensitive(False)
  2421.                 self.check_3v_opencl.set_active(False)
  2422.                 self.check_3v_opencl.set_sensitive(False)
  2423.                 self.check_2pass.set_active(False)
  2424.                 self.check_2pass.set_sensitive(False)
  2425.                 self.check_3v_10bit.set_sensitive(False)
  2426.                 self.check_3v_pool.set_sensitive(False)
  2427.                 video_codec_str = "-vn"
  2428.                 return video_codec_str
  2429.  
  2430.         def v_codec_x264(self):
  2431.                 video_codec_str = ""
  2432.                 if Vars.vcodec_is != "x264":
  2433.                         Vars.vcodec_is = "x264"
  2434.                         self.cboxtxt_change(
  2435.                                 self.box_vrc,
  2436.                                 self.on_codec_vrc_changed,
  2437.                                 Vars.x264_vrc,
  2438.                                 0,
  2439.                                 'Vars.vrc_list',
  2440.                                 'x264')
  2441.                         self.cboxtxt_change(
  2442.                                 self.box_3v_tune,
  2443.                                 self.on_preset_changed,
  2444.                                 Vars.x264_tune,
  2445.                                 0,
  2446.                                 'Vars.tune_list',
  2447.                                 'x264')
  2448.                         self.cboxtxt_change(
  2449.                                 self.box_3v_x264opts,
  2450.                                 self.on_codec_clicked,
  2451.                                 Vars.x264_opt,
  2452.                                 0,
  2453.                                 'Vars.opt_list',
  2454.                                 'x264')
  2455.                         self.box_3v_preset.set_active(3)
  2456.                 self.box_vrc.set_sensitive(True)
  2457.                 self.spin_vc['spinner'].set_sensitive(True)
  2458.                 self.box_3v_preset.set_sensitive(True)
  2459.                 self.box_3v_tune.set_sensitive(True)
  2460.                 self.box_3v_x264opts.set_sensitive(True)
  2461.                 self.check_3v_opencl.set_sensitive(True)
  2462.                 #preset
  2463.                 preset_str = ""
  2464.                 preset = self.box_3v_preset.get_active_text()
  2465.                 # 0 -superfast, 1 -veryfast, 2 -faster, 3 -fast, 4 -medium, 5 -slow, default: 2 faster
  2466.                 if (preset == "ultrafast"):
  2467.                         preset_str = "-preset ultrafast "
  2468.                 elif (preset == "superfast"):
  2469.                         preset_str = "-preset superfast "
  2470.                 elif (preset == "veryfast"):
  2471.                         preset_str = "-preset veryfast "
  2472.                 elif (preset == "faster"):
  2473.                         preset_str = "-preset faster "
  2474.                 elif (preset == "fast"):
  2475.                         preset_str = "-preset fast "
  2476.                 elif (preset == "medium"):
  2477.                         preset_str = "-preset medium "
  2478.                 elif (preset == "slow"):
  2479.                         preset_str = "-preset slow "
  2480.                 elif (preset == "veryslow"):
  2481.                         preset_str = "-preset veryslow "
  2482.                 # tune  film, animation, grain, stillimage
  2483.                 tune = self.box_3v_tune.get_active_text()
  2484.                 if (tune == "film"):
  2485.                         preset_str = preset_str + "-tune film"
  2486.                 elif (tune == "animation"):
  2487.                         preset_str = preset_str + "-tune animation"
  2488.                 elif (tune == "grain"):
  2489.                         preset_str = preset_str + "-tune grain"
  2490.                 elif (tune == "stillimage"):
  2491.                         preset_str = preset_str + "-tune stillimage"
  2492.                 video_codec_str = preset_str
  2493.                 #x264opts      
  2494.                 if (self.box_3v_x264opts.get_active() == 1):
  2495.                         video_codec_str = video_codec_str + " -x264opts ssim"
  2496.                 else:
  2497.                         video_codec_str = video_codec_str + " -x264opts ref=4:bframes=4:direct=auto:aq-strength=1.3:ssim:psnr"
  2498.                 #opencl
  2499.                 if self.check_3v_opencl.get_active():
  2500.                         video_codec_str = video_codec_str + ":opencl"
  2501.                 #pools 3
  2502.                 if self.check_3v_pool.get_active():
  2503.                         video_codec_str = video_codec_str + " -threads 3"
  2504.                 return video_codec_str
  2505.  
  2506.         def v_codec_x265(self):
  2507.                 video_codec_str = ""
  2508.                 if Vars.vcodec_is != "x265":
  2509.                         Vars.vcodec_is = "x265"
  2510.                         self.cboxtxt_change(
  2511.                                 self.box_vrc,
  2512.                                 self.on_codec_vrc_changed,
  2513.                                 Vars.x265_vrc,
  2514.                                 0,
  2515.                                 'Vars.vrc_list',
  2516.                                 'x265')
  2517.                         self.box_3v_preset.set_active(1)
  2518.                         self.cboxtxt_change(
  2519.                                 self.box_3v_tune,
  2520.                                 self.on_preset_changed,
  2521.                                 Vars.x265_tune,
  2522.                                 0,
  2523.                                 'Vars.tune_list',
  2524.                                 'x265')
  2525.                         self.cboxtxt_change(
  2526.                                 self.box_3v_x264opts,
  2527.                                 self.on_codec_clicked,
  2528.                                 Vars.x265_opt,
  2529.                                 4,
  2530.                                 'Vars.opt_list',
  2531.                                 'x265')
  2532.                 self.box_vrc.set_sensitive(True)
  2533.                 self.spin_vc['spinner'].set_sensitive(True)
  2534.                 self.box_3v_preset.set_sensitive(True)
  2535.                 self.box_3v_tune.set_sensitive(True)
  2536.                 self.box_3v_x264opts.set_sensitive(True)
  2537.                 self.check_3v_opencl.set_sensitive(False)
  2538.                 #opts
  2539.                 opt = self.box_3v_x264opts.get_active()
  2540.                 if (opt == 0):
  2541.                         self.entry_optscustom.set_sensitive(False)
  2542.                         video_codec_str = video_codec_str + ":ssim=1:psnr=1"
  2543.                 elif (opt == 1):
  2544.                         self.entry_optscustom.set_sensitive(False)
  2545.                         video_codec_str = video_codec_str + ":rd=3:psy-rd=.5:no-sao=1:rc-lookahead=40:deblock=-4:ssim=1:psnr=1"
  2546.                 elif (opt == 2):
  2547.                         self.entry_optscustom.set_sensitive(False)
  2548.                         video_codec_str = video_codec_str + ":deblock=-3:no-sao=1:ssim=1:psnr=1"
  2549.                 elif (opt == 3):
  2550.                         self.entry_optscustom.set_sensitive(False)
  2551.                         video_codec_str = video_codec_str + ":rd=3:psy-rd=.5:aq-mode=3:no-sao=1:rc-lookahead=40:deblock=-3:ssim=1:psnr=1"
  2552.                 elif (opt == 4):
  2553.                         self.entry_optscustom.set_sensitive(False)
  2554.                         video_codec_str = video_codec_str + ":rd=2:psy-rd=.5:aq-mode=3:no-sao=1:rc-lookahead=40:deblock=-3:ssim=1:psnr=1"
  2555.                 elif (opt == 5): #custom
  2556.                         self.entry_optscustom.set_sensitive(True)
  2557.                         video_codec_str = video_codec_str + ":" + self.entry_optscustom.get_chars(0, -1)
  2558.                 #pools 3
  2559.                 if self.check_3v_pool.get_active():
  2560.                         video_codec_str = video_codec_str + ":pools=3"
  2561.                 #preset
  2562.                 preset_str = ""
  2563.                 preset = self.box_3v_preset.get_active_text()
  2564.                 # 0 -superfast, 1 -veryfast, 2 -faster, 3 -fast, 4 -medium, 5 -slow, default: 2 faster
  2565.                 if (preset == "ultrafast"):
  2566.                         preset_str = "-preset ultrafast "
  2567.                 elif (preset == "superfast"):
  2568.                         preset_str = "-preset superfast "
  2569.                 elif (preset == "veryfast"):
  2570.                         preset_str = "-preset veryfast "
  2571.                 elif (preset == "faster"):
  2572.                         preset_str = "-preset faster "
  2573.                 elif (preset == "fast"):
  2574.                         preset_str = "-preset fast "
  2575.                 elif (preset == "medium"):
  2576.                         preset_str = "-preset medium "
  2577.                 elif (preset == "slow"):
  2578.                         preset_str = "-preset slow "
  2579.                 elif (preset == "veryslow"):
  2580.                         preset_str = "-preset veryslow "
  2581.                 # tune
  2582.                 tune = self.box_3v_tune.get_active_text()
  2583.                 if (tune == "grain"):
  2584.                         preset_str = preset_str + "-tune grain"
  2585.                 elif (tune == "fastdecode"):
  2586.                         preset_str = preset_str + "-tune fastdecode"
  2587.                 elif (tune == "zerolatency"):
  2588.                         preset_str = preset_str + "-tune zerolatency"          
  2589.                 video_codec_str = video_codec_str + " " + preset_str
  2590.                 #10bit
  2591.                 if self.check_3v_10bit.get_active():
  2592.                         video_codec_str = video_codec_str + " -pix_fmt yuv420p10le "                    
  2593.                 return video_codec_str
  2594.  
  2595.  
  2596.         def v_codec_mpeg4(self):
  2597.                 if Vars.vcodec_is != "mpeg4":
  2598.                         Vars.vcodec_is = "mpeg4"
  2599.                         self.cboxtxt_change(
  2600.                                 self.box_vrc,
  2601.                                 self.on_codec_vrc_changed,
  2602.                                 Vars.mpeg4_vrc,
  2603.                                 0,
  2604.                                 'Vars.vrc_list',
  2605.                                 'mpeg4')
  2606.                 self.box_vrc.set_sensitive(True)
  2607.                 self.spin_vc['spinner'].set_sensitive(True)
  2608.                 self.box_3v_preset.set_sensitive(False)
  2609.                 self.box_3v_tune.set_sensitive(False)
  2610.                 self.box_3v_x264opts.set_sensitive(False)
  2611.                 self.check_3v_opencl.set_active(False)
  2612.                 self.check_3v_opencl.set_sensitive(False)
  2613.                 video_codec_str = ""
  2614.                 return video_codec_str
  2615.  
  2616.         def on_f3_other_clicked(self, button):
  2617.                 Vars.final_other_str = ""
  2618.                 Vars.debug = 0
  2619.                 Vars.first_pass = 0
  2620.                 Vars.n_pass = 1
  2621.                 if self.check_nometa.get_active():
  2622.                         Vars.final_other_str = "-map_metadata -1"
  2623.                 if self.check_2pass.get_active():
  2624.                                 Vars.first_pass = 1
  2625.                                 Vars.n_pass = 2
  2626.                 if self.check_scopy.get_active():
  2627.                         if (Vars.final_other_str == ""):
  2628.                                 Vars.final_other_str = "-c:s copy"
  2629.                         else:
  2630.                                 Vars.final_other_str = Vars.final_other_str + " " + "-c:s copy"
  2631.                 if self.check_debug.get_active():
  2632.                                 Vars.debug = 1
  2633.                 self.make_p3_out_command()
  2634.                
  2635.         def on_container_changed(self,button):
  2636.                 container = self.box_oth_container.get_active_text()    
  2637.                 if (container == 'MKV'):
  2638.                         Vars.container_str = "-f matroska"
  2639.                         self.check_scopy.set_sensitive(True)
  2640.                         Vars.ext = ".mkv"
  2641.                         if Vars.acodec_list != "mp4":
  2642.                                 self.cboxtxt_change(
  2643.                                         self.box_ac,
  2644.                                         self.on_codec_audio_changed,
  2645.                                         Vars.mp4_acodec,
  2646.                                         4,
  2647.                                         'Vars.acodec_list',
  2648.                                         "mp4")
  2649.                         if Vars.vcodec_list != "mp4":
  2650.                                 self.cboxtxt_change(
  2651.                                         self.box_vcodec,
  2652.                                         self.on_codec_video_changed,
  2653.                                         Vars.mp4_vcodec,
  2654.                                         0,
  2655.                                         'Vars.vcodec_list',
  2656.                                         "mp4")
  2657.                 elif (container == 'MP4'):
  2658.                         Vars.container_str = "-f mp4"
  2659.                         self.check_scopy.set_active(False)
  2660.                         self.check_scopy.set_sensitive(False)
  2661.                         Vars.ext = ".mp4"
  2662.                         if Vars.acodec_list != "mp4":
  2663.                                 self.cboxtxt_change(
  2664.                                         self.box_ac,
  2665.                                         self.on_codec_audio_changed,
  2666.                                         Vars.mp4_acodec,
  2667.                                         4,
  2668.                                         'Vars.acodec_list',
  2669.                                         "mp4")
  2670.                         if Vars.vcodec_list != "mp4":
  2671.                                 self.cboxtxt_change(
  2672.                                         self.box_vcodec,
  2673.                                         self.on_codec_video_changed,
  2674.                                         Vars.mp4_vcodec,
  2675.                                         0,
  2676.                                         'Vars.vcodec_list',
  2677.                                         "mp4")
  2678.                 elif (container == 'AVI'):
  2679.                         Vars.container_str = "-f avi"
  2680.                         self.check_scopy.set_active(False)
  2681.                         self.check_scopy.set_sensitive(False)
  2682.                         if Vars.acodec_list != "avi":
  2683.                                 self.cboxtxt_change(
  2684.                                         self.box_ac,
  2685.                                         self.on_codec_audio_changed,
  2686.                                         Vars.avi_acodec,
  2687.                                         0,
  2688.                                         'Vars.acodec_list',
  2689.                                         "avi")
  2690.                         if Vars.vcodec_list != "avi":
  2691.                                 self.cboxtxt_change(
  2692.                                         self.box_vcodec,
  2693.                                         self.on_codec_video_changed,
  2694.                                         Vars.avi_vcodec,
  2695.                                         0,
  2696.                                         'Vars.vcodec_list',
  2697.                                         "avi")
  2698.                         Vars.ext = ".avi"
  2699.                 elif (container == 'MKA'):
  2700.                         Vars.container_str = "-f matroska"
  2701.                         self.check_scopy.set_active(False)
  2702.                         self.check_scopy.set_sensitive(False)
  2703.                         if Vars.acodec_list != "mka":
  2704.                                 self.cboxtxt_change(
  2705.                                         self.box_ac,
  2706.                                         self.on_codec_audio_changed,
  2707.                                         Vars.mka_acodec,
  2708.                                         0,
  2709.                                         'Vars.acodec_list',
  2710.                                         "mka")
  2711.                         if Vars.vcodec_list != "v-none":
  2712.                                 self.cboxtxt_change(
  2713.                                         self.box_vcodec,
  2714.                                         self.on_codec_video_changed,
  2715.                                         Vars.none_vcodec,
  2716.                                         0,
  2717.                                         'Vars.vcodec_list',
  2718.                                         "v-none")
  2719.                         Vars.ext = ".mka"
  2720.                 self.check_out_file()
  2721.                 self.make_p3_out_command()
  2722.                
  2723.         def on_but_f3_run_clicked(self, button):
  2724.                                
  2725.                 def clear_ff_file():
  2726.                         if os.path.exists(Vars.outdir + '/' + 'ffmpeg2pass-0.log'):
  2727.                                 os.remove(Vars.outdir + '/' + 'ffmpeg2pass-0.log')
  2728.                         if os.path.exists(Vars.outdir + '/' + 'ffmpeg2pass-0.log.mbtree'):
  2729.                                 os.remove(Vars.outdir + '/' + 'ffmpeg2pass-0.log.mbtree')
  2730.                         if os.path.exists(Vars.outdir + '/' + 'x264_lookahead.clbin'):
  2731.                                 os.remove(Vars.outdir + '/' + 'x264_lookahead.clbin')
  2732.                         if os.path.exists(Vars.outdir + '/' + 'x265_2pass.log'):
  2733.                                 os.remove(Vars.outdir + '/' + 'x265_2pass.log')
  2734.                
  2735.                 def end_run():
  2736.                         if (Vars.eff_pass == 0) and (Vars.final_command1 == ""):
  2737.                                 Vars.out_file_size = self.humansize(Vars.newname)
  2738.                                 stri = " Done in: " + self.sec2hms(Vars.time_done) + " " + "\n"\
  2739.                                         + " in:  " + Vars.in_file_size + "\n"\
  2740.                                         + " out: " + Vars.out_file_size
  2741.                                 self.but_f3_run.set_tooltip_text(stri)
  2742.                                 stri2 = " Done in: " + self.sec2hms(Vars.time_done) + " "\
  2743.                                         + " input size:  " + Vars.in_file_size + " "\
  2744.                                         + " output size: " + Vars.out_file_size
  2745.                                 self.reportdata.set_text(stri2)
  2746.                                 self.but_f3_run.set_label('RUN')
  2747.                                 self.window.set_deletable(True)
  2748.                                 clear_ff_file()
  2749.                                 Vars.ENCODING = False
  2750.                         elif (Vars.eff_pass == 0) and (Vars.final_command1 != ""):
  2751.                                 Vars.eff_pass = 1
  2752.                                 Vars.ENCODING = False
  2753.                                 self.on_but_f3_run_clicked(1)
  2754.                         elif (Vars.eff_pass == 1):
  2755.                                 Vars.out_file_size = self.humansize(Vars.newname)
  2756.                                 stri = " Done in: " + self.sec2hms(Vars.time_done + Vars.time_done_1) + " " + "\n"\
  2757.                                         + " pass 1: " + self.sec2hms(Vars.time_done) + " " + "\n"\
  2758.                                         + " pass 2: " + self.sec2hms(Vars.time_done_1) + " " + "\n"\
  2759.                                         + " in:  " + Vars.in_file_size + "\n"\
  2760.                                         + " out: " + Vars.out_file_size
  2761.                                 self.but_f3_run.set_tooltip_text(stri)
  2762.                                 stri2 = " Done in: " + self.sec2hms(Vars.time_done + Vars.time_done_1) + " "\
  2763.                                         + " pass 1: " + self.sec2hms(Vars.time_done) + " "\
  2764.                                         + " pass 2: " + self.sec2hms(Vars.time_done_1) + " "\
  2765.                                         + " input size:  " + Vars.in_file_size + " "\
  2766.                                         + " output size: " + Vars.out_file_size
  2767.                                 self.reportdata.set_text(stri2)
  2768.                                 Vars.eff_pass = 0
  2769.                                 self.but_f3_run.set_label('RUN')
  2770.                                 self.window.set_deletable(True)
  2771.                                 clear_ff_file()
  2772.                                 Vars.ENCODING = False
  2773.                
  2774.                 def check_run(name):
  2775.                        
  2776.                         def win_controls(label, boolean):
  2777.                                 self.but_f3_run.set_label(label)
  2778.                                 self.window.set_deletable(boolean)
  2779.                                 self.but_f3_run.set_tooltip_text('  Abort current encoding  ')
  2780.  
  2781.                         def encod_time(startime):
  2782.                                 if Vars.time_done == 0:
  2783.                                         et = self.sec2hms(time.time() - startime)
  2784.                                 else:
  2785.                                         et = self.sec2hms((time.time() - startime) + Vars.time_done)
  2786.                                 self.but_f3_run.set_label(et + ' - STOP' )
  2787.  
  2788.                         GLib.idle_add(win_controls, 'ENCODING ...' , False)
  2789.                         time.sleep(0.02)
  2790.                         t0 = time.time()
  2791.                         processname = name
  2792.                         for line in subprocess.Popen(["ps", "xa"], shell=False, stdout=subprocess.PIPE).stdout:
  2793.                                 line = line.decode()
  2794.                                 fields = line.split()
  2795.                                 pid = fields[0]
  2796.                                 process = fields[4]
  2797.                                 if process.find(processname) >= 0:              
  2798.                                         if line.find(Vars.filename) >= 0:
  2799.                                                 mypid = pid
  2800.                                                 break
  2801.                         finn = True
  2802.                         while finn == True:
  2803.                                 GLib.idle_add(encod_time, t0)
  2804.                                 time.sleep(1)
  2805.                                 try:
  2806.                                         finn = os.path.exists("/proc/" + mypid)
  2807.                                 except:
  2808.                                         Vars.eff_pass = 0
  2809.                                         GLib.idle_add(win_controls, 'RUN' , True)
  2810.                                         time.sleep(0.02)
  2811.                                         Vars.ENCODING = False
  2812.                                         return
  2813.                         if Vars.eff_pass == 0:  
  2814.                                 tfin = time.time() - t0
  2815.                                 Vars.time_done = int(tfin)
  2816.                         else:
  2817.                                 tfin = time.time() - t0
  2818.                                 Vars.time_done_1 = int(tfin)
  2819.                         GLib.idle_add(end_run)
  2820.                         time.sleep(0.5)
  2821.                        
  2822.                 if Vars.ENCODING: # STOP pressed
  2823.                         Vars.final_command1 = "" # prevent 2 pass start
  2824.                         command = "q"+ "\n"
  2825.                         length = len(command)
  2826.                         self.terminal.feed_child(command, length)
  2827.                         return
  2828.                
  2829.                 if Vars.eff_pass == 0:
  2830.                         self.check_out_file()
  2831.                         Vars.time_done = 0
  2832.                         Vars.time_done_1 = 0
  2833.                         if Vars.n_pass == 1:
  2834.                                 Vars.final_command1 = ""
  2835.                                 Vars.final_command2 = Vars.ffmpeg_ex + " -hide_banner"
  2836.                                 if Vars.ac3_drc != "":
  2837.                                         Vars.final_command2 = Vars.final_command2 + " " + Vars.ac3_drc
  2838.                                 Vars.final_command2 = Vars.final_command2 + " -i \"" \
  2839.                                         + Vars.filename + "\" " \
  2840.                                         + Vars.p3_command \
  2841.                                         +  " \"" + Vars.newname + "\"" \
  2842.                                         + "\n"
  2843.                                 command = Vars.final_command2
  2844.                        
  2845.                         if Vars.n_pass == 2:
  2846.                                 Vars.final_command1 = Vars.ffmpeg_ex + " -hide_banner" + " -i \"" \
  2847.                                         + Vars.filename + "\" " \
  2848.                                         + Vars.p3_comm_first_p \
  2849.                                         + "\n"
  2850.                                 Vars.final_command2 = Vars.ffmpeg_ex + " -hide_banner"
  2851.                                 if Vars.ac3_drc != "":
  2852.                                         Vars.final_command2 = Vars.final_command2 + " " + Vars.ac3_drc
  2853.                                 Vars.final_command2 = Vars.final_command2 + " -i \"" \
  2854.                                         + Vars.filename + "\" " \
  2855.                                         + Vars.p3_command \
  2856.                                         +  " \"" + Vars.newname + "\"" \
  2857.                                         + "\n"
  2858.                                 command = Vars.final_command1
  2859.                 else:
  2860.                         command = Vars.final_command2
  2861.                        
  2862.                 if Vars.debug == 1:
  2863.                         if Vars.n_pass == 1:
  2864.                                 command = "echo $\'\n\n\n" + Vars.final_command2  + "\' \n"
  2865.                         if Vars.n_pass == 2:
  2866.                                 command = "echo $\'\n\n\n" + Vars.final_command1 + "\n" + Vars.final_command2 + "\' \n"
  2867.                 length = len(command)
  2868.  
  2869.                 #
  2870.                 if Vars.debug == 0:
  2871.                         if Vars.eff_pass != 1:
  2872.                                 self.but_f3_run.set_tooltip_text('')
  2873.                                 self.reportdata.set_text('')
  2874.                         Vars.ENCODING = True
  2875.                
  2876.                 self.terminal.feed_child(command, length)
  2877.                
  2878.                 if Vars.debug == 0:
  2879.                         t = threading.Thread(name='child procs', target=check_run, args=(Vars.ffmpeg_ex,))
  2880.                         t.daemon = True
  2881.                         t.start()
  2882.                        
  2883.                
  2884.         def on_folder_clicked(self, button):
  2885.                 if Vars.ENCODING:
  2886.                         return
  2887.                 dialog = Gtk.FileChooserDialog("Please choose a folder", self.window,
  2888.                 Gtk.FileChooserAction.SELECT_FOLDER,
  2889.                 ("_Cancel", Gtk.ResponseType.CANCEL,
  2890.                 "_Select", Gtk.ResponseType.OK))
  2891.                 dialog.set_default_size(800, 400)
  2892.                 dialog.set_current_folder(Vars.outdir)
  2893.  
  2894.                 response = dialog.run()
  2895.                 if response == Gtk.ResponseType.OK:
  2896.                         Vars.outdir = dialog.get_filename()
  2897.                         command = "cd " + "\"" + Vars.outdir + "\"" + "\n"
  2898.                         length = len(command)
  2899.                         self.terminal.feed_child(command, length)
  2900.                         self.f3_run_outdir_label.set_markup("<b>out dir:  </b>" + Vars.outdir)
  2901.                         self.check_out_file()
  2902.                        
  2903.                 dialog.destroy()
  2904.                                
  2905.         def on_but_black_det_clicked(self, button):
  2906.        
  2907.                 def update_progress(pprog):
  2908.                         self.progressbar_black_det.set_fraction(pprog)
  2909.                         return False
  2910.                
  2911.                 def update_textv(stri):
  2912.                         self.textbuffer.insert_at_cursor(stri, -1)
  2913.                         i = self.textbuffer.get_end_iter()
  2914.                         self.textview.scroll_to_iter(i, 0.0, True, 0.0, 1.0)
  2915.                         return False
  2916.  
  2917.                 def stopped():
  2918.                         stri = "Stopped by user.\n"
  2919.                         self.textbuffer.insert_at_cursor(stri, -1)
  2920.                         i = self.textbuffer.get_end_iter()
  2921.                         self.textview.scroll_to_iter(i, 0.0, True, 0.0, 1.0)
  2922.                         self.but_black_det.set_label("Black detect")
  2923.                         self.blackdet_spin.stop()
  2924.                         self.blackdet_spin.set_sensitive(False)
  2925.                         self.progressbar_black_det.set_fraction(0.0)
  2926.                         Vars.blackdet_is_run = False
  2927.                         set_other_butt(True)
  2928.                        
  2929.                 def bd_finish(detected):
  2930.                         if detected == 0:
  2931.                                 stri = "none black gap found"
  2932.                                 self.textbuffer.insert_at_cursor(stri, -1)
  2933.                         self.blackdet_spin.stop()
  2934.                         self.blackdet_spin.set_sensitive(False)
  2935.                         self.but_black_det.set_label("black detectet")
  2936.                         self.progressbar_black_det.set_fraction(1.0)
  2937.                         Vars.blackdet_is_run = False
  2938.                         Vars.BLACKDT_DONE = True
  2939.                         set_other_butt(True)
  2940.  
  2941.                 def set_other_butt(boolean):
  2942.                         if Vars.VOLDT_DONE != True:
  2943.                                 self.but_volume_det.set_sensitive(boolean)
  2944.                         if Vars.FRAMDT_DONE != True:
  2945.                                 self.but_frames_det.set_sensitive(boolean)
  2946.                
  2947.                 def my_thread_blackdet():
  2948.                         Vars.blackdet_is_run = True
  2949.                         command = [Vars.ffmpeg_ex, '-i', Vars.filename, '-y', '-an', '-vf', 'blackdetect=d=.5', '-f', 'null', '/dev/null']
  2950.                         p = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False, universal_newlines=True)
  2951.                         self.bd_th = False
  2952.                         detected = 0
  2953.                         time_step = 0
  2954.                         pprog = 0.0
  2955.                         stri = ""
  2956.                         GLib.idle_add(set_other_butt, False)
  2957.                         time.sleep(0.01)
  2958.                        
  2959.                         while True:
  2960.                                 line = p.stderr.readline()
  2961.                                
  2962.                                 if 'time=' in line:
  2963.                                         if time_step == 12:
  2964.                                                 tml = line.split('time=')[1]
  2965.                                                 tml2 = tml.split(' ')[0]
  2966.                                                 time_n = tml2.split('.')[0]
  2967.                                                 time_n = self.hms2sec(time_n)
  2968.                                                 time_step = 0
  2969.                                                 pprog = float(time_n)/Vars.duration_in_sec
  2970.                                                 GLib.idle_add(update_progress, pprog)
  2971.                                                 time.sleep(0.002)
  2972.                                         else:
  2973.                                                 time_step = time_step + 1
  2974.                                                
  2975.                                 if 'blackdetect ' in line:
  2976.                                                 a = line
  2977.                                                 b = a.split('black_start:')[1]
  2978.                                                 start = b.split(' ')[0]
  2979.                                                 st_in_s = float(start)
  2980.                                                 st_in_s = int(st_in_s)
  2981.                                                 start_in_s = ("%4.1i"% (st_in_s))  
  2982.                                                 start = self.sec2hms(start)
  2983.                                                 stri = "black start at: " + start_in_s + " s, " + start + " "
  2984.                                                 c = b.split('black_duration:')[1]
  2985.                                                 durat = c.split(' ')[0]
  2986.                                                 dur_s = float(durat)
  2987.                                                 dur_s = "{0:0=3.1f}".format(dur_s)
  2988.                                                 stri = stri + "duration: " + dur_s + "s\n"
  2989.                                                 detected = 1
  2990.                                                 GLib.idle_add(update_textv, stri)
  2991.                                                 time.sleep(0.002)
  2992.                                 if line == '' and p.poll() != None:
  2993.                                         break
  2994.                                 if self.bd_th:
  2995.                                         p.communicate("q")
  2996.                                         break
  2997.                         try:
  2998.                                 p.communicate()
  2999.                         except:
  3000.                                 GLib.idle_add(stopped)
  3001.                                 time.sleep(0.1)
  3002.                                 return
  3003.                         GLib.idle_add(bd_finish, detected)
  3004.                         time.sleep(0.1)
  3005.                        
  3006.                 if Vars.BLACKDT_DONE:
  3007.                         return          
  3008.                        
  3009.                 if Vars.blackdet_is_run == False:
  3010.                         self.but_black_det.set_label("Stop")
  3011.                         self.textbuffer.set_text('') # clear for insert from start
  3012.                         stri = "Detected:\n\n"
  3013.                         start = self.textbuffer.get_start_iter()
  3014.                         self.textbuffer.insert(start, stri, -1)
  3015.                         self.blackdet_spin.set_sensitive(True)
  3016.                         self.blackdet_spin.start()                              
  3017.                         thread = threading.Thread(target=my_thread_blackdet)
  3018.                         thread.daemon = True
  3019.                         thread.start()
  3020.                        
  3021.                 elif Vars.blackdet_is_run == True:
  3022.                         self.bd_th = True
  3023.        
  3024.                
  3025.         # -------------------------------------  
  3026.        
  3027.         def preview_logic(self):
  3028.                 if ( not(('-map ' in Vars.p3_command ) or ('-vf ' in Vars.p3_command )) ):
  3029.                         self.buttest.set_sensitive(False)
  3030.                         self.buttestspl.set_sensitive(False)
  3031.                 elif ('-map ' in Vars.p3_command) and ('-vf ' in Vars.p3_command):
  3032.                         self.buttest.set_sensitive(False)
  3033.                         self.buttestspl.set_sensitive(False)
  3034.                 elif '-map ' in Vars.p3_command:
  3035.                         self.buttest.set_sensitive(True)
  3036.                         self.buttestspl.set_sensitive(False)
  3037.                 elif '-vf ' in Vars.p3_command:
  3038.                         self.buttest.set_sensitive(True)
  3039.                         self.buttestspl.set_sensitive(True)
  3040.                
  3041.         def scale_calc(self):
  3042.                 dim_round = 2
  3043.                 if self.check_round.get_active():
  3044.                         dim_round = 8
  3045.                 Vars.scalestr = ""
  3046.                 # dar
  3047.                 dar = self.box2['cbox'].get_active()
  3048.                 if (dar == 0): # 16/9
  3049.                         scale_factor = 1.777777778
  3050.                         setdar = ",setdar=16/9,setsar=1/1"
  3051.                 elif (dar == 1): # 4/3
  3052.                         scale_factor = 1.333333333
  3053.                         setdar = ",setdar=4/3,setsar=1/1"
  3054.                 elif (dar == 2): # 235/100
  3055.                         scale_factor = 2.35
  3056.                         setdar = ",setdar=235/100,setsar=1/1"
  3057.                 elif (dar == 3): #1/1 same as input  
  3058.                         w = int(Vars.video_width)
  3059.                         h = int(Vars.video_height)
  3060.                         # cropped?
  3061.                         if self.checkcr.get_active():
  3062.                                 crT = int(self.spinct['adj'].get_value())
  3063.                                 crB = int(self.spincb['adj'].get_value())
  3064.                                 crL = int(self.spincl['adj'].get_value())
  3065.                                 crR = int(self.spincr['adj'].get_value())
  3066.                                 h = h - crT - crB
  3067.                                 w = w - crL - crR
  3068.                         scale_factor = (float(w) / h)
  3069.                         setdar = ""
  3070.                 #input numeber
  3071.                 num_in = self.size_spinner['adj'].get_value()
  3072.                 #side in
  3073.                 side = self.box1['cbox'].get_active() # 0 none, 1 W, 2 H
  3074.                 if side == 1:
  3075.                         wout = num_in
  3076.                         hout = wout / float(scale_factor)
  3077.                 elif side == 2:
  3078.                         hout = num_in
  3079.                         wout = hout * float(scale_factor)
  3080.                 wout = int(round(float(wout)/dim_round)*dim_round)
  3081.                 hout = int(round(float(hout)/dim_round)*dim_round)
  3082.                 # scale string
  3083.                 Vars.scalestr = "scale="
  3084.                 Vars.scalestr = Vars.scalestr + str(wout) + ":" + str(hout)
  3085.                 #                    
  3086.                 lanc = self.check.get_active()  
  3087.                 if lanc:
  3088.                         Vars.scalestr = Vars.scalestr + ":flags=lanczos" + setdar  
  3089.                 else:
  3090.                         Vars.scalestr = Vars.scalestr + setdar
  3091.                 self.outfilter()
  3092.                
  3093.                      
  3094.         def outfilter(self):
  3095.                 final_str = ""
  3096.                 if (Vars.deint_str != ""):
  3097.                         final_str = final_str + Vars.deint_str
  3098.                 if (Vars.crop_str != ""):
  3099.                         if (final_str == ""):
  3100.                                 final_str = final_str + Vars.crop_str
  3101.                         else:
  3102.                                         final_str = final_str + "," + Vars.crop_str
  3103.                 if (Vars.scalestr != ""):
  3104.                         if (final_str == ""):
  3105.                                 final_str = final_str + Vars.scalestr
  3106.                         else:
  3107.                                 final_str = final_str + "," + Vars.scalestr
  3108.                 if (Vars.dn_str != ""):
  3109.                         if (final_str == ""):
  3110.                                 final_str = final_str + Vars.dn_str
  3111.                         else:
  3112.                                 final_str = final_str + "," + Vars.dn_str
  3113.                 if (Vars.uns_str != ""):
  3114.                         if (final_str == ""):
  3115.                                 final_str = final_str + Vars.uns_str
  3116.                         else:
  3117.                                 final_str = final_str + "," + Vars.uns_str
  3118.                 Vars.filter_test_str = final_str
  3119.                
  3120.                 if (final_str != ""):
  3121.                         Vars.final_vf_str = "-vf " + final_str
  3122.                 else:
  3123.                         Vars.final_vf_str = ""
  3124.                
  3125.                 label_str = ""          
  3126.                 if (Vars.maps_str != ""):
  3127.                         label_str = label_str + Vars.maps_str + " "  
  3128.                 if (Vars.time_final_str != ""):
  3129.                         label_str = label_str + Vars.time_final_str + " "                      
  3130.                 if (Vars.fr_str != ""):
  3131.                         label_str = label_str + Vars.fr_str + " "                      
  3132.                 if (Vars.final_vf_str != ""):
  3133.                         label_str = label_str + Vars.final_vf_str
  3134.                    
  3135.                 self.labelout.set_text(label_str)      
  3136.                 self.make_p3_out_command()
  3137.                 if (Vars.info_str != ""):
  3138.                         self.preview_logic()    
  3139.        
  3140.         def make_p3_out_command(self):
  3141.                
  3142.                 def x265_pass_com(string_eval, npass): # string , int (1-2)
  3143.                         datainfo = string_eval.split(' ')
  3144.                         pointer = datainfo.index('-x265-params')
  3145.                         x265opts0 = datainfo[pointer+1]
  3146.                         x265opts1 = x265opts0 + ":pass=" + str(npass) + " "
  3147.                         string_eval = string_eval.replace(x265opts0, x265opts1)
  3148.                         return string_eval
  3149.                        
  3150.                 Vars.p3_command = ""
  3151.                 Vars.p3_comm_first_p = ""
  3152.                 self.f3_out_label.set_label("")
  3153.                
  3154.                 if (Vars.maps_str != ""):
  3155.                         Vars.p3_command = Vars.maps_str + " "  
  3156.                 if (Vars.time_final_str != ""):
  3157.                         Vars.p3_command = Vars.p3_command + Vars.time_final_str + " "
  3158.                 if ( (Vars.fr_str != "") and (Vars.vcodec_is != "vcopy") and (Vars.vcodec_is != "none") ): # check -vcopy
  3159.                         Vars.p3_command = Vars.p3_command + Vars.fr_str + " "          
  3160.                 if ( (Vars.final_vf_str != "") and (Vars.vcodec_is != "vcopy") and (Vars.vcodec_is != "none") ): # check -vcopy
  3161.                         Vars.p3_command = Vars.p3_command + Vars.final_vf_str + " "
  3162.                        
  3163.                 # first pass    
  3164.                 if Vars.first_pass:
  3165.                         Vars.p3_comm_first_p = Vars.p3_command + Vars.video_codec_str + " "
  3166.                         if Vars.vcodec_is == "x264":
  3167.                                 Vars.p3_comm_first_p = Vars.p3_comm_first_p + "-pass 1 -fastfirstpass 1 "
  3168.                         elif Vars.vcodec_is == "mpeg4":
  3169.                                 Vars.p3_comm_first_p = Vars.p3_comm_first_p + "-pass 1 "
  3170.                         elif Vars.vcodec_is == "x265":
  3171.                                 Vars.p3_comm_first_p = x265_pass_com(Vars.p3_comm_first_p, 1)
  3172.                         Vars.p3_comm_first_p = Vars.p3_comm_first_p + "-an -f null /dev/null"
  3173.                 else:
  3174.                         Vars.p3_comm_first_p = ""
  3175.                 # -af
  3176.                 audiof = ""
  3177.                 if ( (Vars.final_af_str != "") and (Vars.acodec_is != "acopy") and (Vars.acodec_is != "anone") ):  # check -acopy -an
  3178.                         audiof_1 = Vars.final_af_str
  3179.                 else:
  3180.                         audiof_1 = ""
  3181.                 if ( ((Vars.compand_data != "") or (Vars.dynaudnorm_data != "")) and (Vars.acodec_is != "acopy") and (Vars.acodec_is != "anone") ):  # check -acopy -an
  3182.                         if (Vars.compand_data != ""):
  3183.                                 audiof_2 = Vars.compand_data
  3184.                         elif (Vars.dynaudnorm_data != ""):
  3185.                                 audiof_2 = Vars.dynaudnorm_data
  3186.                 else:
  3187.                         audiof_2 = ""
  3188.                
  3189.                 if (Vars.acodec_is != "acopy") and (Vars.acodec_is != "anone"):
  3190.                         if (audiof_1 != "") and (audiof_2 != ""):
  3191.                                 audiof = audiof_1 + "," + audiof_2
  3192.                         elif (audiof_1 != "") and (audiof_2 == ""):
  3193.                                 if (Vars.audio_channels == 6) and (self.box_audio_ch.get_active_text() == '2') and self.check_prologic.get_active():
  3194.                                         audiof = 'aformat=channel_layouts=stereo,aresample=matrix_encoding=dplii,' + audiof_1
  3195.                                 else:
  3196.                                         audiof = audiof_1
  3197.                         elif (audiof_1 == "") and (audiof_2 != ""):
  3198.                                 audiof = audiof_2
  3199.                         elif (audiof_1 == "") and (audiof_2 == ""):
  3200.                                 if (Vars.audio_channels == 6) and (self.box_audio_ch.get_active_text() == '2') and self.check_prologic.get_active():
  3201.                                         audiof = 'aformat=channel_layouts=stereo,aresample=matrix_encoding=dplii'
  3202.                         if audiof != "":        
  3203.                                 Vars.p3_command = Vars.p3_command + "-af \'" + audiof + "\' "
  3204.                
  3205.                 Vars.final_codec_str = Vars.audio_codec_str + " " + Vars.video_codec_str
  3206.                 if (Vars.final_codec_str != ""):
  3207.                         Vars.p3_command = Vars.p3_command + Vars.final_codec_str + " "
  3208.                
  3209.                 #second pass
  3210.                 if Vars.n_pass == 2:
  3211.                         if Vars.vcodec_is != "x265":
  3212.                                 Vars.p3_command = Vars.p3_command + "-pass 2" + " "
  3213.                         elif Vars.vcodec_is == "x265":
  3214.                                 Vars.p3_command = x265_pass_com(Vars.p3_command, 2)
  3215.                 if (Vars.container_str != ""):
  3216.                         Vars.p3_command = Vars.p3_command + Vars.container_str + " "
  3217.                 if (Vars.final_other_str != ""):
  3218.                         Vars.p3_command = Vars.p3_command + Vars.final_other_str + " "
  3219.                 self.f3_out_label.set_label(Vars.p3_command)
  3220.                
  3221.         def main(self):
  3222.                 Gtk.main()
  3223.  
  3224.                
  3225.        
  3226.  
  3227. if __name__ == "__main__":
  3228.         GObject.threads_init()
  3229.         ProgrammaGTK()
  3230.         Gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement