Beispiel #1
0
def test_audio_downmix():
    in_path = asset_path('audio', 'stereo.mp3')
    f = FFmpeg(in_path,
               Output('output.ogg', streams=[Audio('vorbis', channels=1)]))
    assert f.get_args() == [
        '-i', in_path, '-c:a', 'vorbis', '-ac', '1', 'output.ogg'
    ]
Beispiel #2
0
def test_video_frames():
    in_path = asset_path('video', 'sintel.mkv')
    f = FFmpeg(in_path,
               Output('output.ogv', streams=[Video('libtheora', frames=1)]))
    assert f.get_args() == [
        '-i', in_path, '-c:v', 'libtheora', '-frames:v', '1', 'output.ogv'
    ]
Beispiel #3
0
def test_video_bitrate():
    in_path = asset_path('video', 'sintel.mkv')
    f = FFmpeg(
        in_path,
        Output('output.ogv', streams=[Video('libtheora', bit_rate='2000k')]))
    assert f.get_args() == [
        '-i', in_path, '-c:v', 'libtheora', '-b:v', '2000k', 'output.ogv'
    ]
Beispiel #4
0
def test_simple_multiple_input_output():
    in1_path = asset_path('video', 'sintel.mkv')
    in2_path = asset_path('audio', 'stereo.mp3')

    f = FFmpeg([in1_path, in2_path], ['out1.mp4', 'out2.mp4'])
    assert f.get_args() == [
        '-i', in1_path, '-i', in2_path, 'out1.mp4', 'out2.mp4'
    ]
Beispiel #5
0
def test_audio_bitrate():
    in_path = asset_path('audio', 'stereo.mp3')
    f = FFmpeg(
        in_path,
        Output('output.ogg', streams=[Audio('vorbis', bit_rate='128k')]))
    assert f.get_args() == [
        '-i', in_path, '-c:a', 'vorbis', '-b:a', '128k', 'output.ogg'
    ]
Beispiel #6
0
def test_video_scale():
    in_path = asset_path('video', 'sintel.mkv')
    f = FFmpeg(
        in_path,
        Output('output.ogv', streams=[Video('libtheora', scale=(320, 240))]))
    assert f.get_args() == [
        '-i', in_path, '-c:v', 'libtheora', '-vf', 'scale=320:240',
        'output.ogv'
    ]
Beispiel #7
0
def test_video_extra():
    in_path = asset_path('video', 'sintel.mkv')
    f = FFmpeg(
        in_path,
        Output('output.ogv',
               streams=[
                   Video('libx264',
                         extra=['-crf', '23', '-preset', 'veryslow'])
               ]))
    assert f.get_args() == [
        '-i', in_path, '-c:v', 'libx264', '-crf', '23', '-preset', 'veryslow',
        'output.ogv'
    ]
Beispiel #8
0
def test_input_seek_seconds():
    in_path = asset_path('video', 'sintel.mkv')
    f = FFmpeg(Input(in_path, seek=3), 'output.mp4')
    assert f.get_args() == ['-ss', '3.0', '-i', in_path, 'output.mp4']
Beispiel #9
0
def test_copy_video():
    in_path = asset_path('video', 'sintel.mkv')
    f = FFmpeg(in_path, Output('output.ogg', streams=[CopyVideo]))
    assert f.get_args() == ['-i', in_path, '-c:v', 'copy', 'output.ogg']
Beispiel #10
0
def test_no_video():
    in_path = asset_path('video', 'sintel.mkv')
    f = FFmpeg(in_path, Output('output.ogg', streams=[NoVideo]))
    assert f.get_args() == ['-i', in_path, '-vn', 'output.ogg']
Beispiel #11
0
def test_unsupported_format_fails():
    in_path = asset_path('video', 'sintel.mkv')
    with pytest.raises(ValueError):
        FFmpeg(in_path, Output('output.mp4', fmt=Format('unsupported')))
Beispiel #12
0
def test_specific_output_format():
    in_path = asset_path('video', 'sintel.mkv')
    f = FFmpeg(in_path, Output('output.ogv', fmt=Format('ogg')))
    assert f.get_args() == ['-i', in_path, '-f', 'ogg', 'output.ogv']
Beispiel #13
0
def test_input_duration_decimal():
    in_path = asset_path('video', 'sintel.mkv')
    f = FFmpeg(Input(in_path, duration=Decimal('3.14')), 'output.mp4')
    assert f.get_args() == ['-t', '3.14', '-i', in_path, 'output.mp4']
Beispiel #14
0
def test_input_duration_timedelta():
    in_path = asset_path('video', 'sintel.mkv')
    f = FFmpeg(Input(in_path, duration=timedelta(seconds=3.14)), 'output.mp4')
    assert f.get_args() == ['-t', '3.14', '-i', in_path, 'output.mp4']
Beispiel #15
0
def test_nonexistent_input_fails():
    with pytest.raises(NoMediaError):
        FFmpeg('nonexistent.mp4', 'output.mp4')
Beispiel #16
0
def test_simple_single_input_output():
    in_path = asset_path('video', 'sintel.mkv')
    f = FFmpeg(in_path, 'output.mp4')
    assert f.get_args() == ['-i', in_path, 'output.mp4']
Beispiel #17
0
def test_copy_audio():
    in_path = asset_path('audio', 'stereo.mp3')
    f = FFmpeg(in_path, Output('output.ogg', streams=[CopyAudio]))
    assert f.get_args() == ['-i', in_path, '-c:a', 'copy', 'output.ogg']
Beispiel #18
0
def test_no_audio():
    in_path = asset_path('audio', 'stereo.mp3')
    f = FFmpeg(in_path, Output('output.ogg', streams=[NoAudio]))
    assert f.get_args() == ['-i', in_path, '-an', 'output.ogg']