Advertisement
Guest User

4ffmpeg_7.33

a guest
Nov 17th, 2014
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 75.77 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # work in python3.4
  5.  
  6. from gi.repository import Gtk, GObject, Vte
  7. from gi.repository import GLib
  8. import os
  9. import sys, subprocess, shlex, re
  10. from subprocess import call
  11. from math import pow
  12. from urllib import url2pathname
  13. from gi.repository import Pango
  14. import threading
  15.                
  16. class reuse_init(object):
  17.  
  18.  
  19.         def make_label(self, text):
  20.                 label = Gtk.Label(text)
  21.                 label.set_use_underline(True)
  22.                 label.set_alignment(1.0, 0.5)
  23.                 label.show()
  24.                 return label
  25.  
  26.         def make_slider_and_spinner(self, init, min, max, step, page, digits):
  27.                 controls = {'adj':Gtk.Adjustment(init, min, max, step, page), 'slider':Gtk.HScale(), 'spinner':Gtk.SpinButton()}
  28.                 controls['slider'].set_adjustment(controls['adj'])
  29.                 controls['slider'].set_draw_value(False)
  30.                 controls['spinner'].set_adjustment(controls['adj'])
  31.                 controls['spinner'].set_digits(digits)
  32.                 controls['slider'].show()
  33.                 controls['spinner'].show()
  34.                 return controls
  35.        
  36.         def make_frame_ag(self, f_shadow_type, f_label, alig_pad, gri_row_sp, gri_colu_sp, gri_homog):
  37.                 controls =  {'frame':Gtk.Frame(), 'ali':Gtk.Alignment(), 'grid':Gtk.Grid()}
  38.                 controls['frame'].set_shadow_type(f_shadow_type) # 3 GTK_SHADOW_ETCHED_IN , 1 GTK_SHADOW_IN
  39.                 controls['frame'].set_label(f_label)
  40.                 controls['ali'].set_padding(alig_pad, alig_pad, alig_pad, alig_pad)
  41.                 controls['frame'].add(controls['ali'])
  42.                 controls['grid'].set_row_spacing(gri_row_sp)
  43.                 controls['grid'].set_column_spacing(gri_colu_sp)
  44.                 controls['grid'].set_column_homogeneous(gri_homog) # True
  45.                 controls['ali'].add(controls['grid'])
  46.                 controls['frame'].show()
  47.                 controls['ali'].show()
  48.                 controls['grid'].show()
  49.                 return controls
  50.        
  51.         def make_spinbut(self, init, min, max, step, page, digits, numeric):
  52.                 controls = {'adj':Gtk.Adjustment(init, min, max, step, page), 'spinner':Gtk.SpinButton()}
  53.                 controls['spinner'].set_adjustment(controls['adj'])
  54.                 controls['spinner'].set_digits(digits)
  55.                 controls['spinner'].set_numeric(numeric)
  56.                 controls['spinner'].show()
  57.                 return controls
  58.        
  59.         def make_combobox(self, *vals):
  60.                 controls = {'list':Gtk.ListStore(str), 'cbox':Gtk.ComboBox(), 'cellr':Gtk.CellRendererText()}
  61.                 for i, v in enumerate(vals):
  62.                         controls['list'].append([v])
  63.                 controls['cbox'].set_model(controls['list'])      
  64.                 controls['cbox'].pack_start(controls['cellr'], True)
  65.                 controls['cbox'].add_attribute(controls['cellr'], "text", 0)
  66.                 controls['cbox'].set_active(0)
  67.                 controls['cbox'].show()
  68.                 return controls
  69.        
  70.         def hms2sec(self, hms):
  71.                 result = 0
  72.                 listin = hms.split(':')
  73.                 listin.reverse()
  74.                 for i in range(len(listin)):
  75.                         if listin[i].isdigit():
  76.                                 if i == 0:
  77.                                         mult = 1
  78.                                 if i == 1:
  79.                                         mult = 60
  80.                                 if i == 2:
  81.                                         mult = 3600
  82.                                 result = result + (int(listin[i])*mult)            
  83.                 return result
  84.        
  85.         def sec2hms(self, seconds):
  86.                 seconds = float(seconds)
  87.                 h = int(seconds/3600)
  88.                 if (h > 0):
  89.                         seconds = seconds - (h * 3600)
  90.                 m = int(seconds / 60)
  91.                 s = int(seconds - (m * 60))
  92.                 hms = "{0:0=2d}:{1:0=2d}:{2:0=2d}".format(h,m,s)
  93.                 return hms
  94.        
  95.         def adj_change(self, adjustment, value, lower, upper , step_increment, page_increment):
  96.                 adjustment.set_value(value)
  97.                 adjustment.set_lower(lower)
  98.                 adjustment.set_upper(upper)
  99.                 adjustment.set_step_increment(step_increment)
  100.                 adjustment.set_page_increment(page_increment)
  101.                 #adjustment.set_page_size(page_size)
  102.        
  103.        
  104.        
  105. class ProgrammaGTK(reuse_init):
  106.        
  107.  
  108.         def __init__(self):
  109.                
  110.                 self.window =  Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
  111.                 self.window.connect("destroy", self.on_window_destroy)
  112.                 self.window.set_title("4FFmpeg")
  113.                 self.window.set_position(1) # 1 center, 0 none,
  114.                 self.window.set_border_width(3)
  115.                 self.window.set_default_size(500,-1)
  116.                 #----------------------------------
  117.                
  118.                 #page1 stuff VIDEO FILTERS------------------------------------------
  119.                                
  120.                 # page1 VBox -------------------------
  121.                 self.vbox1 = Gtk.VBox()
  122.                 self.vbox1.set_spacing(2)
  123.                
  124.                 # map --------------------------------------
  125.                 self.make_map()        
  126.                 # add map frame
  127.                 self.vbox1.pack_start(self.f_map['frame'], 1, 0, 0)
  128.                
  129.                 #time cut ------------------------------------
  130.                 self.make_time_cut()
  131.                 # add time frame
  132.                 self.vbox1.pack_start(self.f_time['frame'], 1, 0, 0)
  133.                
  134.                 # deinterlace -----------------------
  135.                 self.make_deinterlace()
  136.                 # add deinterlace frame
  137.                 self.vbox1.pack_start(self.f_deint['frame'], 1, 0, 0)
  138.                
  139.                 # crop ----------------------------------------
  140.                 self.make_crop()        
  141.                 # add crop frame -------------------
  142.                 self.vbox1.pack_start(self.frame_crop['frame'], 1, 0, 0)
  143.        
  144.                 # scale ------------------------------
  145.                 self.make_scale()
  146.                 # add scale frame------------------
  147.                 self.vbox1.pack_start(self.frame_scale['frame'], 1, 0, 0)
  148.  
  149.                 # denoise ----------------------------
  150.                 self.make_denoise()
  151.                 # add denoise frame------------------------
  152.                 self.vbox1.pack_start(self.frame_dn['frame'], 1, 0, 0)
  153.                
  154.                 #test-------------------
  155.                 #self.f_test = self.make_frame_ag(3, "TEST" , 6, 8, 8, True)
  156.                 #self.label_test = Gtk.Label("TEST")
  157.                 #self.f_test['grid'].attach(self.label_test, 0, 0, 1, 1)
  158.  
  159.                 #self.vbox1.pack_start(self.f_test['frame'], 1, 0, 0)
  160.                 #-------------------------------------
  161.                
  162.                 # page 1 output------------------------
  163.                 self.frame_out = self.make_frame_ag(3, '  FFmpeg video filter string (select and copy):  ' , 12, 8, 8, True)
  164.                 self.labelout = Gtk.Label("")
  165.                 self.labelout.set_selectable(1)
  166.                 self.frame_out['grid'].attach(self.labelout, 0, 0, 1 ,1)
  167.                 # add output frame ---------------------
  168.                 self.vbox1.pack_start(self.frame_out['frame'], 1, 0, 0)
  169.                
  170.                 # end page1 stuff
  171.                
  172.                
  173.                 # page2 stuff  UTILITY ------------------------------------------
  174.                
  175.                 # page2 VBox -------------------------
  176.                 self.vbox_pg2 = Gtk.VBox()
  177.                 self.vbox_pg2.set_spacing(2)
  178.                
  179.                 #volumedetect ------------------------------------
  180.                 self.make_volume_det()
  181.                 # add volumedetect frame        
  182.                 self.vbox_pg2.pack_start(self.f_volume_det['frame'], 1, 0, 0)
  183.                
  184.                 # black detect ----------------------------------
  185.                 self.make_black_detect()
  186.                 # add black_detect frame
  187.                 self.vbox_pg2.pack_start(self.f_blackd['frame'], 1, 0, 0)
  188.                
  189.                 # info frame----------------------
  190.                 self.make_info_frame()
  191.                 # add info frame
  192.                 self.vbox_pg2.pack_start(self.f_info['frame'], 1, 0, 0)
  193.                
  194.                 # end page2 stuff
  195.                
  196.                 # page 3 stuff  730 cuatom commands -----------------------------------------
  197.                
  198.                 # page3 VBox -------------------------
  199.                 self.vbox_pg3 = Gtk.VBox()
  200.                 self.vbox_pg3.set_spacing(2)
  201.                
  202.                 # audio codec -------------------
  203.                 self.make_audio_codec()
  204.                 #add frame audio codec
  205.                 self.vbox_pg3.pack_start(self.f_3acodec['frame'], 1, 0, 0)
  206.                
  207.                 # video codec -------------------
  208.                 self.make_video_codec()
  209.                 #add frame video codec
  210.                 self.vbox_pg3.pack_start(self.f_3vcodec['frame'], 1, 0, 0)
  211.                
  212.                 # other options ----------------
  213.                 self.make_other_opts()
  214.                 #add frame other options
  215.                 self.vbox_pg3.pack_start(self.f3_oth['frame'], 1, 0, 0)
  216.                
  217.                 # page3 output ---------------------
  218.                 self.f3_out = self.make_frame_ag(3, "  730 command  " , 6, 8, 8, True)
  219.                 self.f3_out_label = Gtk.Label("")
  220.                 self.f3_out['grid'].attach(self.f3_out_label, 0, 0, 1, 1)
  221.                 # add frame page3 output
  222.                 self.vbox_pg3.pack_start(self.f3_out['frame'], 1, 0, 0)
  223.                
  224.                 # run 730 ---------------------------------
  225.                 self.make_run_730()
  226.                 # add frame run 730
  227.                 self.vbox_pg3.pack_start(self.f3_run['frame'], 1, 0, 0)
  228.                
  229.                
  230.                 #---------------------------------------------------
  231.                 # main vbox
  232.                 self.main_vbox = Gtk.VBox()
  233.                
  234.                 # notebook      
  235.                 self.notebook = Gtk.Notebook()
  236.                 self.notebook.set_tab_pos(0)  #GTK_POS_LEFT
  237.                 self.notebook.set_show_border (False)
  238.                 self.main_vbox.pack_start(self.notebook, 1, 0, 0)
  239.                
  240.                 #page 1
  241.                 self.tab1label = Gtk.Label("Video filters")
  242.                 self.page1_ali = Gtk.Alignment()
  243.                 self.page1_ali.set_padding(0, 6, 6, 6)
  244.                 self.page1_ali.add(self.vbox1)
  245.                 self.notebook.append_page(self.page1_ali, self.tab1label)
  246.                
  247.                 #page 2
  248.                 self.tab2label = Gtk.Label("Utility")
  249.                 self.page2_ali = Gtk.Alignment()
  250.                 self.page2_ali.set_padding(0, 6, 6, 6)
  251.                 self.page2_ali.add(self.vbox_pg2)
  252.                 self.notebook.append_page(self.page2_ali, self.tab2label)
  253.                
  254.                 #page 3
  255.                 self.tab3label = Gtk.Label("730")
  256.                 self.page3_ali = Gtk.Alignment()
  257.                 self.page3_ali.set_padding(0, 6, 6, 6)
  258.                 self.page3_ali.add(self.vbox_pg3)
  259.                 self.notebook.append_page(self.page3_ali, self.tab3label)
  260.                
  261.                 #---------------------------------------------------
  262.                
  263.                 # low part BUTTONS AND TERM --------------------------
  264.                 self.make_low_part()
  265.                 # add low part-----------------
  266.                 self.main_vbox.pack_start(self.gridterm, 1, 1, 0)
  267.                
  268.                 #---------------------------------------------------------
  269.                 self.window.add (self.main_vbox)
  270.                 #---------------------------------
  271.                 self.window.show_all()
  272.                
  273.                 # initialize variables
  274.                 self.final_vf_str = ""
  275.                 self.final_af_str = ""
  276.                 self.deint_str = ""
  277.                 self.crop_str = ""
  278.                 self.scalestr = ""
  279.                 self.dn_str = ""
  280.                 self.filter_test_str = ""
  281.                 self.video_width = "0"
  282.                 self.video_height = "0"
  283.                 self.add_1_1 = True
  284.                 self.maps_str = ""
  285.                 self.time_final_srt = ""
  286.                 self.final_codec_str = "-aaq -crf 21"
  287.                 self.final_other_str = ""
  288.                 self.a_copy = 0
  289.                 self.v_copy = 0
  290.                 self.container_str = "-mkv"
  291.                 self.preset_str = "-faster"
  292.                 self.info_str = ''
  293.                 self.make_p3_out_command()
  294.                 self.first_run = 0
  295.                
  296.                 # ----------------------------
  297.                
  298.         def make_deinterlace(self):
  299.                 self.f_deint = self.make_frame_ag(3, "" , 6, 8, 8, True)
  300.                 self.checkdeint = Gtk.CheckButton("deinterlace")
  301.                 self.checkdeint.connect("toggled", self.on_deint_clicked)
  302.                 self.f_deint['grid'].attach(self.checkdeint, 0, 0, 1, 1)
  303.                
  304.                 self.box_deint = self.make_combobox(
  305.                   "yadif",
  306.                   "postprocessing linear blend"
  307.                   )
  308.                 self.f_deint['grid'].attach(self.box_deint['cbox'], 1, 0, 1, 1)
  309.                 self.box_deint['cbox'].connect("changed", self.on_deint_clicked)
  310.                 #
  311.                 self.f_deint['grid'].attach(self.make_label(""), 2, 0, 1, 1)
  312.        
  313.         def make_map(self):
  314.                 #
  315.                 self.map_tooltip_str = ' use 0:0  or  0:0,0:1,0:2 '
  316.                 #
  317.                 self.f_map = self.make_frame_ag(3, "" , 6, 8, 8, True)
  318.                 #
  319.                 self.check_map = Gtk.CheckButton("map")
  320.                 self.check_map.connect("toggled", self.on_map_clicked) # toggled or activate (enter)
  321.                 self.f_map['grid'].attach(self.check_map, 0, 0, 1, 1)
  322.                 #
  323.                 self.mapstream_label = self.make_label("streams: ")
  324.                 self.f_map['grid'].attach(self.mapstream_label, 1, 0, 1, 1)
  325.                 #
  326.                 self.entry_map = Gtk.Entry()
  327.                 self.entry_map.set_tooltip_text(self.map_tooltip_str)
  328.                 self.entry_map.connect("changed", self.on_map_clicked)
  329.                 self.f_map['grid'].attach(self.entry_map, 2, 0, 1, 1)
  330.                 #
  331.                 self.map_label = Gtk.Label("")
  332.                 self.f_map['grid'].attach(self.map_label, 3, 0, 1, 1)
  333.                 # placeholder
  334.                 self.f_map['grid'].attach(self.make_label(""), 4, 0, 1, 1)
  335.                
  336.         def make_time_cut(self):
  337.                 #
  338.                 self.time_tooltip_str = ' use: 90 or 00:01:30 '
  339.                 #
  340.                 self.f_time = self.make_frame_ag(3, "" , 6, 8, 8, True)
  341.                 #
  342.                 self.check_time = Gtk.CheckButton("time")
  343.                 self.check_time.connect("toggled", self.on_time_clicked) # toggled or activate (enter)
  344.                 self.f_time['grid'].attach(self.check_time, 0, 0, 1, 1)
  345.                 #
  346.                 self.label_time_in = self.make_label("from: ")
  347.                 self.f_time['grid'].attach(self.label_time_in, 1, 0, 1, 1)
  348.                 self.entry_timein = Gtk.Entry()
  349.                 self.entry_timein.set_tooltip_text(self.time_tooltip_str)
  350.                 self.entry_timein.connect("changed", self.on_time_clicked)
  351.                 self.f_time['grid'].attach(self.entry_timein, 2, 0, 1, 1)
  352.                
  353.                 self.label_time_out = self.make_label("to: ")
  354.                 self.f_time['grid'].attach(self.label_time_out, 3, 0, 1, 1)
  355.                 self.entry_timeout = Gtk.Entry()
  356.                 self.entry_timeout.set_tooltip_text(self.time_tooltip_str)
  357.                 self.entry_timeout.connect("changed", self.on_time_clicked)
  358.                 self.f_time['grid'].attach(self.entry_timeout, 4, 0, 1, 1)
  359.        
  360.         def make_scale(self):
  361.                 self.frame_scale = self.make_frame_ag(3, '  scale  ' , 6, 8, 8, True)
  362.                 # ------------------------------
  363.                 self.box1 = self.make_combobox(
  364.                   "None",
  365.                   "W",
  366.                   "H"
  367.                   )
  368.                 self.frame_scale['grid'].attach(self.box1['cbox'], 0, 0, 1, 1)
  369.                 self.box1['cbox'].connect("changed", self.on_scale_clicked)
  370.                 #------------------------------------
  371.                 self.box2 = self.make_combobox(
  372.                   "16/9",
  373.                   "4/3"
  374.                   )
  375.                 self.frame_scale['grid'].attach(self.box2['cbox'], 0, 1, 1, 1)
  376.                 self.box2['cbox'].connect("changed", self.on_scale_clicked)
  377.                 #-----------------------------------------
  378.                 self.size_spinner = self.make_slider_and_spinner(720, 200, 2000, 1, 10, 0)
  379.                 self.frame_scale['grid'].attach(self.size_spinner['slider'], 1, 0, 1, 1)
  380.                 self.frame_scale['grid'].attach(self.size_spinner['spinner'], 2, 0, 1, 1)
  381.                 #self.size_spinner['slider'].set_size_request(150,-1)
  382.                 self.size_spinner['adj'].set_value(720.001) #mettere decimali se no non si vede
  383.                 self.size_spinner['adj'].connect("value-changed", self.on_scale_clicked)
  384.                 #-------------------------------------------------------
  385.                 self.check = Gtk.CheckButton("lanczos")
  386.                 self.check.connect("toggled", self.on_scale_clicked)
  387.                 self.frame_scale['grid'].attach(self.check, 2, 1, 1, 1)
  388.                
  389.         def make_crop(self):
  390.                 self.frame_crop = self.make_frame_ag(3, '' , 6, 2, 0, True)
  391.                 # -------
  392.                 self.checkcr = Gtk.CheckButton("crop")
  393.                 self.checkcr.connect("toggled", self.on_crop_clicked)
  394.                 self.frame_crop['grid'].attach(self.checkcr, 0, 0, 1, 1)
  395.                 #----------
  396.                 self.butcrode = Gtk.Button(label="Crop detect")
  397.                 self.butcrode.connect("clicked", self.on_butcrode_clicked)
  398.                 self.frame_crop['grid'].attach(self.butcrode, 0, 1, 1, 1)
  399.                 #-----------
  400.                 self.labelcropinw = self.make_label("input W: ")
  401.                 self.frame_crop['grid'].attach(self.labelcropinw, 1, 0, 1, 1)
  402.                 self.labelcropinh = self.make_label("input H: ")
  403.                 self.frame_crop['grid'].attach(self.labelcropinh, 1, 1, 1, 1)
  404.                 #
  405.                 self.spincw = self.make_spinbut(640 , 100 , 1920 , 10 , 1 , 0, True )
  406.                 self.spincw["adj"].connect("value-changed", self.on_crop_clicked)
  407.                 self.frame_crop['grid'].attach(self.spincw["spinner"], 2, 0, 1, 1)
  408.                 #
  409.                 self.spinch = self.make_spinbut(480 , 100 , 1280 , 10 , 1 , 0, True )
  410.                 self.spinch["adj"].connect("value-changed", self.on_crop_clicked)
  411.                 self.frame_crop['grid'].attach(self.spinch["spinner"], 2, 1, 1, 1)
  412.                 #
  413.                
  414.                 self.labelcroptop = self.make_label("crop Top: ")
  415.                 self.frame_crop['grid'].attach(self.labelcroptop, 3, 0, 1, 1)
  416.                 self.labelcropbot = self.make_label("crop Bottom: ")
  417.                 self.frame_crop['grid'].attach(self.labelcropbot, 3, 1, 1, 1)
  418.                 #
  419.                
  420.                 self.spinct = self.make_spinbut(0 , 0 , 600 , 1 , 10 , 0, True )
  421.                 self.spinct["adj"].connect("value-changed", self.on_crop_clicked)
  422.                 self.frame_crop['grid'].attach(self.spinct["spinner"], 4, 0, 1, 1)
  423.                 #
  424.                 self.spincb = self.make_spinbut(0 , 0 , 600 , 1 , 10 , 0, True )
  425.                 self.spincb["adj"].connect("value-changed", self.on_crop_clicked)
  426.                 self.frame_crop['grid'].attach(self.spincb["spinner"], 4, 1, 1, 1)
  427.                 #
  428.                
  429.                 self.labelcroplef = self.make_label("crop Left: ")
  430.                 self.frame_crop['grid'].attach(self.labelcroplef, 5, 0, 1, 1)
  431.                 self.labelcroprig = self.make_label("crop Right: ")
  432.                 self.frame_crop['grid'].attach(self.labelcroprig, 5, 1, 1, 1)
  433.                 #
  434.                 self.spincl = self.make_spinbut(0 , 0 , 600 , 1 , 10 , 0, True )
  435.                 self.spincl["adj"].connect("value-changed", self.on_crop_clicked)
  436.                 self.frame_crop['grid'].attach(self.spincl["spinner"], 6, 0, 1, 1)
  437.                 #
  438.                 self.spincr = self.make_spinbut(0 , 0 , 600 , 1 , 10 , 0, True )
  439.                 self.spincr["adj"].connect("value-changed", self.on_crop_clicked)
  440.                 self.frame_crop['grid'].attach(self.spincr["spinner"], 6, 1, 1, 1)
  441.                
  442.                
  443.         def make_denoise(self):
  444.                 self.frame_dn = self.make_frame_ag(3, '' , 6, 8, 8, True)
  445.                 # ----------------------
  446.                 self.checkdn = Gtk.CheckButton("denoise")
  447.                 self.checkdn.connect("toggled", self.on_dn_clicked)
  448.                 self.frame_dn['grid'].attach(self.checkdn, 0, 0, 1, 1)
  449.                 # -------------------------
  450.                 self.labeldn = Gtk.Label("hqdn3d:")
  451.                 self.labeldn.set_alignment(1.0, 0.5)
  452.                 self.frame_dn['grid'].attach(self.labeldn, 1, 0, 1, 1)
  453.                 #----------------------------------------
  454.                 self.spindn = self.make_spinbut(4 , 2 , 8 , 1 , 10 , 0, True )
  455.                 self.spindn["adj"].connect("value-changed", self.on_dn_clicked)
  456.                 self.frame_dn['grid'].attach(self.spindn["spinner"], 2, 0, 1, 1)
  457.                
  458.         def make_low_part(self):
  459.                 # grid
  460.                 self.gridterm = Gtk.Grid()
  461.                 self.gridterm.set_row_spacing(2)
  462.                 self.gridterm.set_column_spacing(2)
  463.                 self.gridterm.set_column_homogeneous(True) # True
  464.                 # filechooserbutton
  465.                 self.filechooserbutton = Gtk.FileChooserButton(title="FileChooserButton")
  466.                 #
  467.                 #self.filechooserbutton.set_action(2) # 0 open file, 1 save file, 2 select folder, 3 create folder
  468.                 #
  469.                 self.filechooserbutton.connect("file-set", self.file_changed)  
  470.                 # filter
  471.                 self.filter = Gtk.FileFilter()
  472.                 self.filter.set_name("Video")
  473.                 self.filter.add_mime_type("video/x-matroska")
  474.                 self.filter.add_mime_type("video/mp4")
  475.                 self.filter.add_mime_type("video/x-flv")
  476.                 self.filter.add_mime_type("video/avi")
  477.                 self.filter.add_mime_type("video/mpg")
  478.                 self.filter.add_mime_type("video/mpeg")
  479.                 self.filter.add_mime_type("video/x-ms-wmv")
  480.                 self.filter.add_mime_type("video/webm")
  481.                 self.filter.add_mime_type("video/ogg")
  482.                 self.filter.add_mime_type("video/quicktime")
  483.                 self.filechooserbutton.add_filter(self.filter)
  484.                 # terminal
  485.                 self.terminal     = Vte.Terminal()
  486.                 self.terminal.fork_command_full(
  487.                         Vte.PtyFlags.DEFAULT, #default is fine
  488.                         os.getcwd(), #where to start the command?   os.environ['HOME']
  489.                         ["/bin/sh"], #where is the emulator?
  490.                         [], #it's ok to leave this list empty
  491.                         GLib.SpawnFlags.DO_NOT_REAP_CHILD,
  492.                         None, #at least None is required
  493.                         None,
  494.                         )
  495.                 self.scroller = Gtk.ScrolledWindow()
  496.                 self.scroller.set_hexpand(True)
  497.                 self.scroller.set_vexpand(True)
  498.                 self.scroller.add(self.terminal)
  499.                 self.scroller.set_min_content_height(90)
  500.                 #self.gridterm.attach(self.scroller, 0, 1, 6, 1)
  501.                 #ff command button
  502.                 self.butplay = Gtk.Button(label="FFplay")
  503.                 self.butplay.connect("clicked", self.on_butplay_clicked)
  504.                 self.butplay.set_sensitive(False)
  505.                 self.butprobe = Gtk.Button(label="FFprobe")
  506.                 self.butprobe.connect("clicked", self.on_butprobe_clicked)
  507.                 self.butprobe.set_sensitive(False)
  508.                 #self.butcrode = Gtk.Button(label="Crop detect")
  509.                 #self.butcrode.connect("clicked", self.on_butcrode_clicked)
  510.                 self.butcrode.set_sensitive(False)
  511.                 self.buttest = Gtk.Button(label="Test")
  512.                 self.buttest.connect("clicked", self.on_buttest_clicked)
  513.                 self.buttest.set_sensitive(False)
  514.                 self.buttestspl = Gtk.Button(label="Test split")
  515.                 self.buttestspl.connect("clicked", self.on_buttestspl_clicked)
  516.                 self.buttestspl.set_sensitive(False)
  517.                
  518.                 self.gridterm.attach(self.filechooserbutton, 0, 0, 1, 1)
  519.                 self.gridterm.attach(self.butprobe, 1, 0, 1, 1)
  520.                 self.gridterm.attach(self.butplay, 2, 0, 1, 1)
  521.                 #self.gridterm.attach(self.butcrode, 3, 0, 1, 1)
  522.                 self.gridterm.attach(self.buttest, 3, 0, 1, 1)
  523.                 self.gridterm.attach(self.buttestspl, 4, 0, 1, 1)
  524.                
  525.                 self.gridterm.attach(self.scroller, 0, 1, 5, 1)
  526.  
  527.         def make_volume_det(self):
  528.                 self.f_volume_det = self.make_frame_ag(3, "" , 6, 8, 8, True)
  529.                 #
  530.                 self.but_volume_det = Gtk.Button(label="Volume detect")
  531.                 self.but_volume_det.connect("clicked", self.on_but_volume_det_clicked)
  532.                 self.but_volume_det.set_sensitive(False)
  533.                 self.f_volume_det['grid'].attach(self.but_volume_det, 0, 0, 1, 1)
  534.                 #
  535.                 self.voldet_spin = Gtk.Spinner()
  536.                 self.voldet_spin.set_sensitive(False)
  537.                 self.f_volume_det['grid'].attach(self.voldet_spin, 1, 0, 1, 1)
  538.                 #
  539.                 self.label_maxvol = Gtk.Label("")
  540.                 self.f_volume_det['grid'].attach(self.label_maxvol, 2, 0, 1, 1)
  541.                 self.label_meanvol = Gtk.Label("")
  542.                 self.f_volume_det['grid'].attach(self.label_meanvol, 3, 0, 1, 1)
  543.                 #
  544.                 self.check_vol = Gtk.CheckButton("volume")
  545.                 self.check_vol.connect("toggled", self.on_volume_clicked)
  546.                 self.f_volume_det['grid'].attach(self.check_vol, 0, 1, 1, 1)
  547.                 #
  548.                 self.label_db = self.make_label("dB: ")
  549.                 self.f_volume_det['grid'].attach(self.label_db, 1, 1, 1, 1)
  550.                 self.spin_db = self.make_spinbut(0 , -6 , 20 , 0.1 , 1 , 2, True )
  551.                 self.spin_db["adj"].connect("value-changed", self.on_volume_clicked)
  552.                 self.f_volume_det['grid'].attach(self.spin_db["spinner"], 2, 1, 1, 1)
  553.                 self.label_ratio = self.make_label("ratio: ")
  554.                 self.f_volume_det['grid'].attach(self.label_ratio, 3, 1, 1, 1)
  555.                 self.label_ratio_val = Gtk.Label("")
  556.                 self.f_volume_det['grid'].attach(self.label_ratio_val, 4, 1, 1, 1)
  557.  
  558.         def make_black_detect(self):
  559.                 self.f_blackd = self.make_frame_ag(3, "" , 6, 8, 8, True)
  560.                 #
  561.                 self.but_black_det = Gtk.Button(label="Black detect")
  562.                 self.but_black_det.connect("clicked", self.on_but_black_det_clicked)
  563.                 self.but_black_det.set_sensitive(False)
  564.                 self.f_blackd['grid'].attach(self.but_black_det, 0, 0, 1, 1)
  565.                 #
  566.                 self.blackdet_spin = Gtk.Spinner()
  567.                 self.blackdet_spin.set_sensitive(False)
  568.                 self.f_blackd['grid'].attach(self.blackdet_spin, 1, 0, 1, 1)
  569.                 #
  570.                 scrolledwindow = Gtk.ScrolledWindow()
  571.                 #scrolledwindow.set_hexpand(True)
  572.                 scrolledwindow.set_vexpand(True)
  573.                 self.textview = Gtk.TextView()
  574.                 self.textbuffer = self.textview.get_buffer()
  575.                 self.textview.set_editable(False)
  576.                 self.textview.set_cursor_visible(False)
  577.                 self.textview.modify_font(Pango.font_description_from_string('Monospace 9'))
  578.                 scrolledwindow.add(self.textview)
  579.                 self.black_dt_init_str = 'Detect black frames can take some time,\ndepending on the length of the video.'
  580.                 self.textbuffer.set_text(self.black_dt_init_str)
  581.                 self.f_blackd['grid'].attach(scrolledwindow, 2, 0, 3, 3)
  582.                
  583.         def make_info_frame(self):
  584.                 self.f_info = self.make_frame_ag(3, "  info  " , 6, 8, 8, True)
  585.                 scrolledwindow1 = Gtk.ScrolledWindow()
  586.                 scrolledwindow1.set_hexpand(True)
  587.                 scrolledwindow1.set_vexpand(True)
  588.                 self.textview_info = Gtk.TextView()
  589.                 self.textbuffer_info = self.textview_info.get_buffer()
  590.                 self.textview_info.set_editable(False)
  591.                 self.textview_info.set_cursor_visible(False)
  592.                 self.textview_info.modify_font(Pango.font_description_from_string('Monospace 9'))
  593.                 scrolledwindow1.add(self.textview_info)
  594.                 self.f_info['grid'].attach(scrolledwindow1, 0, 0, 3, 3)
  595.        
  596.         def make_audio_codec(self):
  597.                 # tooltips
  598.                 self.faac_q_str = 'faac vbr: q 80 ~96k, 90 ~100k, 100 ~118k, 120 ~128k, 160 ~156k'
  599.                 #
  600.                 self.f_3acodec = self.make_frame_ag(3, "  audio codec  " , 6, 8, 8, True)
  601.                 #
  602.                 self.box_ac = self.make_combobox(
  603.                   "libfaac quality (def. 100)",
  604.                   "aacplus (64 Kb/s)",
  605.                   "aacplus (32 Kb/s)",
  606.                   "no audio",
  607.                   "audio copy"
  608.                   )
  609.                 self.f_3acodec['grid'].attach(self.box_ac['cbox'], 0, 0, 1, 1)
  610.                 self.box_ac['cbox'].connect("changed", self.on_codec_audio_changed)
  611.                 #
  612.                 self.spin_ac = self.make_spinbut(100 , 80 , 160 , 10 , 1 , 0, True )
  613.                 self.spin_ac["adj"].connect("value-changed", self.on_codec_clicked)
  614.                 self.f_3acodec['grid'].attach(self.spin_ac["spinner"], 1, 0, 1, 1)
  615.                 self.spin_ac['spinner'].set_tooltip_text(self.faac_q_str)
  616.                 # placeholder
  617.                 self.f_3acodec['grid'].attach(self.make_label(""), 2, 0, 1, 1)
  618.                 #
  619.                 self.f3ac_label_out = Gtk.Label("-aaq")
  620.                 self.f_3acodec['grid'].attach(self.f3ac_label_out, 3, 0, 1, 1)
  621.        
  622.         def make_video_codec(self):
  623.                 self.f_3vcodec = self.make_frame_ag(3, "  video codec  " , 6, 8, 8, True)
  624.                 self.box_vcodec = self.make_combobox(
  625.                   "libx264",
  626.                   "video copy"
  627.                   )
  628.                 self.f_3vcodec['grid'].attach(self.box_vcodec['cbox'], 0, 0, 1, 1)
  629.                 self.box_vcodec['cbox'].connect("changed", self.on_codec_video_changed)
  630.                 #
  631.                 self.box_vrc = self.make_combobox(
  632.                   "crf",
  633.                   "bitrate kb/s"
  634.                   )
  635.                 self.f_3vcodec['grid'].attach(self.box_vrc['cbox'], 1, 0, 1, 1)
  636.                 self.box_vrc['cbox'].connect("changed", self.on_codec_vrc_changed)
  637.                 #
  638.                 self.spin_vc = self.make_spinbut(21.3 , 15 , 40 , 0.1 , 1 , 1, True )
  639.                 self.spin_vc["adj"].connect("value-changed", self.on_codec_clicked)
  640.                 self.f_3vcodec['grid'].attach(self.spin_vc["spinner"], 2, 0, 1, 1)
  641.                 #
  642.                 self.f3v_label_out = Gtk.Label("-crf 21.3")
  643.                 self.f_3vcodec['grid'].attach(self.f3v_label_out, 3, 0, 1, 1)
  644.                 # x264 options
  645.                 self.box_3v_preset = self.make_combobox(
  646.                   "superfast",
  647.                   "veryfast",
  648.                   "faster",
  649.                   "fast",
  650.                   "medium",
  651.                   "slow"
  652.                   ) #(-superfast -veryfast -fast, -medium, -slow, default: faster)
  653.                 self.box_3v_preset['cbox'].set_active(2)
  654.                 self.f_3vcodec['grid'].attach(self.box_3v_preset['cbox'], 0, 1, 1, 1)
  655.                 self.box_3v_preset['cbox'].connect("changed", self.on_preset_changed)
  656.        
  657.         def make_other_opts(self):
  658.                 #
  659.                 subcopy_tooltip_srt = 'if false srt->ass'
  660.                 cpu_tooltip_srt = 'if false -thread 0'
  661.                 nometa_tooltip_srt = 'if true --map_metadata -1'
  662.                 #
  663.                 self.f3_oth = self.make_frame_ag(3, "  other options  " , 6, 8, 8, True)
  664.                 #
  665.                 self.check_2pass = Gtk.CheckButton("2 pass")
  666.                 self.check_2pass.connect("toggled", self.on_f3_other_clicked)
  667.                 self.f3_oth['grid'].attach(self.check_2pass, 0, 0, 1, 1)
  668.                 self.check_2pass.set_sensitive(False)
  669.                 #
  670.                 self.check_nometa = Gtk.CheckButton("no metatag")
  671.                 self.check_nometa.connect("toggled", self.on_f3_other_clicked)
  672.                 self.check_nometa.set_tooltip_text(nometa_tooltip_srt)
  673.                 self.f3_oth['grid'].attach(self.check_nometa, 1, 0, 1, 1)
  674.                 #
  675.                 #
  676.                 self.check_scopy = Gtk.CheckButton("sub copy")
  677.                 self.check_scopy.connect("toggled", self.on_f3_other_clicked)
  678.                 self.check_scopy.set_tooltip_text(subcopy_tooltip_srt)
  679.                 self.f3_oth['grid'].attach(self.check_scopy, 2, 0, 1, 1)
  680.                 #
  681.                 self.check_cpu = Gtk.CheckButton("cpu 3")
  682.                 self.check_cpu.connect("toggled", self.on_f3_other_clicked)
  683.                 self.check_cpu.set_tooltip_text(cpu_tooltip_srt)
  684.                 self.f3_oth['grid'].attach(self.check_cpu, 3, 0, 1, 1)
  685.                 #
  686.                 self.check_debug = Gtk.CheckButton("debug")
  687.                 self.check_debug.connect("toggled", self.on_f3_other_clicked)
  688.                 self.f3_oth['grid'].attach(self.check_debug, 4, 0, 1, 1)
  689.                 #
  690.                 self.box_oth_container = self.make_combobox(
  691.                   "MKV",
  692.                   "MP4"
  693.                   )
  694.                 self.f3_oth['grid'].attach(self.box_oth_container['cbox'], 5, 0, 1, 1)
  695.                 self.box_oth_container['cbox'].connect("changed", self.on_container_changed)
  696.                
  697.         def make_run_730(self):
  698.                 self.f3_run = self.make_frame_ag(3, "  execute in terminal  " , 6, 8, 8, True)
  699.                 #
  700.                 self.f3_run_indir_label = Gtk.Label("")
  701.                 self.f3_run['grid'].attach(self.f3_run_indir_label, 0, 0, 1, 1)
  702.                 self.f3_run_file = Gtk.Label("no input file")
  703.                 self.f3_run_file.set_tooltip_text('')
  704.                 self.f3_run['grid'].attach(self.f3_run_file, 1, 0, 2, 1)
  705.                 self.f3_dur_file = Gtk.Label("")
  706.                 self.f3_run['grid'].attach(self.f3_dur_file, 3, 0, 1, 1)
  707.                 #
  708.                 self.but_f3_run = Gtk.Button(label="RUN")
  709.                 self.but_f3_run.connect("clicked", self.on_but_f3_run_clicked)
  710.                 self.but_f3_run.set_sensitive(False)
  711.                 self.f3_run['grid'].attach(self.but_f3_run, 3, 1, 1, 1)
  712.                 #
  713.                 #self.f3_run_outdir_label = Gtk.Label("out dir:  " + os.getcwd())
  714.                 self.f3_run_outdir_label = Gtk.Label("")
  715.                 self.f3_run_outdir_label.set_markup("<b>out dir:  </b>" + os.getcwd())
  716.                 self.f3_run['grid'].attach(self.f3_run_outdir_label, 0, 1, 2, 1)
  717.                 #
  718.                 # filechooserbutton
  719.                 self.out_dir_chooserbut = Gtk.FileChooserButton(title="Dir out")
  720.                 self.out_dir_chooserbut.set_action(2)
  721.                 #self.filechooserbutton.set_action(2) # 0 open file, 1 save file, 2 select folder, 3 create folder
  722.                 acturi = "file://" + os.getcwd()
  723.                 self.out_dir_chooserbut.set_uri(acturi)
  724.                 self.f3_run['grid'].attach(self.out_dir_chooserbut, 2, 1, 1, 1)
  725.                 self.out_dir_chooserbut.connect("selection-changed", self.dir_changed)
  726.                
  727.                
  728.         # signal handlers -----------------------------------------------
  729.        
  730.         def on_window_destroy(self, *args):
  731.                 Gtk.main_quit(*args)
  732.        
  733.         def on_scale_clicked(self, button):
  734.                 if (self.box1['cbox'].get_active() != 0):
  735.                         self.calcola_scale()
  736.                 else:
  737.                         self.scalestr = ""
  738.                         self.outfilter()
  739.                  
  740.         def on_deint_clicked(self, button):
  741.                 self.deint_str = ""
  742.                 if self.checkdeint.get_active():
  743.                         deint_val = self.box_deint['cbox'].get_active()
  744.                         if (deint_val == 0):
  745.                                 self.deint_str = "yadif"
  746.                         elif (deint_val == 1):
  747.                                 self.deint_str = "pp=lb"
  748.                 self.outfilter()
  749.                        
  750.         def on_dn_clicked(self, button):
  751.                 self.dn_str = ""
  752.                 if self.checkdn.get_active():
  753.                         dn_val = int( self.spindn['adj'].get_value() )
  754.                         self.dn_str = "hqdn3d=" + str(dn_val)
  755.                 self.outfilter()
  756.                    
  757.         def on_crop_clicked(self, button):
  758.                 ok = 0
  759.                 self.crop_str = ""
  760.                 if self.checkcr.get_active():
  761.                         ok = 1
  762.                 if ok:
  763.                         inW = int(self.spincw['adj'].get_value())
  764.                         inH = int(self.spinch['adj'].get_value())
  765.                         crT = int(self.spinct['adj'].get_value())
  766.                         crB = int(self.spincb['adj'].get_value())
  767.                         crL = int(self.spincl['adj'].get_value())
  768.                         crR = int(self.spincr['adj'].get_value())      
  769.                         finW = inW - crL - crR
  770.                         finH = inH - crT - crB
  771.                         if ( (finW < 100) or (finH < 100) ):
  772.                                 self.crop_str = ""
  773.                         else:
  774.                                 self.crop_str = "crop=" + str(finW) + ":" \
  775.                                  + str(finH) + ":" \
  776.                                  + str(crL)  + ":" \
  777.                                  + str(crT)
  778.                 if (self.box2['cbox'].get_active() != 2):
  779.                         self.outfilter()
  780.                 else:
  781.                         self.on_scale_clicked(button)
  782.                
  783.         def file_changed(self, filechooserbutton):              
  784.                 if self.filechooserbutton.get_filename():
  785.                         self.butplay.set_sensitive(True) # low part ---------
  786.                         self.butprobe.set_sensitive(True)
  787.                         self.preview_logic() # test and testsplit
  788.                         #self.buttest.set_sensitive(True)
  789.                         #self.buttestspl.set_sensitive(True)
  790.                         self.butcrode.set_sensitive(True) # crop ----------
  791.                         self.spinct['adj'].set_value(0)
  792.                         self.spincb['adj'].set_value(0)
  793.                         self.spincl['adj'].set_value(0)
  794.                         self.spincr['adj'].set_value(0)                
  795.                         self.but_volume_det.set_sensitive(True) # volume detect
  796.                         self.but_volume_det.set_label("Volume detect")
  797.                         self.label_meanvol.set_label("")
  798.                         self.label_maxvol.set_label("")
  799.                         self.spin_db["adj"].set_value(0)
  800.                         self.but_black_det.set_sensitive(True) # black  detect
  801.                         self.textbuffer.set_text(self.black_dt_init_str)
  802.                         self.but_f3_run.set_sensitive(True) # 730 run
  803.                         #
  804.                         self.command = "clear" + "\n"
  805.                         length = len(self.command)
  806.                         self.terminal.feed_child(self.command, length)
  807.                         # need ffprobe
  808.                         filename = self.filechooserbutton.get_filename()
  809.                         self.f3_run_indir_label.set_label(os.path.dirname(filename))
  810.                         #
  811.                         file_4_label = os.path.basename(filename)
  812.                         if ( len(file_4_label) > 50):
  813.                                 a = file_4_label[:46]
  814.                                 b = '  ...  '
  815.                                 c = file_4_label[-4:]
  816.                                 file_4_label = a + b + c
  817.                         self.f3_run_file.set_label(file_4_label)
  818.                         cmnd = ['ffprobe', '-show_format', '-show_streams', '-pretty', '-loglevel', 'quiet', filename]
  819.                         p = subprocess.Popen(cmnd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  820.                         out, err =  p.communicate()
  821.                         out = out.decode() # python3
  822.                         self.get_info(out)
  823.                        
  824.         def get_info(self, out):
  825.                 def form_to_3(in_str):
  826.                         '''
  827.                        bitrate and size info formatting
  828.                        '''
  829.                         a = in_str.split(' ')[0]
  830.                         if len(in_str.split(' ')) == 2:
  831.                                 b = in_str.split(' ')[1]
  832.                                 a = float(a)
  833.                                 result = "{0:.3f}".format(a ) + " " + b
  834.                         else:
  835.                                 result = 'N/A'
  836.                         return result
  837.                 # x scale w h, duration label p3
  838.                 for line in out.split('\n'):
  839.                         line = line.strip()
  840.                         if line.startswith('width='):
  841.                                 s = line
  842.                                 width = s.split('width=', 1)
  843.                                 #print "Video pixel width is: %s" % width[1]
  844.                                 self.video_width = width[1]
  845.                                 self.spincw['adj'].set_value(float(self.video_width)) #mettere decimali se no non si vede
  846.                                 self.spincw['spinner'].set_sensitive(False)
  847.                         elif line.startswith('height='):
  848.                                 s = line
  849.                                 height = s.split('height=', 1)
  850.                                 #print "Video pixel height is: %s" % height[1]
  851.                                 self.video_height = height[1]    
  852.                                 self.spinch['adj'].set_value(float(self.video_height)) #mettere decimali se no non si vede
  853.                                 self.spinch['spinner'].set_sensitive(False)
  854.                                 if self.add_1_1:
  855.                                         self.box2['list'].append(["as input"])
  856.                                 self.add_1_1 = False
  857.                         elif line.startswith('duration='):
  858.                                 s = line
  859.                                 duration = s.split('duration=', 1)
  860.                                 dur = duration[1].split('.')
  861.                                 self.f3_dur_file.set_label(dur[0])
  862.                 #x self.info_str
  863.                 self.info_str = ""
  864.                 is_stream = 0
  865.                 is_format = 0
  866.                 for line in out.split('\n'):
  867.                         line = line.strip()
  868.                         if line.startswith('[STREAM]'):
  869.                                 self.info_str = self.info_str + "STREAM "
  870.                                 is_stream = 1
  871.                         elif line.startswith('[/STREAM]'):
  872.                                 self.info_str = self.info_str + "\n"
  873.                                 is_stream = 0
  874.                         elif (line.startswith('index=') and (is_stream == 1)):
  875.                                 s = line
  876.                                 info = s.split('=')[1]  
  877.                                 self.info_str = self.info_str + info + ": "
  878.                         elif (line.startswith('codec_name=') and (is_stream == 1)):
  879.                                 s = line
  880.                                 info = s.split('=')[1]  
  881.                                 self.info_str = self.info_str + info + ", "
  882.                         elif (line.startswith('profile=') and (is_stream == 1)):
  883.                                 s = line
  884.                                 info = s.split('=')[1]  
  885.                                 self.info_str = self.info_str + "profile=" +info + ", "
  886.                         elif (line.startswith('codec_type=') and (is_stream == 1)):
  887.                                 s = line
  888.                                 info = s.split('=')[1]  
  889.                                 self.info_str = self.info_str + info + ", "
  890.                         elif (line.startswith('width=') and (is_stream == 1)):
  891.                                 s = line
  892.                                 info = s.split('=')[1]  
  893.                                 self.info_str = self.info_str + info + "x"
  894.                         elif (line.startswith('height=') and (is_stream == 1)):
  895.                                 s = line
  896.                                 info = s.split('=')[1]  
  897.                                 self.info_str = self.info_str + info + ", "
  898.                         elif (line.startswith('sample_aspect_ratio=') and (is_stream == 1)):
  899.                                 s = line
  900.                                 info = s.split('=')[1]  
  901.                                 self.info_str = self.info_str + "SAR=" + info + ", "
  902.                         elif (line.startswith('display_aspect_ratio=') and (is_stream == 1)):
  903.                                 s = line
  904.                                 info = s.split('=')[1]  
  905.                                 self.info_str = self.info_str + "DAR=" + info + ", "
  906.                         elif (line.startswith('pix_fmt=') and (is_stream == 1)):
  907.                                 s = line
  908.                                 info = s.split('=')[1]  
  909.                                 self.info_str = self.info_str + info + ", "
  910.                         elif (line.startswith('sample_rate=') and (is_stream == 1)):
  911.                                 s = line
  912.                                 info = s.split('=')[1]
  913.                                 info = form_to_3(info)
  914.                                 self.info_str = self.info_str + "samplerate=" + info + ", "
  915.                         elif (line.startswith('channels=') and (is_stream == 1)):
  916.                                 s = line
  917.                                 info = s.split('=')[1]  
  918.                                 self.info_str = self.info_str + "channels=" + info + ", "
  919.                         elif (line.startswith('r_frame_rate=') and (is_stream == 1)):
  920.                                 s = line
  921.                                 info = s.split('=')[1]
  922.                                 a = info.split('/')[0]
  923.                                 b = info.split('/')[1]
  924.                                 a = float(a)
  925.                                 b = float(b)
  926.                                 if ((a > 0) and (b > 0)):
  927.                                         c = float(a)/float(b)
  928.                                         info = "{0:0.2f}".format(c)
  929.                                         self.info_str = self.info_str + info + " fps, "
  930.                         elif (line.startswith('bit_rate=') and (is_stream == 1)):
  931.                                 s = line
  932.                                 info = s.split('=')[1]
  933.                                 info = form_to_3(info)
  934.                                 self.info_str = self.info_str + "bitrate=" + info + ", "
  935.                         elif (line.startswith('TAG:language=') and (is_stream == 1)):
  936.                                 s = line
  937.                                 info = s.split('=')[1]  
  938.                                 self.info_str = self.info_str + "lang=" + info + ", "
  939.                         elif line.startswith('[FORMAT]'):
  940.                                 self.info_str = self.info_str + "FORMAT "
  941.                                 is_format = 1
  942.                         elif line.startswith('[/FORMAT]'):
  943.                                 #self.info_str = self.info_str + "/n"
  944.                                 is_format = 0
  945.                         elif (line.startswith('nb_streams=') and (is_format == 1)):
  946.                                 s = line
  947.                                 info = s.split('=')[1]  
  948.                                 self.info_str = self.info_str + "streams=" + info + ", "
  949.                         elif (line.startswith('duration=') and (is_format == 1)):
  950.                                 s = line
  951.                                 info = s.split('=')[1]  
  952.                                 info = info.split('.')[0]
  953.                                 self.info_str = self.info_str + "duration=" + info + ", "
  954.                         elif (line.startswith('size=') and (is_format == 1)):
  955.                                 s = line
  956.                                 info = s.split('=')[1]
  957.                                 info = form_to_3(info)
  958.                                 self.info_str = self.info_str + "size=" + info + ", "
  959.                         elif (line.startswith('bit_rate=') and (is_format == 1)):
  960.                                 s = line
  961.                                 info = s.split('=')[1]
  962.                                 info = form_to_3(info)
  963.                                 self.info_str = self.info_str + "bitrate=" + info + ", "
  964.                 self.textbuffer_info.set_text(self.info_str)
  965.                 self.f3_run_file.set_tooltip_text(self.info_str)
  966.                 self.check_map.set_tooltip_text(self.info_str)
  967.                 self.check_time.set_tooltip_text(self.info_str)
  968.        
  969.         def on_butplay_clicked(self, button):
  970.                 self.command = "ffplay \"" + self.filechooserbutton.get_filename() + "\"" +"\n"
  971.                 length = len(self.command)
  972.                 self.terminal.feed_child(self.command, length)
  973.                
  974.         def on_butprobe_clicked(self, button):
  975.                 self.command = "ffprobe \"" + self.filechooserbutton.get_filename() + "\""  + " 2>&1 | grep 'Input\|Duration\|Stream'" + "\n"
  976.                 length = len(self.command)
  977.                 self.terminal.feed_child(self.command, length)    
  978.                
  979.         def on_butcrode_clicked(self, button):
  980.                 # need ffmpeg
  981.                 self.butcrode.set_sensitive(False)
  982.                 filename = self.filechooserbutton.get_filename()
  983.                 #cmnd = ['ffplay' , '-vf', 'cropdetect', '-autoexit' ,'-ss', '60' , '-t' , '1',  filename]
  984.                 cmnd = "ffmpeg -i " + "\"" + filename + "\"" + " -ss 60 -t 1 -vf cropdetect -f null - 2>&1 | awk \'/crop/ { print $NF }\' | tail -1"
  985.                 p = subprocess.Popen(cmnd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
  986.                 out, err =  p.communicate()
  987.                 out = out.decode()
  988.                 for line in out.split('\n'):
  989.                         line = line.strip()
  990.                         if "crop=" in line:  
  991.                                 aa = line.split('crop=', 1)
  992.                                 aaa = aa[1]
  993.                                 listdata = aaa.split(':')
  994.                                 w = listdata[0]
  995.                                 h = listdata[1]
  996.                                 offx = listdata[2]
  997.                                 offy = listdata[3]
  998.                                 ctop = int(offy)
  999.                                 cbot = int(self.video_height) - int(offy) -int(h)
  1000.                                 cleft = int(offx)
  1001.                                 cright = int(self.video_width) - int(offx) -int(w)
  1002.                                 self.spinct['adj'].set_value(float(ctop))
  1003.                                 self.spincb['adj'].set_value(float(cbot))
  1004.                                 self.spincl['adj'].set_value(float(cleft))
  1005.                                 self.spincr['adj'].set_value(float(cright))  
  1006.                                 break
  1007.                 self.butcrode.set_sensitive(True)
  1008.                
  1009.         def on_buttest_clicked(self, button):
  1010.                 # -map preview: only with none -vf option  
  1011.                 if (self.maps_str == ""):
  1012.                         self.command = "ffplay \"" + self.filechooserbutton.get_filename() + "\" " \
  1013.                          + " " + self.time_final_srt + " " \
  1014.                          + "-vf "  + self.filter_test_str + "\n"
  1015.                 else:
  1016.                         self.command = "ffmpeg -i \"" + self.filechooserbutton.get_filename() + "\" " \
  1017.                          + self.maps_str  + " " + self.time_final_srt + " "
  1018.                         if (self.filter_test_str != ""):
  1019.                                 self.command = self.command + " -vf "  + self.filter_test_str
  1020.                         self.command = self.command +  " -c copy -f matroska - | ffplay -" + "\n"
  1021.                 length = len(self.command)
  1022.                 self.terminal.feed_child(self.command, length)
  1023.                
  1024.         def on_buttestspl_clicked(self, button):
  1025.                 self.command = "ffplay \"" + self.filechooserbutton.get_filename() + "\" " \
  1026.                   + " " + self.time_final_srt + " " \
  1027.                   + " -vf \"split[a][b]; [a]pad=iw:(ih*2)+4:color=888888 [src]; [b]" \
  1028.                   + self.filter_test_str + " [filt]; [src][filt]overlay=((main_w - w)/2):main_h/2\"" + "\n"
  1029.                 length = len(self.command)
  1030.                 self.terminal.feed_child(self.command, length)
  1031.        
  1032.         def on_but_volume_det_clicked(self, button):
  1033.                 self.but_volume_det.set_sensitive(False)
  1034.                 self.voldet_spin.set_sensitive(True)
  1035.                 self.voldet_spin.start()
  1036.                 def my_thread(obj):
  1037.                         filename = self.filechooserbutton.get_filename()        
  1038.                         #cmnd = "ffmpeg -i " + "\"" + filename + "\" " + " -vn -af volumedetect -f null /dev/null 2>&1 | grep \'mean_volume\\|max_volume\'"
  1039.                         cmnd = ['ffmpeg', '-i', filename, '-vn', '-af', 'volumedetect', '-f', 'null', '/dev/null']
  1040.                         p = subprocess.Popen(cmnd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
  1041.                         while True:
  1042.                                 line = p.stderr.read()
  1043.                                 if not line:
  1044.                                         break
  1045.                                 out = line.decode()
  1046.                                 for line in out.split('\n'):
  1047.                                         line = line.strip()
  1048.                                         if "mean_volume:" in line:  
  1049.                                                 aa = line.split('mean_volume:', 1)
  1050.                                                 mea_vol_det = aa[1]
  1051.                                                 self.label_meanvol.set_label("Mean vol: " + mea_vol_det)
  1052.                                         if "max_volume:" in line:  
  1053.                                                 aa = line.split('max_volume:', 1)
  1054.                                                 max_vol_det = aa[1]
  1055.                                                 self.label_maxvol.set_label("Max vol: " + max_vol_det)
  1056.                                 self.but_volume_det.set_label("volume detected")
  1057.                                 self.voldet_spin.stop()
  1058.                                 self.voldet_spin.set_sensitive(False)
  1059.                         p.communicate()
  1060.                 self.but_volume_det.set_label("Wait")  
  1061.                 threading.Thread(target=my_thread, args=(self,)).start()
  1062.        
  1063.         def on_volume_clicked(self, button):
  1064.                 self.label_ratio_val.set_label("")
  1065.                 self.final_af_str = ""
  1066.                 db = self.spin_db["adj"].get_value()
  1067.                 if (db != 0.00):
  1068.                         ratio = pow(10, (db/20.0))
  1069.                         ratio = float("{0:.3f}".format(ratio))    
  1070.                         self.label_ratio_val.set_label(str(ratio))
  1071.                         self.final_af_str = "-af volume=" + str(ratio)
  1072.                 self.make_p3_out_command()
  1073.        
  1074.         def on_map_clicked(self, button):
  1075.                 self.map_label.set_label("")
  1076.                 self.maps_str = ""
  1077.                 if self.check_map.get_active():
  1078.                         map_in = self.entry_map.get_chars(0, -1)
  1079.                         if (map_in != ""):
  1080.                                 map_l = map_in.split(",")
  1081.                                 for i in range(len(map_l)):
  1082.                                         if self.maps_str == "":
  1083.                                                 self.maps_str = self.maps_str + "-map " + map_l[i]
  1084.                                         else:
  1085.                                                 self.maps_str = self.maps_str + " -map " + map_l[i]
  1086.                                 self.map_label.set_label(self.maps_str)
  1087.                 self.outfilter()
  1088.                 self.make_p3_out_command()
  1089.                
  1090.         def on_time_clicked(self, button):
  1091.                 self.time_final_srt = ""
  1092.                        
  1093.                 if self.check_time.get_active():
  1094.                         timein = 0
  1095.                         timeout = 0
  1096.                         timedur = 0
  1097.                         timein_ent = self.entry_timein.get_chars(0, -1)
  1098.                         if (timein_ent != ""):
  1099.                                 if timein_ent.isdigit():
  1100.                                         timein = int(timein_ent)        
  1101.                                 else:  
  1102.                                         timein = self.hms2sec(timein_ent)
  1103.                         timeout_ent = self.entry_timeout.get_chars(0, -1)
  1104.                         if (timeout_ent != ""):
  1105.                                 if timeout_ent.isdigit():
  1106.                                         timeout = int(timeout_ent)
  1107.                                         timedur = timeout - timein
  1108.                                 else:  
  1109.                                         timeout = self.hms2sec(timeout_ent)
  1110.                                         timedur = timeout - timein
  1111.                         if (timein != 0):
  1112.                                 self.time_final_srt = self.time_final_srt + " -ss " + str(timein)  
  1113.                         if (timedur > 0):
  1114.                                 self.time_final_srt = self.time_final_srt + " -t " + str(timedur)    
  1115.                 self.outfilter()
  1116.                 self.make_p3_out_command()
  1117.        
  1118.         def on_codec_audio_changed(self, button):
  1119.                 a_cod = self.box_ac['cbox'].get_active()
  1120.                 if (a_cod == 0): # aaq
  1121.                         self.spin_ac['spinner'].set_sensitive(True)
  1122.                         self.spin_ac['adj'].set_value(100.0)
  1123.                         self.spin_ac['spinner'].set_tooltip_text(self.faac_q_str)
  1124.                 else:
  1125.                         self.spin_ac['spinner'].set_sensitive(False)
  1126.                         self.spin_ac['spinner'].set_tooltip_text('')
  1127.                 self.on_codec_clicked(button)
  1128.        
  1129.         def on_codec_video_changed(self, button):
  1130.                 self.on_codec_clicked(button)
  1131.        
  1132.         def on_codec_vrc_changed(self, button):
  1133.                 self.video_rc = self.box_vrc['cbox'].get_active() #0 crf, 1 kb/s
  1134.                 if (self.video_rc == 0):
  1135.                         self.adj_change(self.spin_vc['adj'], 21.3, 15, 40, 0.1, 1)
  1136.                         self.spin_vc['adj'].set_value(21.3)
  1137.                         #self.check_2pass.set_active(False)
  1138.                         self.check_2pass.set_sensitive(False)
  1139.                 elif (self.video_rc == 1):
  1140.                         self.adj_change(self.spin_vc['adj'], 730, 300, 4000, 10, 100)
  1141.                         self.spin_vc['adj'].set_value(730.0)
  1142.                         self.check_2pass.set_sensitive(True)
  1143.        
  1144.         def on_codec_clicked(self, button):
  1145.                 self.a_copy = 0
  1146.                 self.v_copy = 0
  1147.                 self.final_codec_str = ""
  1148.                 audio_codec = self.box_ac['cbox'].get_active() # 0 aaq. 1 a64 , 2 a32 , 3 audio none
  1149.                 if (audio_codec == 0):
  1150.                         audio_codec_str = "-aaq"
  1151.                         quality_faac = self.spin_ac['adj'].get_value()
  1152.                         if (quality_faac != 100):
  1153.                                 audio_codec_str = audio_codec_str + " " + str(int(quality_faac))
  1154.                 elif (audio_codec == 1):
  1155.                         audio_codec_str = "-a64"
  1156.                 elif (audio_codec == 2):
  1157.                         audio_codec_str = "-a32"
  1158.                 elif (audio_codec == 3):
  1159.                         audio_codec_str = "-an"
  1160.                 elif (audio_codec == 4):
  1161.                         audio_codec_str = "-acopy"
  1162.                         self.a_copy = 1
  1163.                 self.f3ac_label_out.set_label(audio_codec_str)
  1164.                 #
  1165.                 self.pg2_str = audio_codec_str
  1166.                 # video
  1167.                 video_codec = self.box_vcodec['cbox'].get_active() #0 x264, 1 -vcopy
  1168.                 if (video_codec == 1):
  1169.                         video_codec_str = "-vcopy"
  1170.                         self.v_copy = 1
  1171.                         self.box_vrc['cbox'].set_sensitive(False)
  1172.                         self.spin_vc['spinner'].set_sensitive(False)
  1173.                         self.box_3v_preset['cbox'].set_active(2)
  1174.                         self.box_3v_preset['cbox'].set_sensitive(False)
  1175.                 else:
  1176.                         self.box_vrc['cbox'].set_sensitive(True)
  1177.                         self.spin_vc['spinner'].set_sensitive(True)
  1178.                         self.box_3v_preset['cbox'].set_sensitive(True)
  1179.                         self.video_rc = self.box_vrc['cbox'].get_active() #0 crf, 1 kb/s
  1180.                         if (self.video_rc == 0):        
  1181.                                 video_codec_str = "-crf " + str(self.spin_vc['adj'].get_value())
  1182.                         elif (self.video_rc == 1):
  1183.                                 video_codec_str = "-b " + str(int(self.spin_vc['adj'].get_value()))
  1184.                
  1185.                 self.f3v_label_out.set_label(video_codec_str)    
  1186.                 self.final_codec_str = audio_codec_str + " " + video_codec_str
  1187.                 self.make_p3_out_command()
  1188.        
  1189.         def on_preset_changed(self, button):
  1190.                 self.preset_str = "-faster"
  1191.                 preset = self.box_3v_preset['cbox'].get_active()
  1192.                 # 0 -superfast, 1 -veryfast, 2 -faster, 3 -fast, 4 -medium, 5 -slow, default: 2 faster
  1193.                 if (preset == 0):
  1194.                         self.preset_str = "-superfast"
  1195.                 if (preset == 1):
  1196.                         self.preset_str = "-veryfast"
  1197.                 if (preset == 3):
  1198.                         self.preset_str = "-fast"
  1199.                 if (preset == 4):
  1200.                         self.preset_str = "-medium"
  1201.                 if (preset == 5):
  1202.                         self.preset_str = "-slow"
  1203.                 self.make_p3_out_command()
  1204.                
  1205.         def on_f3_other_clicked(self, button):
  1206.                 self.final_other_str = ""
  1207.                 if self.check_nometa.get_active():
  1208.                         self.final_other_str = "-nometa"
  1209.                 if self.check_2pass.get_active():
  1210.                         if (self.final_other_str == ""):
  1211.                                 self.final_other_str = "" + "-pass 2"
  1212.                         else:
  1213.                                 self.final_other_str = self.final_other_str + " " + "-pass 2"
  1214.                 if self.check_cpu.get_active():
  1215.                         if (self.final_other_str == ""):
  1216.                                 self.final_other_str = "-cpu 3"
  1217.                         else:
  1218.                                 self.final_other_str = self.final_other_str + " " + "-cpu 3"
  1219.                 if self.check_scopy.get_active():
  1220.                         if (self.final_other_str == ""):
  1221.                                 self.final_other_str = "-scopy"
  1222.                         else:
  1223.                                 self.final_other_str = self.final_other_str + " " + "-scopy"    
  1224.                 if self.check_debug.get_active():
  1225.                         if (self.final_other_str == ""):
  1226.                                 self.final_other_str = "debug"
  1227.                         else:
  1228.                                 self.final_other_str = self.final_other_str + " " + "debug"
  1229.                 self.make_p3_out_command()
  1230.                
  1231.         def on_container_changed(self,button):
  1232.                 container = self.box_oth_container['cbox'].get_active() #0 mkv, 1 mp4
  1233.                 if (container == 1):
  1234.                         self.container_str = "-mp4"
  1235.                 else:
  1236.                         self.container_str = "-mkv"
  1237.                 self.make_p3_out_command()
  1238.                
  1239.         def on_but_f3_run_clicked(self, button):
  1240.                 self.command = "/home/mc/730-ffmpeg-tool-2 \"" \
  1241.                   + self.filechooserbutton.get_filename() + "\" " \
  1242.                   + self.p3_command + "\n"
  1243.                 length = len(self.command)
  1244.                 self.terminal.feed_child(self.command, length)
  1245.              
  1246.         def dir_changed(self, button):
  1247.                 if self.first_run:
  1248.                         select = self.out_dir_chooserbut.get_uri()
  1249.                         decoded = url2pathname(select)
  1250.                         newdir = decoded.split('//')[1]
  1251.                         self.command = "cd " + "\"" + newdir + "\"" + "\n"
  1252.                         length = len(self.command)
  1253.                         self.terminal.feed_child(self.command, length)
  1254.                         self.f3_run_outdir_label.set_markup("<b>out dir:  </b>" + newdir)
  1255.                 else:
  1256.                         self.first_run = 1
  1257.                        
  1258.         def on_but_black_det_clicked(self, button):            
  1259.                 self.but_black_det.set_sensitive(False)
  1260.                 self.textbuffer.set_text('') # clear for insert from start
  1261.                 self.blackdet_spin.set_sensitive(True)
  1262.                 self.blackdet_spin.start()
  1263.                 def my_thread(obj):
  1264.                         filename = self.filechooserbutton.get_filename()
  1265.                         filein = os.path.basename(filename)
  1266.                         stri = filein +"\n"
  1267.                         start = self.textbuffer.get_start_iter()
  1268.                         self.textbuffer.insert(start, stri, -1)
  1269.                         self.but_black_det.set_label("black detectet")
  1270.                         #
  1271.                         #ffmpeg -i "A.mp4" -y -an -vf blackdetect=d=.5 -f null - 2>&1 | grep blackdetect
  1272.                         #cmnd = "ffmpeg -i " + "\"" + filename + "\"" + " -y -an -vf blackdetect=d=.5 -f null - 2>&1 | grep blackdetect"
  1273.                         cmnd = ['ffmpeg', '-i', filename, '-y', '-an', '-vf', 'blackdetect=d=.5', '-f', 'null', '/dev/null']
  1274.                         p = subprocess.Popen(cmnd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
  1275.                         while True:
  1276.                                 line = p.stderr.readline()
  1277.                                 if 'blackdetect ' in line:
  1278.                                                 a = line
  1279.                                                 b = a.split('black_start:')[1]
  1280.                                                 start = b.split(' ')[0]
  1281.                                                 st_in_s = float(start)
  1282.                                                 st_in_s = int(st_in_s)
  1283.                                                 start_in_s = ("%4.1i"% (st_in_s))  
  1284.                                                 start = self.sec2hms(start)
  1285.                                                 stri = "black start at: " + start_in_s + " s, " + start + " "
  1286.                                                 c = b.split('black_duration:')[1]
  1287.                                                 durat = c.split(' ')[0]
  1288.                                                 dur_s = float(durat)
  1289.                                                 dur_s = "{0:0=3.1f}".format(dur_s)
  1290.                                                 stri = stri + "duration: " + dur_s + "s\n"
  1291.                                                 self.textbuffer.insert_at_cursor(stri, -1)
  1292.                                 if line == '' and p.poll() != None:
  1293.                                         break
  1294.                         p.communicate()                
  1295.                         self.blackdet_spin.stop()
  1296.                         self.blackdet_spin.set_sensitive(False)
  1297.                 self.but_black_det.set_label("Wait")    
  1298.                 threading.Thread(target=my_thread, args=(self,)).start()
  1299.        
  1300.                
  1301.         # -------------------------------------  
  1302.        
  1303.         def preview_logic(self):
  1304.                 if ( not(('-map ' in self.p3_command ) or ('-vf ' in self.p3_command )) ):
  1305.                         self.buttest.set_sensitive(False)
  1306.                         self.buttestspl.set_sensitive(False)
  1307.                 elif ('-map ' in self.p3_command) and ('-vf ' in self.p3_command):
  1308.                         self.buttest.set_sensitive(False)
  1309.                         self.buttestspl.set_sensitive(False)
  1310.                 elif '-map ' in self.p3_command:
  1311.                         self.buttest.set_sensitive(True)
  1312.                         self.buttestspl.set_sensitive(False)
  1313.                 elif '-vf ' in self.p3_command:
  1314.                         self.buttest.set_sensitive(True)
  1315.                         self.buttestspl.set_sensitive(True)
  1316.        
  1317.         def calcola_scale(self):
  1318.                 self.scalestr = ""
  1319.                 numero = self.size_spinner['adj'].get_value()
  1320.                 numero = int(numero/4)*4
  1321.                 dar = self.box2['cbox'].get_active()
  1322.                 lato = self.box1['cbox'].get_active()          
  1323.                 if (dar == 1): # 4/3
  1324.                         if (lato == 1):
  1325.                                 n2 = numero/4*3
  1326.                         else:
  1327.                                 n2 = numero/3*4
  1328.                         setdar = ",setdar=4/3,setsar=1/1"
  1329.                 elif (dar == 0): # 16/9
  1330.                         if (lato == 1):
  1331.                                 n2 = numero/16*9
  1332.                         else:
  1333.                                 n2 = numero/9*16
  1334.                         setdar = ",setdar=16/9,setsar=1/1"      
  1335.                 elif (dar == 2): #1/1 same as input  
  1336.                         w = int(self.video_width)
  1337.                         h = int(self.video_height)
  1338.                         if self.checkcr.get_active():
  1339.                                 crT = int(self.spinct['adj'].get_value())
  1340.                                 crB = int(self.spincb['adj'].get_value())
  1341.                                 crL = int(self.spincl['adj'].get_value())
  1342.                                 crR = int(self.spincr['adj'].get_value())
  1343.                                 h = h - crT - crB
  1344.                                 w = w - crL - crR
  1345.                         if (lato == 1): # h                
  1346.                                 n2 = (float(h)/(w/float(numero)))  
  1347.                         else:
  1348.                                 n2 = (float(w)/(h/float(numero)))
  1349.                         setdar = ""
  1350.                 n2 = int(n2/4)*4                    
  1351.                 self.scalestr = "scale="
  1352.                 if (lato == 1):
  1353.                         self.scalestr = self.scalestr + str(numero) + ":" + str(n2)
  1354.                 else:
  1355.                         self.scalestr = self.scalestr + str(n2) + ":" + str(numero)                  
  1356.                 lanc = self.check.get_active()  
  1357.                 if lanc:
  1358.                         self.scalestr = self.scalestr + ":flags=lanczos" + setdar  
  1359.                 else:
  1360.                         self.scalestr = self.scalestr + setdar
  1361.                 self.outfilter()
  1362.                      
  1363.         def outfilter(self):
  1364.                 final_str = ""
  1365.                 if (self.deint_str != ""):
  1366.                         final_str = final_str + self.deint_str    
  1367.                 if (self.crop_str != ""):
  1368.                         if (final_str == ""):
  1369.                                 final_str = final_str + self.crop_str
  1370.                         else:
  1371.                                         final_str = final_str + "," + self.crop_str
  1372.                 if (self.scalestr != ""):
  1373.                         if (final_str == ""):
  1374.                                 final_str = final_str + self.scalestr
  1375.                         else:
  1376.                                 final_str = final_str + "," + self.scalestr
  1377.                 if (self.dn_str != ""):
  1378.                         if (final_str == ""):
  1379.                                 final_str = final_str + self.dn_str
  1380.                         else:
  1381.                                 final_str = final_str + "," + self.dn_str              
  1382.                 self.filter_test_str = final_str
  1383.                
  1384.                 if (final_str != ""):
  1385.                         self.final_vf_str = "-vf " + final_str
  1386.                 else:
  1387.                         self.final_vf_str = ""
  1388.                
  1389.                 label_str = ""          
  1390.                 if (self.maps_str != ""):
  1391.                         label_str = label_str + self.maps_str + " "  
  1392.                 if (self.time_final_srt != ""):
  1393.                         label_str = label_str + self.time_final_srt + " "
  1394.                 if (self.final_vf_str != ""):
  1395.                         label_str = label_str + self.final_vf_str
  1396.                    
  1397.                 self.labelout.set_text(label_str)      
  1398.                 self.make_p3_out_command()
  1399.                 if (self.info_str != ""):
  1400.                         self.preview_logic()    
  1401.        
  1402.         def make_p3_out_command(self):
  1403.                 pass
  1404.                 self.p3_command = ""
  1405.                 self.f3_out_label.set_label("")
  1406.                 if (self.maps_str != ""):
  1407.                         self.p3_command = self.maps_str + " "  
  1408.                 if (self.time_final_srt != ""):
  1409.                         self.p3_command = self.p3_command + self.time_final_srt + " "
  1410.                 if ( (self.final_vf_str != "") and (self.v_copy == 0) ): # check -vcopy
  1411.                         self.p3_command = self.p3_command + self.final_vf_str + " "
  1412.                 if ( (self.final_af_str != "") and (self.a_copy == 0) ):  # check -acopy
  1413.                         self.p3_command = self.p3_command + self.final_af_str + " "
  1414.                 if (self.final_codec_str != ""):
  1415.                         self.p3_command = self.p3_command + self.final_codec_str + " "
  1416.                 if (self.preset_str != "-faster"):
  1417.                         self.p3_command = self.p3_command + self.preset_str + " "
  1418.                 if (self.container_str != "-mkv"):
  1419.                         self.p3_command = self.p3_command + self.container_str + " "
  1420.                 if (self.final_other_str != ""):
  1421.                         self.p3_command = self.p3_command + self.final_other_str + " "
  1422.                 self.f3_out_label.set_label(self.p3_command)
  1423.                
  1424.         def main(self):
  1425.                 Gtk.main()
  1426.  
  1427.                
  1428.        
  1429.  
  1430. if __name__ == "__main__":
  1431.         hwg = ProgrammaGTK()
  1432.         Gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement