| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -131,22 +131,28 @@ def get_args(stream_spec, overwrite_output=False): | |||
| 131 | 131 | return args | |
| 132 | 132 | ||
| 133 | 133 | ||
| 134 | + @output_operator() | ||
| 135 | + def compile(stream_spec, cmd='ffmpeg', **kwargs): | ||
| 136 | + """Build command-line for ffmpeg.""" | ||
| 137 | + if isinstance(cmd, basestring): | ||
| 138 | + cmd = [cmd] | ||
| 139 | + elif type(cmd) != list: | ||
| 140 | + cmd = list(cmd) | ||
| 141 | + return cmd + get_args(stream_spec, **kwargs) | ||
| 142 | + | ||
| 143 | + | ||
| 134 | 144 | @output_operator() | |
| 135 | 145 | def run(stream_spec, cmd='ffmpeg', **kwargs): | |
| 136 | 146 | """Run ffmpeg on node graph. | |
| 137 | 147 | ||
| 138 | 148 | Args: | |
| 139 | 149 | **kwargs: keyword-arguments passed to ``get_args()`` (e.g. ``overwrite_output=True``). | |
| 140 | 150 | """ | |
| 141 | - if isinstance(cmd, basestring): | ||
| 142 | - cmd = [cmd] | ||
| 143 | - elif type(cmd) != list: | ||
| 144 | - cmd = list(cmd) | ||
| 145 | - args = cmd + get_args(stream_spec, **kwargs) | ||
| 146 | - _subprocess.check_call(args) | ||
| 151 | + _subprocess.check_call(compile(stream_spec, cmd, **kwargs)) | ||
| 147 | 152 | ||
| 148 | 153 | ||
| 149 | 154 | __all__ = [ | |
| 155 | + 'compile', | ||
| 150 | 156 | 'get_args', | |
| 151 | 157 | 'run', | |
| 152 | 158 | ] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -219,6 +219,12 @@ def _get_drawtext_text_repr(text): | |||
| 219 | 219 | # subprocess.check_call(['ffmpeg', '-version']) | |
| 220 | 220 | ||
| 221 | 221 | ||
| 222 | + def test_compile(): | ||
| 223 | + out_file = ffmpeg.input('dummy.mp4').output('dummy2.mp4') | ||
| 224 | + assert out_file.compile() == ['ffmpeg', '-i', 'dummy.mp4', 'dummy2.mp4'] | ||
| 225 | + assert out_file.compile(cmd='ffmpeg.old') == ['ffmpeg.old', '-i', 'dummy.mp4', 'dummy2.mp4'] | ||
| 226 | + | ||
| 227 | + | ||
| 222 | 228 | def test_run(): | |
| 223 | 229 | stream = _get_complex_filter_example() | |
| 224 | 230 | ffmpeg.run(stream) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments