Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 9287a87

Browse files
committed
33092: testing all possible outputs for ffmpeg in is_functional
1 parent 34c2bb3 commit 9287a87

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

src/sage/features/ffmpeg.py

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,39 @@ def is_functional(self):
7171
import os
7272
base, filename_png = os.path.split(base_filename_png)
7373
filename, _png = os.path.splitext(filename_png)
74-
filename_gif = filename + '.gif'
7574

76-
# running the command (taken from sage/plot/animate.py)
77-
from subprocess import run
78-
# the `-nostdin` is needed to avoid the command to hang, see
75+
# Setting a list of commands (taken from sage/plot/animate.py)
76+
# The `-nostdin` is needed to avoid the command to hang, see
7977
# https://stackoverflow.com/questions/16523746/ffmpeg-hangs-when-run-in-background
80-
cmd = ['ffmpeg', '-nostdin', '-y', '-f', 'image2', '-r', '5', '-i',
81-
filename_png, '-pix_fmt', 'rgb24', '-loop', '0',
82-
filename_gif]
83-
result = run(cmd, cwd=base, capture_output=True, text=True)
84-
85-
# If an error occured, return False
86-
if result.returncode:
87-
return FeatureTestResult(self, False, reason='Running command "{}" '
88-
'returned non-zero exit status "{}" with stderr '
89-
'"{}" and stdout "{}".'.format(result.args,
90-
result.returncode,
91-
result.stderr.strip(),
92-
result.stdout.strip()))
78+
commands = []
79+
for ext in ['.avi', '.flv', '.gif', '.mkv', '.mov', #'.mpg',
80+
'.mp4', '.ogg', '.ogv', '.webm', '.wmv']:
81+
82+
cmd = ['ffmpeg', '-nostdin', '-y', '-f', 'image2', '-r', '5',
83+
'-i', filename_png, '-pix_fmt', 'rgb24', '-loop', '0',
84+
filename + ext]
85+
commands.append(cmd)
86+
87+
for ext in ['.avi', '.flv', '.gif', '.mkv', '.mov', '.mpg',
88+
'.mp4', '.ogg', '.ogv', '.webm', '.wmv']:
89+
90+
cmd = ['ffmpeg', '-nostdin', '-y', '-f', 'image2', '-i',
91+
filename_png, filename + ext]
92+
commands.append(cmd)
93+
94+
# Running the commands and reporting any issue encountered
95+
from subprocess import run
96+
for cmd in commands:
97+
result = run(cmd, cwd=base, capture_output=True, text=True)
98+
99+
# If an error occurred, return False
100+
if result.returncode:
101+
return FeatureTestResult(self, False, reason='Running command "{}" '
102+
'returned non-zero exit status "{}" with stderr '
103+
'"{}" and stdout "{}".'.format(result.args,
104+
result.returncode,
105+
result.stderr.strip(),
106+
result.stdout.strip()))
93107

94108
# If necessary, run more tests here
95109
# ...

src/sage/features/imagemagick.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def is_functional(self):
8383
'-loop', '0', filename_png, filename_gif]
8484
result = run(cmd, cwd=base, capture_output=True, text=True)
8585

86-
# If an error occured, return False
86+
# If an error occurred, return False
8787
if result.returncode:
8888
return FeatureTestResult(self, False, reason='Running command "{}" '
8989
'returned non-zero exit status "{}" with stderr '

0 commit comments

Comments
 (0)