diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2016-09-21 16:01:51 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2016-09-21 16:03:11 +0300 |
commit | a7e74791221e2ef9b44ee1b3eb9ece37785aa62a (patch) | |
tree | bdef7bcac914ea1330046baac05c52719c34cd7e /source/blender/makesrna | |
parent | 2476faebd751fe7a250d7a496a1f56338b83d4e9 (diff) |
FFmpeg interface improvements
This patch changes a couple of things in the video output encoding.
{F362527}
- Clearer separation between container and codec. No more "format", as this is
too ambiguous. As a result, codecs were removed from the container list.
- Added FFmpeg speed presets, so the user can choosen from the range "Very
slow" to "Ultra fast". By default no preset is used.
- Added Constant Rate Factor (CRF) mode, which allows changing the bit-rate
depending on the desired quality and the input. This generally produces the
best quality videos, at the expense of not knowing the exact bit-rate and
file size.
- Added optional maximum of non-B-frames between B-frames (`max_b_frames`).
- Presets were adjusted for these changes, and new presets added. One of the
new presets is [recommended](https://trac.ffmpeg.org/wiki/Encode/VFX#H.264)
for reviewing videos, as it allows players to scrub through it easily. Might
be nice in weeklies. This preset also requires control over the
`max_b_frames` setting.
GUI-only changes:
- Renamed "MPEG" in the output file format menu with "FFmpeg", as this is more
accurate. After all, FFmpeg is used when this option is chosen, which can
also output non-MPEG files.
- Certain parts of the GUI are disabled when not in use:
- bit rate options are not used when a constant rate factor is given.
- audio bitrate & volume are not used when no audio is exported.
Note that I did not touch `BKE_ffmpeg_preset_set()`. There are currently two
preset systems for FFmpeg (`BKE_ffmpeg_preset_set()` and the Python preset
system). Before we do more work on `BKE_ffmpeg_preset_set()`, I think it's a
good idea to determine whether we want to keep it at all.
After this patch has been accepted, I'd be happy to go through the code and
remove any then-obsolete bits, such as the handling of "XVID" as a container
format.
Reviewers: sergey, mont29, brecht
Subscribers: mpan3, Blendify, brecht, fsiddi
Tags: #bf_blender
Differential Revision: https://developer.blender.org/D2242
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 81 |
1 files changed, 70 insertions, 11 deletions
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index bd6674f899c..c63d4e775f8 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -282,16 +282,11 @@ EnumPropertyItem rna_enum_image_type_items[] = { {R_IMF_IMTYPE_FRAMESERVER, "FRAMESERVER", ICON_FILE_SCRIPT, "Frame Server", "Output image to a frameserver"}, #endif #ifdef WITH_FFMPEG - {R_IMF_IMTYPE_H264, "H264", ICON_FILE_MOVIE, "H.264", "Output video in H.264 format"}, - {R_IMF_IMTYPE_FFMPEG, "FFMPEG", ICON_FILE_MOVIE, "MPEG", "Output video in MPEG format"}, - {R_IMF_IMTYPE_THEORA, "THEORA", ICON_FILE_MOVIE, "Ogg Theora", "Output video in Ogg format"}, + {R_IMF_IMTYPE_FFMPEG, "FFMPEG", ICON_FILE_MOVIE, "FFmpeg video", "The most versatile way to output video files"}, #endif #ifdef WITH_QUICKTIME {R_IMF_IMTYPE_QUICKTIME, "QUICKTIME", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"}, #endif -#ifdef WITH_FFMPEG - {R_IMF_IMTYPE_XVID, "XVID", ICON_FILE_MOVIE, "Xvid", "Output video in Xvid format"}, -#endif {0, NULL, 0, NULL, NULL} }; @@ -5320,6 +5315,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) PropertyRNA *prop; #ifdef WITH_FFMPEG + /* Container types */ static EnumPropertyItem ffmpeg_format_items[] = { {FFMPEG_MPEG1, "MPEG1", 0, "MPEG-1", ""}, {FFMPEG_MPEG2, "MPEG2", 0, "MPEG-2", ""}, @@ -5327,8 +5323,8 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) {FFMPEG_AVI, "AVI", 0, "AVI", ""}, {FFMPEG_MOV, "QUICKTIME", 0, "Quicktime", ""}, {FFMPEG_DV, "DV", 0, "DV", ""}, - {FFMPEG_H264, "H264", 0, "H.264", ""}, - {FFMPEG_XVID, "XVID", 0, "Xvid", ""}, +// {FFMPEG_H264, "H264", 0, "H.264", ""}, not a container +// {FFMPEG_XVID, "XVID", 0, "Xvid", ""}, not a container {FFMPEG_OGG, "OGG", 0, "Ogg", ""}, {FFMPEG_MKV, "MKV", 0, "Matroska", ""}, {FFMPEG_FLV, "FLASH", 0, "Flash", ""}, @@ -5352,6 +5348,32 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem ffmpeg_preset_items[] = { + {FFM_PRESET_ULTRAFAST, "ULTRAFAST", 0, "Ultra fast; biggest file", ""}, + {FFM_PRESET_SUPERFAST, "SUPERFAST", 0, "Super fast", ""}, + {FFM_PRESET_VERYFAST, "VERYFAST", 0, "Very fast", ""}, + {FFM_PRESET_FASTER, "FASTER", 0, "Faster", ""}, + {FFM_PRESET_FAST, "FAST", 0, "Fast", ""}, + {FFM_PRESET_MEDIUM, "MEDIUM", 0, "Medium speed", ""}, + {FFM_PRESET_SLOW, "SLOW", 0, "Slow", ""}, + {FFM_PRESET_SLOWER, "SLOWER", 0, "Slower", ""}, + {FFM_PRESET_VERYSLOW, "VERYSLOW", 0, "Very slow; smallest file", ""}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem ffmpeg_crf_items[] = { + {FFM_CRF_NONE, "NONE", 0, "None; use constant bit-rate", + "Use constant bit rate, rather than constant output quality"}, + {FFM_CRF_LOSSLESS, "LOSSLESS", 0, "Lossless", ""}, + {FFM_CRF_PERC_LOSSLESS, "PERC_LOSSLESS", 0, "Perceptually lossless", ""}, + {FFM_CRF_HIGH, "HIGH", 0, "High quality", ""}, + {FFM_CRF_MEDIUM, "MEDIUM", 0, "Medium quality", ""}, + {FFM_CRF_LOW, "LOW", 0, "Low quality", ""}, + {FFM_CRF_VERYLOW, "VERYLOW", 0, "Very low quality", ""}, + {FFM_CRF_LOWEST, "LOWEST", 0, "Lowest quality", ""}, + {0, NULL, 0, NULL, NULL} + }; + static EnumPropertyItem ffmpeg_audio_codec_items[] = { {AV_CODEC_ID_NONE, "NONE", 0, "None", ""}, {AV_CODEC_ID_MP2, "MP2", 0, "MP2", ""}, @@ -5383,13 +5405,15 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) RNA_def_property_enum_bitflag_sdna(prop, NULL, "type"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_enum_items(prop, ffmpeg_format_items); - RNA_def_property_ui_text(prop, "Format", "Output file format"); + RNA_def_property_enum_default(prop, FFMPEG_MKV); + RNA_def_property_ui_text(prop, "Container", "Output file container"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_FFmpegSettings_codec_settings_update"); prop = RNA_def_property(srna, "codec", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "codec"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_enum_items(prop, ffmpeg_codec_items); + RNA_def_property_enum_default(prop, AV_CODEC_ID_H264); RNA_def_property_ui_text(prop, "Codec", "FFmpeg codec to use"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_FFmpegSettings_codec_settings_update"); @@ -5421,8 +5445,25 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "gopsize", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gop_size"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_range(prop, 0, 100); - RNA_def_property_ui_text(prop, "GOP Size", "Distance between key frames"); + RNA_def_property_range(prop, 0, 500); + RNA_def_property_int_default(prop, 25); + RNA_def_property_ui_text(prop, "Keyframe interval", + "Distance between key frames, also known as GOP size; " + "influences file size and seekability"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "max_b_frames", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "max_b_frames"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_range(prop, 0, 16); + RNA_def_property_ui_text(prop, "Max B-frames", + "Maximum number of B-frames between non-B-frames; influences file size and seekability"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "use_max_b_frames", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", FFMPEG_USE_MAX_B_FRAMES); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Use max B-frames", "Set a maximum number of B-frames"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "buffersize", PROP_INT, PROP_NONE); @@ -5439,6 +5480,24 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mux Packet Size", "Mux packet size (byte)"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + prop = RNA_def_property(srna, "constant_rate_factor", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "constant_rate_factor"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_enum_items(prop, ffmpeg_crf_items); + RNA_def_property_enum_default(prop, FFM_CRF_MEDIUM); + RNA_def_property_ui_text(prop, "Output quality", + "Constant Rate Factor (CRF); tradeoff between video quality and file size"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "ffmpeg_preset", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "ffmpeg_preset"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_enum_items(prop, ffmpeg_preset_items); + RNA_def_property_enum_default(prop, FFM_PRESET_MEDIUM); + RNA_def_property_ui_text(prop, "Encoding speed", + "Tradeoff between encoding speed and compression ratio"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + prop = RNA_def_property(srna, "use_autosplit", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", FFMPEG_AUTOSPLIT_OUTPUT); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); |