get timestamps from an output file
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from tsmark.video_annotator import Marker
|
from tsmark.video_annotator import Marker
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
VERSION = "0.4.5"
|
VERSION = "0.4.6"
|
||||||
|
|
||||||
|
|
||||||
def get_options():
|
def get_options():
|
||||||
@@ -13,7 +13,7 @@ def get_options():
|
|||||||
dest="timestamps",
|
dest="timestamps",
|
||||||
default=None,
|
default=None,
|
||||||
required=False,
|
required=False,
|
||||||
help="Comma separated list of predefined timestamps, in seconds, or HH:MM:SS.ss. You can use the -o output file as input via --ts $( cut -d, -f1 ts.csv | xargs printf '%%s,' )",
|
help="Comma separated list of predefined timestamps, in seconds, or HH:MM:SS.ss, or input CSV file. You can use the -o output file as input via --ts $( cut -d, -f1 ts.csv | xargs printf '%%s,' )",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-o",
|
"-o",
|
||||||
|
|||||||
@@ -247,10 +247,17 @@ class Marker:
|
|||||||
|
|
||||||
def parse_timestamps(self):
|
def parse_timestamps(self):
|
||||||
if self.opts.timestamps:
|
if self.opts.timestamps:
|
||||||
|
if os.path.exists(self.opts.timestamps):
|
||||||
|
with open(self.opts.timestamps,'rt') as fp:
|
||||||
|
|
||||||
|
self.opts.timestamps = [x.split(",")[0] for x in fp.readlines()]
|
||||||
|
else:
|
||||||
|
self.opts.timestamps = self.opts.timestamps.split(",")
|
||||||
|
|
||||||
self.stamps = sorted(
|
self.stamps = sorted(
|
||||||
[
|
[
|
||||||
self.parse_time(ts.strip())
|
self.parse_time(ts.strip())
|
||||||
for ts in self.opts.timestamps.split(",")
|
for ts in self.opts.timestamps
|
||||||
if ts.strip() != ""
|
if ts.strip() != ""
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -270,11 +277,11 @@ class Marker:
|
|||||||
print("# {}: {} / {}".format(i + 1, self.format_time(ts), ts + 1))
|
print("# {}: {} / {}".format(i + 1, self.format_time(ts), ts + 1))
|
||||||
if len(self.stamps) > 0:
|
if len(self.stamps) > 0:
|
||||||
print(
|
print(
|
||||||
'ffmpeg -i "{}" -ss {} -to {} -c copy "{}.trimmed.mp4"'.format(
|
'ffmpeg -ss {} -to {} -i "{}" -c copy "{}.trimmed.mp4"'.format(
|
||||||
self.opts.video.replace('"', '\\"'),
|
|
||||||
self.format_time(self.stamps[0]),
|
self.format_time(self.stamps[0]),
|
||||||
self.format_time(self.stamps[-1]),
|
self.format_time(self.stamps[-1]),
|
||||||
self.opts.video.replace('"', '\\"'),
|
self.opts.video.replace('"', '\\"'),
|
||||||
|
self.opts.video.replace('"', '\\"'),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user