Skip to content

Commit

Permalink
concat: Ignore corrupted clips
Browse files Browse the repository at this point in the history
`record --no-concat` may leave behind some empty clips.
  • Loading branch information
TheDrHax committed Apr 3, 2021
1 parent 5773b1b commit 7dceda3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions twitch_utils/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def render(self, path: str = 'full.mp4', container: str = 'mp4',

if path.endswith('.ts') or path == '-' and container == 'mpegts':
command += ['-copyts']

command += ['-f', 'concat', '-safe', '0', '-hide_banner',
'-i', map_file_name, '-c', 'copy']

Expand Down Expand Up @@ -145,8 +145,16 @@ def render(self, path: str = 'full.mp4', container: str = 'mp4',
def main(argv=None):
args = docopt(__doc__, argv=argv)

clips = []

for path in args['<input>']:
try:
clips.append(Clip(path))
except Exception:
print(f'WARN: Clip {path} is corrupted, ignoring...')

try:
timeline = Timeline([Clip(path) for path in args['<input>']])
timeline = Timeline(clips)
except TimelineMissingRangeError as ex:
print(f'ERROR: Range {int(ex.start)}~{int(ex.end)} is not present in '
'provided files')
Expand Down

0 comments on commit 7dceda3

Please sign in to comment.