From 7e39d151d850590fbabc9870bc5134d9421c5c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 9 Apr 2018 15:27:11 +0200 Subject: Added support for the WEBM/VP9 video codec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WEBM is the codec name, and VP9 is the encoder (the older encoder "VP8" is less efficient than VP9). WEBM/VP9 and h.264 both have options to control the file size versus compression time (e.g. fast but big, or slow and small, for the same output quality). Since WEBM/VP9 only has three choices, I've chosen to map those to 3 of the 9 possible choices of h.264: - BEST → SLOWER - GOOD → MEDIUM - REALTIME → SUPERFAST The VERYSLOW and ULTRAFAST options give very little extra benefit. Reviewed by: @Severin --- source/blender/blenkernel/intern/writeffmpeg.c | 33 ++++++++++++++++---------- 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern/writeffmpeg.c') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index aa81b39d196..d7fcd896e11 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -582,24 +582,33 @@ static AVStream *alloc_video_stream(FFMpegContext *context, RenderData *rd, int } if (context->ffmpeg_preset) { - char const *preset_name; + /* 'preset' is used by h.264, 'deadline' is used by webm/vp9. I'm not + * setting those properties conditionally based on the video codec, + * as the FFmpeg encoder simply ignores unknown settings anyway. */ + char const *preset_name = NULL; /* used by h.264 */ + char const *deadline_name = NULL; /* used by webm/vp9 */ switch (context->ffmpeg_preset) { - case FFM_PRESET_ULTRAFAST: preset_name = "ultrafast"; break; - case FFM_PRESET_SUPERFAST: preset_name = "superfast"; break; - case FFM_PRESET_VERYFAST: preset_name = "veryfast"; break; - case FFM_PRESET_FASTER: preset_name = "faster"; break; - case FFM_PRESET_FAST: preset_name = "fast"; break; - case FFM_PRESET_MEDIUM: preset_name = "medium"; break; - case FFM_PRESET_SLOW: preset_name = "slow"; break; - case FFM_PRESET_SLOWER: preset_name = "slower"; break; - case FFM_PRESET_VERYSLOW: preset_name = "veryslow"; break; + case FFM_PRESET_GOOD: + preset_name = "medium"; + deadline_name = "good"; + break; + case FFM_PRESET_BEST: + preset_name = "slower"; + deadline_name = "best"; + break; + case FFM_PRESET_REALTIME: + preset_name = "superfast"; + deadline_name = "realtime"; + break; default: printf("Unknown preset number %i, ignoring.\n", context->ffmpeg_preset); - preset_name = NULL; } if (preset_name != NULL) { av_dict_set(&opts, "preset", preset_name, 0); } + if (deadline_name != NULL) { + av_dict_set(&opts, "deadline", deadline_name, 0); + } } #if 0 @@ -1676,7 +1685,7 @@ void BKE_ffmpeg_image_type_verify(RenderData *rd, ImageFormatData *imf) { BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_H264); rd->ffcodecdata.constant_rate_factor = FFM_CRF_MEDIUM; - rd->ffcodecdata.ffmpeg_preset = FFM_PRESET_MEDIUM; + rd->ffcodecdata.ffmpeg_preset = FFM_PRESET_GOOD; rd->ffcodecdata.type = FFMPEG_MKV; } if (rd->ffcodecdata.type == FFMPEG_OGG) { -- cgit v1.2.3