Fix python2.6 support with requested changes
This commit is contained in:
parent
215b093fdf
commit
bea82b3acf
@ -758,11 +758,11 @@ def parseOpts(overrideArguments=None):
|
|||||||
help='Encode the video to another format if necessary (currently supported: mp4|flv|ogg|webm|mkv|avi)')
|
help='Encode the video to another format if necessary (currently supported: mp4|flv|ogg|webm|mkv|avi)')
|
||||||
postproc.add_option(
|
postproc.add_option(
|
||||||
'--slice-start',
|
'--slice-start',
|
||||||
metavar='START_TIME', dest='slicestart', default=None,
|
metavar='TIME', dest='slicestart', default=None,
|
||||||
help='Slice start time')
|
help='Slice start time')
|
||||||
postproc.add_option(
|
postproc.add_option(
|
||||||
'--slice-end',
|
'--slice-end',
|
||||||
metavar='END_TIME', dest='sliceend', default=None,
|
metavar='TIME', dest='sliceend', default=None,
|
||||||
help='Slice end time')
|
help='Slice end time')
|
||||||
postproc.add_option(
|
postproc.add_option(
|
||||||
'--postprocessor-args',
|
'--postprocessor-args',
|
||||||
|
@ -22,6 +22,7 @@ from ..utils import (
|
|||||||
subtitles_filename,
|
subtitles_filename,
|
||||||
dfxp2srt,
|
dfxp2srt,
|
||||||
ISO639Utils,
|
ISO639Utils,
|
||||||
|
parse_duration,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -586,15 +587,22 @@ class FFmpegSlicePP(FFmpegPostProcessor):
|
|||||||
self.slice_start_time = slice_start_time
|
self.slice_start_time = slice_start_time
|
||||||
self.slice_end_time = slice_end_time
|
self.slice_end_time = slice_end_time
|
||||||
|
|
||||||
|
def _parse_time(self, duration):
|
||||||
|
start_time = self.slice_start_time or '0'
|
||||||
|
end_time = self.slice_end_time or ('%s' % duration)
|
||||||
|
start_time = "%s" % parse_duration(start_time)
|
||||||
|
end_time = "%s" % parse_duration(end_time)
|
||||||
|
return start_time, end_time
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
|
import pudb; pudb.set_trace()
|
||||||
filename = info['filepath']
|
filename = info['filepath']
|
||||||
temp_filename = prepend_extension(filename, 'temp')
|
temp_filename = prepend_extension(filename, 'temp')
|
||||||
start_time = self.slice_start_time or "0"
|
start_time, end_time = self._parse_time(info['duration'])
|
||||||
end_time = self.slice_end_time or "{}".format(info['duration'])
|
|
||||||
options = ['-ss', start_time, '-to', end_time]
|
options = ['-ss', start_time, '-to', end_time]
|
||||||
self.run_ffmpeg(filename, temp_filename, options)
|
self.run_ffmpeg(filename, temp_filename, options)
|
||||||
msg = '[ffmpeg] Sliced: from ({}) seconds to ({}) seconds'.format(
|
msg = ('[ffmpeg] Sliced: from "%s" seconds to "%s" seconds' %
|
||||||
start_time, end_time)
|
(start_time, end_time))
|
||||||
self._downloader.to_screen(msg)
|
self._downloader.to_screen(msg)
|
||||||
os.remove(encodeFilename(filename))
|
os.remove(encodeFilename(filename))
|
||||||
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user