~heckyel/librevideoconverter

5e0be6a75ce96eabb949cfc967f0af9bfe3b3ebf — Jesús 1 year, 4 months ago 4f30c2b
Add more converter to WebM VP8 and WebM VP9
2 files changed, 141 insertions(+), 33 deletions(-)

M lvc/basicconverters.py
M test/test_converter.py
M lvc/basicconverters.py => lvc/basicconverters.py +50 -13
@@ 4,7 4,7 @@ import re
from lvc import converter


class WebM_UHD(converter.FFmpegConverterInfo1080p):
class WebM_UHD_VP8(converter.FFmpegConverterInfo1080p):
    media_type = 'format'
    extension = 'webm'
    parameters = ('-f webm -vcodec libvpx -g 120 -lag-in-frames 23 '


@@ 14,7 14,7 @@ class WebM_UHD(converter.FFmpegConverterInfo1080p):
                  '-ar 44100')


class WebM_HD(converter.FFmpegConverterInfo720p):
class WebM_HD_VP8(converter.FFmpegConverterInfo720p):
    media_type = 'format'
    extension = 'webm'
    parameters = ('-f webm -vcodec libvpx -g 120 -lag-in-frames 16 '


@@ 24,7 24,7 @@ class WebM_HD(converter.FFmpegConverterInfo720p):
                  '-ar 44100')


class WebM_SD(converter.FFmpegConverterInfo480p):
class WebM_SD_VP8(converter.FFmpegConverterInfo480p):
    media_type = 'format'
    extension = 'webm'
    parameters = ('-f webm -vcodec libvpx -g 120 -lag-in-frames 16 '


@@ 33,10 33,39 @@ class WebM_SD(converter.FFmpegConverterInfo480p):
                  '-ar 44100')


class WebM_UHD_VP9(converter.FFmpegConverterInfo1080p):
    media_type = 'format'
    extension = 'webm'
    parameters = ('-f webm -vcodec libvpx-vp9 -g 120 -lag-in-frames 23 '
                  '-deadline good -cpu-used 0 -vprofile 0 -qmax 51 -qmin 11 '
                  '-slices 4 -b:v 4M -acodec libopus -ab 128k '
                  '-map_metadata -1 '
                  '-ar 44100')


class WebM_HD_VP9(converter.FFmpegConverterInfo720p):
    media_type = 'format'
    extension = 'webm'
    parameters = ('-f webm -vcodec libvpx-vp9 -g 120 -lag-in-frames 16 '
                  '-deadline good -cpu-used 0 -vprofile 0 -qmax 51 -qmin 11 '
                  '-slices 4 -b:v 2M -acodec libopus -ab 112k '
                  '-map_metadata -1 '
                  '-ar 44100')


class WebM_SD_VP9(converter.FFmpegConverterInfo480p):
    media_type = 'format'
    extension = 'webm'
    parameters = ('-f webm -vcodec libvpx-vp9 -g 120 -lag-in-frames 16 '
                  '-deadline good -cpu-used 0 -vprofile 0 -qmax 53 -qmin 0 '
                  '-b:v 768k -acodec libopus -ab 112k -map_metadata -1 '
                  '-ar 44100')


class WebM_VP9(converter.FFmpegConverterInfo):
    media_type = 'format'
    extension = 'webm'
    parameters = ('-f webm -vcodec libvpx-vp9 -g 240 -threads 8 '
    parameters = ('-f webm -vcodec libvpx-vp9 -g 240 -threads 4 '
                  '-quality good -crf 32 '
                  '-b:v 0 -acodec libopus -map_metadata -1')



@@ 44,7 73,7 @@ class WebM_VP9(converter.FFmpegConverterInfo):
class WebM_VP8(converter.FFmpegConverterInfo):
    media_type = 'format'
    extension = 'webm'
    parameters = ('-f webm -vcodec libvpx -g 240 -threads 8 '
    parameters = ('-f webm -vcodec libvpx -g 240 -threads 4 '
                  '-quality good -crf 32 '
                  '-b:v 0 -acodec libvorbis -map_metadata -1')



@@ 154,21 183,29 @@ mp3 = MP3('MP3')
ogg_vorbis = OggVorbis('Ogg Vorbis')
audio_formats = ('Audio', [mp3, ogg_vorbis])

webm_uhd = WebM_UHD('WebM UHD 1080p')
webm_hd = WebM_HD('WebM HD 720p')
webm_sd = WebM_SD('WebM SD 480p')
webm_vp9 = WebM_VP9('WebM VP9')
webm_uhd_vp8 = WebM_UHD_VP8('WebM 1080p VP8')
webm_hd_vp8 = WebM_HD_VP8('WebM 720p VP8')
webm_sd_vp8 = WebM_SD_VP8('WebM 480p VP8')
webm_vp8 = WebM_VP8('WebM VP8')

webm_uhd_vp9 = WebM_UHD_VP9('WebM 1080p VP9')
webm_hd_vp9 = WebM_HD_VP9('WebM 720p VP9')
webm_sd_vp9 = WebM_SD_VP9('WebM 480p VP9')
webm_vp9 = WebM_VP9('WebM VP9')

mp4 = MP4('MP4')
theora = OggTheora('Ogg Theora')

video_formats = ('Video',
                 [
                     webm_uhd,
                     webm_hd,
                     webm_sd,
                     webm_vp9,
                     webm_uhd_vp8,
                     webm_hd_vp8,
                     webm_sd_vp8,
                     webm_vp8,
                     webm_uhd_vp9,
                     webm_hd_vp9,
                     webm_sd_vp9,
                     webm_vp9,
                     mp4,
                     theora
                 ])

M test/test_converter.py => test/test_converter.py +91 -20
@@ 1003,8 1003,26 @@ class TestConverterDefinitions(base.Test):
        })
        self.check_size('iphone5', 1920, 1080)

    def test_webmuhd1080p(self):
        self.check_ffmpeg_arguments('webmuhd1080p', {
    def test_webmvp8(self):
        self.check_ffmpeg_arguments('webmvp8', {
            'acodec': 'libvorbis',
            'vcodec': 'libvpx',
            'b:v': '0',
            'g': '240',
            'crf': '32',
            'f': 'webm',
            'i': self.input_path,
            'output_file': self.output_path,
            'quality': 'good',
            's': '542x320',
            'strict': 'experimental',
            'threads': '4',
            'map_metadata': '-1',
        })
        self.check_uses_input_size('webmvp8')

    def test_webm1080pvp8(self):
        self.check_ffmpeg_arguments('webm1080pvp8', {
            'ab': '128k',
            'acodec': 'libvorbis',
            'ar': '44100',


@@ 1025,10 1043,10 @@ class TestConverterDefinitions(base.Test):
            'vcodec': 'libvpx',
            'vprofile': '0'
        })
        self.check_size('webmuhd1080p', 1920, 1080)
        self.check_size('webm1080pvp8', 1920, 1080)

    def test_webmhd720p(self):
        self.check_ffmpeg_arguments('webmhd720p', {
    def test_webm720pvp8(self):
        self.check_ffmpeg_arguments('webm720pvp8', {
            'ab': '112k',
            'acodec': 'libvorbis',
            'ar': '44100',


@@ 1049,10 1067,10 @@ class TestConverterDefinitions(base.Test):
            'vprofile': '0',
            'map_metadata': '-1',
        })
        self.check_size('webmhd720p', 1080, 720)
        self.check_size('webm720pvp8', 1080, 720)

    def test_webmsd480p(self):
        self.check_ffmpeg_arguments('webmsd480p', {
    def test_webm480pvp8(self):
        self.check_ffmpeg_arguments('webm480pvp8', {
            'ab': '112k',
            'acodec': 'libvorbis',
            'ar': '44100',


@@ 1072,7 1090,7 @@ class TestConverterDefinitions(base.Test):
            'vprofile': '0',
            'map_metadata': '-1',
        })
        self.check_size('webmsd480p', 720, 480)
        self.check_size('webm480pvp8', 720, 480)

    def test_webmvp9(self):
        self.check_ffmpeg_arguments('webmvp9', {


@@ 1087,28 1105,81 @@ class TestConverterDefinitions(base.Test):
            'quality': 'good',
            's': '542x320',
            'strict': 'experimental',
            'threads': '8',
            'threads': '4',
            'map_metadata': '-1',
        })
        self.check_uses_input_size('webmvp9')

    def test_webmvp8(self):
        self.check_ffmpeg_arguments('webmvp8', {
            'acodec': 'libvorbis',
            'vcodec': 'libvpx',
            'b:v': '0',
            'g': '240',
            'crf': '32',
    def test_webm1080pvp9(self):
        self.check_ffmpeg_arguments('webm1080pvp9', {
            'ab': '128k',
            'acodec': 'libopus',
            'ar': '44100',
            'b:v': '4M',
            'cpu_used': '0',
            'deadline': 'good',
            'f': 'webm',
            'g': '120',
            'i': self.input_path,
            'lag_in_frames': '23',
            'map_metadata': '-1',
            'output_file': self.output_path,
            'quality': 'good',
            'qmax': '51',
            'qmin': '11',
            's': '542x320',
            'slices': '4',
            'strict': 'experimental',
            'vcodec': 'libvpx-vp9',
            'vprofile': '0'
        })
        self.check_size('webm1080pvp9', 1920, 1080)

    def test_webm720pvp9(self):
        self.check_ffmpeg_arguments('webm720pvp9', {
            'ab': '112k',
            'acodec': 'libopus',
            'ar': '44100',
            'b:v': '2M',
            'cpu_used': '0',
            'deadline': 'good',
            'f': 'webm',
            'g': '120',
            'i': self.input_path,
            'lag_in_frames': '16',
            'output_file': self.output_path,
            'qmax': '51',
            'qmin': '11',
            's': '542x320',
            'slices': '4',
            'strict': 'experimental',
            'threads': '8',
            'vcodec': 'libvpx-vp9',
            'vprofile': '0',
            'map_metadata': '-1',
        })
        self.check_uses_input_size('webmvp8')
        self.check_size('webm720pvp9', 1080, 720)

    def test_webm480pvp9(self):
        self.check_ffmpeg_arguments('webm480pvp9', {
            'ab': '112k',
            'acodec': 'libopus',
            'ar': '44100',
            'b:v': '768k',
            'cpu_used': '0',
            'deadline': 'good',
            'f': 'webm',
            'g': '120',
            'i': self.input_path,
            'lag_in_frames': '16',
            'output_file': self.output_path,
            'qmax': '53',
            'qmin': '0',
            's': '542x320',
            'strict': 'experimental',
            'vcodec': 'libvpx-vp9',
            'vprofile': '0',
            'map_metadata': '-1',
        })
        self.check_size('webm480pvp9', 720, 480)

    def test_galaxymini(self):
        self.check_ffmpeg_arguments('galaxymini', {