mirror of
https://github.com/kkroening/ffmpeg-python.git
synced 2025-04-06 04:15:44 +08:00
Merge pull request #87 from kkroening/feature-80
Add `video_bitrate` and `audio_bitrate` params
This commit is contained in:
commit
57eeea2356
@ -62,12 +62,19 @@ def output(*streams_and_filename, **kwargs):
|
|||||||
Syntax:
|
Syntax:
|
||||||
`ffmpeg.output(stream1[, stream2, stream3...], filename, **ffmpeg_args)`
|
`ffmpeg.output(stream1[, stream2, stream3...], filename, **ffmpeg_args)`
|
||||||
|
|
||||||
|
Any supplied keyword arguments are passed to ffmpeg verbatim (e.g.
|
||||||
|
``t=20``, ``f='mp4'``, ``acodec='pcm'``, ``vcodec='rawvideo'``,
|
||||||
|
etc.). Some keyword-arguments are handled specially, as shown below.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
video_bitrate: parameter for ``-b:v``, e.g. ``video_bitrate=1000``.
|
||||||
|
audio_bitrate: parameter for ``-b:a``, e.g. ``audio_bitrate=200``.
|
||||||
|
format: alias for ``-f`` parameter, e.g. ``format='mp4'``
|
||||||
|
(equivalent to ``f='mp4'``).
|
||||||
|
|
||||||
If multiple streams are provided, they are mapped to the same
|
If multiple streams are provided, they are mapped to the same
|
||||||
output.
|
output.
|
||||||
|
|
||||||
Any supplied kwargs are passed to ffmpeg verbatim (e.g. ``t=20``,
|
|
||||||
``f='mp4'``, ``acodec='pcm'``, etc.).
|
|
||||||
|
|
||||||
To tell ffmpeg to write to stdout, use ``pipe:`` as the filename.
|
To tell ffmpeg to write to stdout, use ``pipe:`` as the filename.
|
||||||
|
|
||||||
Official documentation: `Synopsis <https://ffmpeg.org/ffmpeg.html#Synopsis>`__
|
Official documentation: `Synopsis <https://ffmpeg.org/ffmpeg.html#Synopsis>`__
|
||||||
|
@ -119,9 +119,12 @@ def _get_output_args(node, stream_name_map):
|
|||||||
|
|
||||||
kwargs = copy.copy(node.kwargs)
|
kwargs = copy.copy(node.kwargs)
|
||||||
filename = kwargs.pop('filename')
|
filename = kwargs.pop('filename')
|
||||||
fmt = kwargs.pop('format', None)
|
if 'format' in kwargs:
|
||||||
if fmt:
|
args += ['-f', kwargs.pop('format')]
|
||||||
args += ['-f', fmt]
|
if 'video_bitrate' in kwargs:
|
||||||
|
args += ['-b:v', str(kwargs.pop('video_bitrate'))]
|
||||||
|
if 'audio_bitrate' in kwargs:
|
||||||
|
args += ['-b:a', str(kwargs.pop('audio_bitrate'))]
|
||||||
if 'video_size' in kwargs:
|
if 'video_size' in kwargs:
|
||||||
video_size = kwargs.pop('video_size')
|
video_size = kwargs.pop('video_size')
|
||||||
if not isinstance(video_size, basestring) and isinstance(video_size, collections.Iterable):
|
if not isinstance(video_size, basestring) and isinstance(video_size, collections.Iterable):
|
||||||
|
@ -237,6 +237,16 @@ def test_filter_asplit():
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test__output__bitrate():
|
||||||
|
args = (
|
||||||
|
ffmpeg
|
||||||
|
.input('in')
|
||||||
|
.output('out', video_bitrate=1000, audio_bitrate=200)
|
||||||
|
.get_args()
|
||||||
|
)
|
||||||
|
assert args == ['-i', 'in', '-b:v', '1000', '-b:a', '200', 'out']
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('video_size', [(320, 240), '320x240'])
|
@pytest.mark.parametrize('video_size', [(320, 240), '320x240'])
|
||||||
def test__output__video_size(video_size):
|
def test__output__video_size(video_size):
|
||||||
args = (
|
args = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user