handle incompatible pixel formats

This commit is contained in:
Martinez 2015-11-08 16:29:10 +01:00
parent 5ffb173513
commit 08ee80454c

View file

@ -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
# --------------------------------------------------