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

General: More specific error in burnins script #4026

Merged
merged 2 commits into from
Oct 25, 2022
Merged
Changes from all commits
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
26 changes: 19 additions & 7 deletions openpype/scripts/otio_burnin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
'"{}"%(input_args)s -i "%(input)s" %(filters)s %(args)s%(output)s'
).format(ffmpeg_path)

FFPROBE = (
'"{}" -v quiet -print_format json -show_format -show_streams "%(source)s"'
).format(ffprobe_path)

DRAWTEXT = (
"drawtext=fontfile='%(font)s':text=\\'%(text)s\\':"
"x=%(x)s:y=%(y)s:fontcolor=%(color)s@%(opacity).1f:fontsize=%(size)d"
Expand All @@ -48,8 +44,15 @@ def _get_ffprobe_data(source):
:param str source: source media file
:rtype: [{}, ...]
"""
command = FFPROBE % {'source': source}
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
command = [
ffprobe_path,
"-v", "quiet",
"-print_format", "json",
"-show_format",
"-show_streams",
source
]
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
out = proc.communicate()[0]
if proc.returncode != 0:
raise RuntimeError("Failed to run: %s" % command)
Expand Down Expand Up @@ -113,11 +116,20 @@ def __init__(
if not ffprobe_data:
ffprobe_data = _get_ffprobe_data(source)

# Validate 'streams' before calling super to raise more specific
# error
source_streams = ffprobe_data.get("streams")
if not source_streams:
raise ValueError((
"Input file \"{}\" does not contain any streams"
" with image/video content."
).format(source))

self.ffprobe_data = ffprobe_data
self.first_frame = first_frame
self.input_args = []

super().__init__(source, ffprobe_data["streams"])
super().__init__(source, source_streams)

if options_init:
self.options_init.update(options_init)
Expand Down