diff options
author | Jesús Eduardo <heckyel@hyperbola.info> | 2017-09-11 17:47:17 -0500 |
---|---|---|
committer | Jesús Eduardo <heckyel@hyperbola.info> | 2017-09-11 17:47:17 -0500 |
commit | 14738704ede6dfa6ac79f362a9c1f7f40f470cdc (patch) | |
tree | 31c83bdd188ae7b64d7169974d6f066ccfe95367 /lvc/basicconverters.py | |
parent | eb1896583afbbb622cadcde1a24e17173f61904f (diff) | |
download | librevideoconverter-14738704ede6dfa6ac79f362a9c1f7f40f470cdc.tar.lz librevideoconverter-14738704ede6dfa6ac79f362a9c1f7f40f470cdc.tar.xz librevideoconverter-14738704ede6dfa6ac79f362a9c1f7f40f470cdc.zip |
rename mvc at lvc
Diffstat (limited to 'lvc/basicconverters.py')
-rw-r--r-- | lvc/basicconverters.py | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/lvc/basicconverters.py b/lvc/basicconverters.py new file mode 100644 index 0000000..ddf99ec --- /dev/null +++ b/lvc/basicconverters.py @@ -0,0 +1,149 @@ +import logging +import re + +from lvc import converter + +class WebM_UHD(converter.FFmpegConverterInfo1080p): + media_type = 'format' + extension = 'webm' + parameters = ('-f webm -vcodec libvpx -g 120 -lag-in-frames 23 ' + '-deadline good -cpu-used 0 -vprofile 0 -qmax 51 -qmin 11 ' + '-slices 4 -b:v 4M -acodec libvorbis -ab 128k -map_metadata -1 ' + '-ar 44100') + +class WebM_HD(converter.FFmpegConverterInfo720p): + media_type = 'format' + extension = 'webm' + parameters = ('-f webm -vcodec libvpx -g 120 -lag-in-frames 16 ' + '-deadline good -cpu-used 0 -vprofile 0 -qmax 51 -qmin 11 ' + '-slices 4 -b:v 2M -acodec libvorbis -ab 112k -map_metadata -1 ' + '-ar 44100') + +class WebM_SD(converter.FFmpegConverterInfo480p): + media_type = 'format' + extension = 'webm' + parameters = ('-f webm -vcodec libvpx -g 120 -lag-in-frames 16 ' + '-deadline good -cpu-used 0 -vprofile 0 -qmax 53 -qmin 0 ' + '-b:v 768k -acodec libvorbis -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 ' + '-quality good -crf 32 ' + '-b:v 0 -acodec libopus -map_metadata -1') + +class MP4(converter.FFmpegConverterInfo): + media_type = 'format' + extension = 'mp4' + parameters = ('-acodec aac -ab 96k -vcodec libx264 -preset slow -map_metadata -1' + '-f mp4 -crf 22') + +class MP3(converter.FFmpegConverterInfo): + media_type = 'format' + extension = 'mp3' + parameters = '-f mp3 -ac 2' + audio_only = True + +class OggVorbis(converter.FFmpegConverterInfo): + media_type = 'format' + extension = 'ogg' + parameters = '-f ogg -vn -acodec libvorbis -aq 60' + audio_only = True + +class OggTheora(converter.FFmpegConverterInfo): + media_type = 'format' + extension = 'ogv' + parameters = '-f ogg -codec:v libtheora -qscale:v 7 -codec:a libvorbis -qscale:a 5 -map_metadata -1' + +class DNxHD_1080(converter.FFmpegConverterInfo1080p): + media_type = 'format' + extension = 'mov' + parameters = ('-r 23.976 -f mov -vcodec dnxhd -b:v ' + '175M -acodec pcm_s16be -ar 48000') + +class DNxHD_720(converter.FFmpegConverterInfo720p): + media_type = 'format' + extension = 'mov' + parameters = ('-r 23.976 -f mov -vcodec dnxhd -b:v ' + '175M -acodec pcm_s16be -ar 48000') + +class PRORES_720(converter.FFmpegConverterInfo720p): + media_type = 'format' + extension = 'mov' + parameters = ('-f mov -vcodec prores -profile 2 ' + '-acodec pcm_s16be -ar 48000') + +class PRORES_1080(converter.FFmpegConverterInfo1080p): + media_type = 'format' + extension = 'mov' + parameters = ('-f mov -vcodec prores -profile 2 ' + '-acodec pcm_s16be -ar 48000') + +class AVC_INTRA_1080(converter.FFmpegConverterInfo1080p): + media_type = 'format' + extension = 'mov' + parameters = ('-f mov -vcodec libx264 -pix_fmt yuv422p ' + '-crf 0 -intra -b:v 100M -acodec pcm_s16be -ar 48000') + +class AVC_INTRA_720(converter.FFmpegConverterInfo720p): + media_type = 'format' + extension = 'mov' + parameters = ('-f mov -vcodec libx264 -pix_fmt yuv422p ' + '-crf 0 -intra -b:v 100M -acodec pcm_s16be -ar 48000') + +class NullConverter(converter.FFmpegConverterInfo): + media_type = 'format' + extension = None + + def get_parameters(self, video): + params = [] + if not video.audio_only and self.should_copy_video_size(video): + # -vcodec copy copies the video data exactly. Only use it if the + # output video is the same size as the input video (#19664) + params.extend(['-vcodec', 'copy']) + params.extend(['-acodec', 'copy']) + return params + + def should_copy_video_size(self, video): + if self.width is None or self.height is None: + return True + return (video.width == self.width and video.height == self.height) + + def get_extra_arguments(self, video, output): + if not video.container: + logging.warn("sameformat: video.container is None. Using mp4") + container = 'mp4' + elif isinstance(video.container, list): + # XXX: special case mov,mp4,m4a,3gp,3g2,mj2 + container = 'mp4' + else: + container = video.container + return ['-f', container] + +mp3 = MP3('MP3') +ogg_vorbis = OggVorbis('Ogg Vorbis') +audio_formats = ('Audio', [mp3, ogg_vorbis]) + +webm_uhd = WebM_UHD('WebM UHD') +webm_hd = WebM_HD('WebM HD') +webm_sd = WebM_SD('WebM SD') +webm_vp9 = WebM_VP9('WebM VP9') +mp4 = MP4('MP4') +theora = OggTheora('Ogg Theora') + +video_formats = ('Video', [webm_uhd, webm_hd, webm_sd, webm_vp9, mp4, theora]) + +dnxhd_1080 = DNxHD_1080('DNxHD 1080p') +dnxhd_720 = DNxHD_720('DNxHD 720p') +prores_1080 = PRORES_1080('Prores Ingest 1080p') +prores_720 = PRORES_720('Prores Ingest 720p') +avc_intra_1080 = PRORES_1080('AVC Intra 1080p') +avc_intra_720 = PRORES_720('AVC Intra 720p') + +ingest_formats = ('Ingest Formats', [dnxhd_1080, dnxhd_720, prores_1080, + prores_720, avc_intra_1080, avc_intra_720]) +null_converter = NullConverter('Same Format') + +converters = [video_formats, audio_formats, ingest_formats, null_converter] |