Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look for duration in format if not available in stream #11

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/mediacatch_s2t/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,17 @@ def get_duration(self):
if probe.return_code:
return 0, probe.error
else:
for stream in probe.json['streams']:
if stream['codec_type'] == 'audio':
return int(float(stream['duration']) * 1000), stream
else:
return 0, "The file doesn't have an audio track"
try:
for stream in probe.json['streams']:
if stream['codec_type'] == 'audio':
return int(float(stream['duration']) * 1000), stream
else:
return 0, "The file doesn't have an audio track"
except:
if 'duration' in probe.json['format']:
return int(float(probe.json['format']['duration']) * 1000), probe.json['format']
else:
return 0, "Duration couldn't be found for audio track"
except OSError as e:
return 0, 'FFmpeg not installed (sudo apt install ffmpeg)'

Expand Down