multiple trims

This commit is contained in:
q
2024-12-13 14:44:57 +02:00
parent c5947d0d60
commit 8902e0ad16
2 changed files with 13 additions and 19 deletions

View File

@@ -372,24 +372,18 @@ class Marker:
if len(self.stamps) == 0:
self.stamps.append(0)
self.stamps.append(self.frames)
if len(self.stamps) > 0:
print(
'ffmpeg -i "{}" {}-c:v mpeg2video -q:v 3 -g 1 -a copy -ss {} -to {} "{}.trimmed.mp4"'.format(
self.opts.video.replace('"', '\\"'),
cropstr,
self.format_time(self.stamps[0]),
self.format_time(self.stamps[-1]),
os.path.splitext(self.opts.video)[0].replace('"', '\\"'),
)
)
elif self.crop[0][0] is not None:
print(
'ffmpeg -i "{}" {}-c:v mpeg2video -q:v 3 -g 1 "{}.trimmed.mp4"'.format(
self.opts.video.replace('"', '\\"'),
cropstr,
os.path.splitext(self.opts.video)[0].replace('"', '\\"'),
)
)
padlen = len(str(self.frames))
src_name = self.opts.video.replace('"', '\\"')
tgt_name = os.path.splitext(self.opts.video)[0].replace('"', '\\"')
for i in range(1,len(self.stamps),2):
from_ts = self.stamps[i-1]
to_ts = self.stamps[i]
from_ft = self.format_time(from_ts)
to_ft = self.format_time(to_ts)
from_str=str(from_ts).zfill(padlen)
to_str=str(to_ts).zfill(padlen)
print(f'ffmpeg -i "{src_name}" {cropstr}-c:v mpeg2video -q:v 3 -g 1 -c:a copy -ss {from_ft} -to {to_ft} "{tgt_name}.trim.{from_str}-{to_str}.mpeg"')
def save_timestamps(self):