Beispiel #1
0
def test_codec_equality():
    dummy_codec = Codec("AVC", ffmpeg_name="h264", pretty_name="x264")
    different_codec = Codec("HEVC", ffmpeg_name="libx265", pretty_name="x265")
    same_codec = Codec("AVC", ffmpeg_name="h264", pretty_name="x264")
    not_a_codec = "I'm ralph, not a codec"

    assert dummy_codec == same_codec
    assert dummy_codec != different_codec
    with pytest.raises(AssertionError):
        assert dummy_codec == not_a_codec
Beispiel #2
0
def target():
    audio_settings = AudioSettings(codec=Codec("AAC"), channels=2, bitrate=120)

    video_settings = VideoSettings(
        codec=Codec("HEVC"),
        quality=25,
        preset="slow",
        encoder="software",
    )

    return Processor(directory="/tmp/foo",
                     force=False,
                     video_settings=video_settings,
                     audio_settings=audio_settings,
                     in_place=False,
                     container="mkv")
def target():
    audio_settings = AudioSettings(codec=Codec("AAC"), channels=2, bitrate=120)

    video_settings = VideoSettings(codec=Codec("HEVC"),
                                   quality=25,
                                   preset="slow",
                                   encoder="software")

    return VideoProcessor(
        video=Video("bar.mkv", "/asdf/foo"),
        video_settings=video_settings,
        audio_settings=audio_settings,
        container="asdf",
        in_place=False,
        dry_run=False,
    )
Beispiel #4
0
def main(
    directories,
    force,
    in_place,
    video_codec,
    quality,
    preset,
    width,
    extra_input_args,
    extra_output_args,
    audio_codec,
    audio_channels,
    audio_bitrate,
    temp_dir,
    verbose,
    container,
    dry_run,
    encoder,
):
    configure_logger(verbose)

    video_settings = VideoSettings(codec=Codec(video_codec), quality=quality, preset=preset, width=width, encoder=encoder)
    audio_settings = AudioSettings(codec=Codec(audio_codec), channels=audio_channels, bitrate=audio_bitrate,)

    if video_settings.codec.get_ffmpeg_name() is None:
        raise Exception("Invalid video codec specified")

    if audio_settings.codec.get_ffmpeg_name() is None:
        raise Exception("Invalid audio codec specified")

    results = []
    for directory in directories:
        results += Processor(
            directory=directory,
            force=force,
            video_settings=video_settings,
            audio_settings=audio_settings,
            in_place=in_place,
            extra_ffmpeg_input_args=extra_input_args,
            extra_ffmpeg_output_args=extra_output_args,
            temp_directory=temp_dir,
            container=container,
            dry_run=dry_run,
        ).start()

    _print_conversion_results(results)
def target():
    audio_settings = AudioSettings(codec=Codec("AAC"), channels=2, bitrate=120)

    video_settings = VideoSettings(codec=Codec("HEVC"),
                                   quality=25,
                                   preset="slow",
                                   encoder="software")

    return FFmpegConverter(
        source_file_path="/asdf/foo/bar.mkv",
        video_settings=video_settings,
        audio_settings=audio_settings,
        destination_file_path="/asdf/temp/path.mkv",
        extra_ffmpeg_input_args="",
        extra_ffmpeg_output_args="",
        dry_run=False,
    )
def test_video_settings_width():
    target = VideoSettings(codec=Codec("AVC"),
                           quality=25,
                           preset="slow",
                           width=720,
                           encoder="software")
    assert str(
        target
    ) == " -map 0:v:0 -map 0:s? -c:s copy -vcodec h264 -preset slow -crf 25 -vf scale=720:-2"
Beispiel #7
0
def test_refresh(mock_needs_refresh, mock_get_size, mock_validator, mock_media_info):
    expected_codec = Codec("HEVC")
    mock_media_info.parse.return_value = metadata_return()
    mock_validator().quality_similar_to.return_value = "1080p"

    v = Video("foo.mkv", "/not-a-real-path/bar")
    v.refresh()

    assert v.codec == expected_codec
    assert v.quality == "1080p"
    assert v.size == 12345
def test_video_settings_avc_intel():
    target = VideoSettings(Codec("AVC"), 25, "slow", encoder="intel")
    assert str(
        target
    ) == " -map 0:v:0 -map 0:s? -c:s copy -vcodec h264_qsv -preset slow -global_quality 25 -look_ahead 1"
Beispiel #9
0
def test_codec():
    c = Codec("AVC", "h264", "x264")
    assert c.format_name == "AVC"
    assert c.get_ffmpeg_name() == "h264"
    assert c.pretty_name == "x264"
Beispiel #10
0
def test_codec_intel():
    c = Codec("HEVC")
    assert c.format_name == "HEVC"
    assert c.get_ffmpeg_name("intel") == "hevc_qsv"
    assert c.pretty_name == "x265"
Beispiel #11
0
def test_audio_settings():
    target = AudioSettings(Codec("AAC"), 2, 128)
    assert str(target) == " -acodec aac -ab 128k -ac 2 -map 0:a"
Beispiel #12
0
 def _get_codec_settings(self):
     output = ""
     if self.codec == Codec("HEVC"):
         output += f" -strict -2"
     return output
Beispiel #13
0
def test_codec_setter():
    v = Video("foo.mkv", "./foo")
    codec = Codec("foo", "bar", "baz")
    v.codec = codec
    assert v.codec == codec
Beispiel #14
0
def test_video_settings_hevc():
    target = VideoSettings(Codec("HEVC"), 25, "slow", None)
    assert str(
        target
    ) == " -map 0:v:0 -map 0:s? -c:s copy -vcodec libx265 -preset slow -crf 25 -strict -2"
Beispiel #15
0
def test_codec_minimal():
    c = Codec("foo")
    assert c.format_name == "foo"
    assert c.get_ffmpeg_name() is None
    assert c.pretty_name is None
Beispiel #16
0
def test_video_settings_hevc_nvidia():
    target = VideoSettings(Codec("HEVC"), 25, "slow", encoder="nvidia")
    assert str(
        target
    ) == " -map 0:v:0 -map 0:s? -c:s copy -vcodec hevc_nvenc -preset slow -rc constqp -qp 25 -b:v 0 -strict -2"
Beispiel #17
0
def test_codec_autodetect():
    c = Codec("HEVC")
    assert c.format_name == "HEVC"
    assert c.get_ffmpeg_name() == "libx265"
    assert c.pretty_name == "x265"
Beispiel #18
0
def test_video_settings_hevc_intel():
    target = VideoSettings(Codec("HEVC"), 25, "slow", encoder="intel")
    assert str(
        target
    ) == " -map 0:v:0 -map 0:s? -c:s copy -vcodec hevc_qsv -preset slow -global_quality 25 -strict -2"
Beispiel #19
0
def test_codec_nvidia():
    c = Codec("HEVC")
    assert c.format_name == "HEVC"
    assert c.get_ffmpeg_name("nvidia") == "hevc_nvenc"
    assert c.pretty_name == "x265"
Beispiel #20
0
def test_video_settings_avc():
    target = VideoSettings(Codec("AVC"), 25, "slow", None)
    assert str(
        target
    ) == " -map 0:v:0 -map 0:s? -c:s copy -vcodec h264 -preset slow -crf 25"
def test_in_desired_format(target):
    target.video.codec = Codec("HEVC")
    target.video_settings.codec = Codec("HEVC")
    response = target.process()
    assert response == Status.IN_DESIRED_FORMAT