Diff of /trunk/tubetutor/ffmpeg.py [r9] .. [r10]  Maximize  Restore

Switch to unified view

a/trunk/tubetutor/ffmpeg.py b/trunk/tubetutor/ffmpeg.py
...
...
25
25
26
#
26
#
27
# The following helper functions will retrieve the pathnames for the ffmpeg tools
27
# The following helper functions will retrieve the pathnames for the ffmpeg tools
28
#
28
#
29
def get_cmd_ffmpeg():
29
def get_cmd_ffmpeg():
30
    subdir=os.path.join(os.path.dirname(sys.argv[0]), "ffmpeg -loglevel verbose")
30
    subdir=os.path.join(os.path.dirname(sys.argv[0]), "ffmpeg")
31
    if os.path.exists(subdir):
31
    if os.path.exists(subdir):
32
        return os.path.join(subdir, "ffmpeg.exe -loglevel verbose")
32
        return os.path.join(subdir, "ffmpeg.exe -loglevel verbose")
33
    return "ffmpeg -loglevel verbose"
33
    return "ffmpeg -loglevel verbose"
34
34
35
def get_cmd_ffprobe():
35
def get_cmd_ffprobe():
...
...
88
    global proc_ffmpeg
88
    global proc_ffmpeg
89
    # Kill remaining ffmpeg instances
89
    # Kill remaining ffmpeg instances
90
    if proc_ffmpeg:
90
    if proc_ffmpeg:
91
        try:
91
        try:
92
            ctypes.windll.kernel32.TerminateProcess(int(proc_ffmpeg._handle), -1)
92
            ctypes.windll.kernel32.TerminateProcess(int(proc_ffmpeg._handle), -1)
93
        except:
93
        finally:
94
            os.killpg(os.getpgid(proc_ffmpeg.pid), signal.SIGTERM)
94
            pass
95
        proc_ffmpeg.kill()
95
        proc_ffmpeg.kill()
96
        if hasattr(os, "killpg"):
97
            os.killpg(os.getpgid(proc_ffmpeg.pid), signal.SIGTERM)
98
            os.killpg(os.getpgid(proc_ffmpeg.pid), signal.SIGKILL)
99
        if hasattr(os, "kill"):
100
            os.kill(proc_ffmpeg.pid, signal.CTRL_C_EVENT)
101
        
96
        proc_ffmpeg=None
102
        proc_ffmpeg=None
97
        
103
        
98
def video_duration(filename):
104
def video_duration(filename):
99
    cmd = get_cmd_ffprobe()
105
    cmd = get_cmd_ffprobe()
100
    cmd += " -i %s" % filename
106
    cmd += " -i %s" % filename
...
...
136
        self.framerate = 20
142
        self.framerate = 20
137
        
143
        
138
    def add_text(self, filename, duration=5):
144
    def add_text(self, filename, duration=5):
139
        f = open(filename, "r")
145
        f = open(filename, "r")
140
        if f:
146
        if f:
141
            content = f.read()
147
            content = f.read().replace("\n", "")
142
            f.close()
148
            f.close()
143
        if content.replace("\n", "") == "":
149
        if content.replace("\n", "") == "":
144
            return
150
            return
145
151
146
        params = " -scale %s!" % self.vidresolution.replace(":", "x")
152
        params = " -scale %s!" % self.vidresolution.replace(":", "x")