From 08ee80454c2560a7bc742c15ebccee1c4dfa4671 Mon Sep 17 00:00:00 2001 From: Martinez Date: Sun, 8 Nov 2015 16:29:10 +0100 Subject: [PATCH] handle incompatible pixel formats --- over-video.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/over-video.py b/over-video.py index 845cf30..d99ac06 100755 --- a/over-video.py +++ b/over-video.py @@ -15,6 +15,9 @@ from aux import parse_fps, to_Path Command = over.core.cmd.Command prefix = over.core.text.prefix +# -------------------------------------------------- +X264_BANNED_PIXFMTS = {'bgr24'} + # -------------------------------------------------- # see doc/command_assembler.png @@ -25,9 +28,10 @@ command.encode_generic = Command('ffmpeg', '-i', 'INFILE', 'VIDEO', 'AUDIO', '-s command.sub_vorbis = Command('-codec:a', 'libvorbis', '-qscale:a', 'QUALITY', 'NORMALIZE') command.sub_pcm = Command('-codec:a', 'pcm_s16le', 'NORMALIZE') command.sub_theora = Command('-codec:v', 'libtheora', '-qscale:v', 'QUALITY', 'VFILTER') -command.sub_x264 = Command('-codec:v', 'libx264', '-preset', 'slow', '-crf', 'QUALITY', '-profile:v', 'high', '-level', '4.2', 'VFILTER') +command.sub_x264 = Command('PIXFMT', '-codec:v', 'libx264', '-preset', 'slow', '-crf', 'QUALITY', '-profile:v', 'high', '-level', '4.2', 'VFILTER') command.sub_normalize = Command('-filter:a', 'VOLUME') command.sub_vfilter = Command('-filter:v', 'ARGS') +command.force_yuv420p = Command('-pix_fmt', 'yuv420p') command.sub_copy_audio = Command('-codec:a', 'copy') command.sub_copy_video = Command('-codec:v', 'copy') @@ -156,6 +160,7 @@ if __name__ == '__main__': info.video_size_y = video['height'] info.video_fps = over.core.text.Unit(parse_fps(video['r_frame_rate']), 'Hz') info.video_bitrate = over.core.text.Unit(video['bit_rate'], 'b/s') if 'bit_rate' in video else '§r??§/' + info.pixel_fmt = video['pix_fmt'] if audio_streams: audio = audio_streams[0] @@ -279,6 +284,12 @@ if __name__ == '__main__': command.sub_x264.QUALITY = main.cfg.video_quality command.sub_x264.VFILTER = info.vfilter_command + if info.pixel_fmt in X264_BANNED_PIXFMTS: + main.print('source pixel format §r%s§/ is incompatible with x264, forcing §yyuv420p§/' %(info.pixel_fmt), prefix.warn) + command.sub_x264.PIXFMT = command.force_yuv420p + else: + command.sub_x264.PIXFMT = None + encode_cmd.VIDEO = command.sub_x264 # --------------------------------------------------