Advertisement
Guest User

4ffmpeg-8.172

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