A/V friendly settings for the 'Video Editing' workspace:
h264_in_MP4 preset
Audio with AAC and 256kbit.
Details
Diff Detail
Event Timeline
Can you explain what is purpose of setting max_b_frames and overall keyframe interval to these values? This should be included in commit message.
I once played with these values but I don't remember they would have any significant effect on output. So perhaps there was but I just tested this wrong.
| release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py | ||
|---|---|---|
| 35–36 | I think setting this once should be enough :) | |
| 49–54 | Aren't these values ignored when you set constant_rate_factor to MEDIUM? | |
| release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py | ||
|---|---|---|
| 35–36 | Thanks. | |
| 49–54 | I basically just the settings from this file: https://developer.blender.org/diffusion/B/browse/master/release/scripts/presets/ffmpeg/h264_in_MP4.py But since these settings also affect UI settings I've added: render.ffmpeg.constant_rate_factor = "MEDIUM" render.ffmpeg.ffmpeg_preset = "REALTIME" I know that using these preset values directly in a command line they'll override individual settings, but I do not know if this happens when set through the UI in Blender. | |
| release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py | ||
|---|---|---|
| 46–47 | I have done test of influence of GOP and max B-frames value with default preset vs. proposed - Render time was pretty much same, filesize as well and seekability difference was impercievable. So I think we should set these to preset default - GOP: 18 and max B frames to False | |
| 49–54 | I have checked in code and these values are overridden We can keep them in case we want preset for constant bitrate, but I don't think it make sense really, so I would remove these | |
Imo, the main thing here is when users are using the "Video Editing" profile, it would be more user-friendly to have video+audio render settings as defaults. Anyway, it just a thought, and I'll leave it up to you guys from here.
It took me a moment to understand what this is doing from the patch description. First I thought it adds a new preset. (I generally try to understand the changes from the description first, before looking at the code).
Better to clearly state what this does: It modifies the "Video Editing" template so that YouTube compatible encoding settings are the default (right?). It doesn't really add anything, just sets a different default.
Are these settings available as a preset? If they are useful, they should be. Rather than setting a bunch of settings to be useful by default, we should use a preset by default.
Adding Sybren as reviewer, since he knows this stuff well and may have a better idea of what is reasonable and what not.
@Julian Eisel (Severin) It's just this profile: https://developer.blender.org/diffusion/B/browse/master/release/scripts/presets/ffmpeg/h264_in_MP4.py but used for the Video Editing profile. Maybe it can be run directly from Video Editing workspace template?
If you want to offer a video-export friendly profile for users when they start Blender in the Video Editing profile, let me know and I'll do the corrections to make the profile exactly like the h264 profile.
I'll leave the decision which settings are best for default to others (e.g. Sybren). But I do think that whatever is the default should match a preset. Ideally by just activating a preset, not by setting the values manually (that can easily go out of sync).
If the goal is to make Youtube compatible encoding settings the default, doesn't it make sense to use Youtube's recommended encoding settings?
| release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py | ||
|---|---|---|
| 46–47 | Just as an FYI: According to this paper from 2010, GOP size influences video quality when viewing video over a wireless network. Higher GOP sizes are better when there is more traffic and therefore packet loss. The higher the GOP size, the lower the chance that consecutive I-frames packets are lost. Testing video quality on a local machine won't show this. =) Youtube recommends GOP size to be "half the frame rate" and "2 consecutive B frames." | |
Thanks for feedback, I mostly wanted to know if this is OK from UI point of view, I agree with aim of this change.
I agree with proposed approach - just activate the preset. H264 in mp4 preset does not set audio for output. So this needs to be set in app template if there is reason why it is not part of preset. That is question for @Sybren A. Stüvel (sybren) if it needs to be that way or we should add audio to video preset(s).
As for the audio settings, I think it is a good idea to enable audio by default in the Video Editing . AAC is a decent enough codec, but 384kbit is overkill. 192kbit is probably fine, 128kbit could also be a suitable default.
Why is YouTube so special that Blender needs to change its defaults for it? Why not use the Vimeo or PeerTube recommendations?
The settings themselves (REALTIME preset, so large output file, and 384kbit AAC audio) seem more like suitable for a studio setting than to produce a file that needs to be uploaded (and thus not super large).
I had a go at updating the template P1874 , however python_file_run is causing a context error - is this an 2.92 introduced bug?
Also I couldn't find a good way to locate the path of the template. So I need help with these things.
I've added presetting SMPTE as default Animation Timeline, since this is an industry standard.
Discussed best way of loading preset with @Campbell Barton (campbellbarton) and came to following approach:
render = bpy.context.scene.render
render.image_settings.file_format = 'FFMPEG'
preset = "h264_in_MP4"
filename = bpy.utils.preset_find(preset, preset_path="ffmpeg")
if filename:
bpy.utils.execfile(filename)
else:
print("Preset %r not found" % preset)
render.ffmpeg.audio_codec = "AAC"
render.ffmpeg.audio_bitrate = 384128 kbit is good enough for speech, but terrible for music. 192kbit is absolute minimum for general purpose IMO. I would argue that audio quality is cheap in terms of filesize so it seems reasonable to go for higher values here. I would consider 256kbit to be OK for most cases.
Why is YouTube so special that Blender needs to change its defaults for it? Why not use the Vimeo or PeerTube recommendations?
Agree here. I don't think these defaults should aim at being in line with any video platform recommendations unless Blender would have special preset for that. I would need to check if such presets are even allowed.
| release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py | ||
|---|---|---|
| 33–34 | This prevents user from saving his own timecode style in user preferences. You would have to do this in load_factory_preferences_post handler as versioning change. And include userpref.blend file for sequencer. Question is if this is OK to do UI wise, because none builtin template have own preferences. This can cause some confusion I think. Also then any versioning change of preferences file would have to take sequencer preferences into account, which is not very nice. So unless anybody has idea how to do this nicely, I disagree with this change. | |
@Richard Antalik (ISS) You're right. The SMPTE setting does override the setting stored in the .blend files. This surprises me, since I believe using an external Workspace Template, you'll need to Restore Factory Settings to override settings stored in a file.
Anyway, SMPTE has now been removed from the patch. Would have been nice to offer to users of the Video Editing workspace as default, though.
| release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py | ||
|---|---|---|
| 35 | bpy.data.scenes is collection of scenes you have to iterate it or access by index. I assume that iterating is preferred even if there is only 1 scene. for scene in bpy.data.scenes:
render = scene.render
render.image_settings.file_format = 'FFMPEG'
preset = "h264_in_MP4"
filename = bpy.utils.preset_find(preset, preset_path="ffmpeg")
if filename:
bpy.utils.execfile(filename)
else:
print("Preset %r not found" % preset)
render.ffmpeg.audio_codec = "AAC"
render.ffmpeg.audio_bitrate = 256 | |
I don't understand some of the review notes.
@Campbell Barton (campbellbarton) wrote:
Avoid using the context in versioning code, loop over bpy.data.scenes instead.
What is "versioning code" in this context? This code is called from the load_factory_startup_post handler.
Ignoring the "versioning code" part, if "avoid using the context" is correct then this code suggested by @Richard Antalik (ISS) is not:
for scene in bpy.data.scenes:
render = scene.render
render.image_settings.file_format = 'FFMPEG'
preset = "h264_in_MP4"
filename = bpy.utils.preset_find(preset, preset_path="ffmpeg")
if filename:
bpy.utils.execfile(filename)as the "h264_in_MP4" preset makes use of bpy.context.
Conceptually the code is also wrong, because it loops over each scene, but the called preset is not going to use the local scene variable. In other words, it's only going to set the preset on the current scene len(bpy.data.scenes) times.
@Sybren A. Stüvel (sybren) @Richard Antalik (ISS) @Campbell Barton (campbellbarton) @Julian Eisel (Severin) Bottom line is, the built-in application template for a VSE should not export to an image sequence without sound... I've tried to update this patch continuously according to the various demands being raised, but at this point and at this hour, I think one of you guys should commandeer this patch, and commit whatever code you think will solve the original problem, so I'm abandoning it.
Taking this over since this seems like a good change.
Will have a look if I can make ffmpeg presets independent of context if that is even desirable in the first place. Otherwise I will think about different approach, when I will have a bit of time.
@Peter Fog (tintwotin) we are aware this is a reasonable change, screenshots of complaints on social media isn't especially helpful.
Yes, that's what I was referring to, these should be split into functions (named that it's clear they are for versioning).
Done.
As far as I can see it's straightforward to update the patch to meet requirements.
- Split FFMPEG startup updating logic into a function, only run it when FFMPEG build option is enabled.
- Use script.python_file_run operator to run the preset, overriding the "scene" context member.
Removed Sybren as he's not available to review, his concerns regarding script execution have been addressed.
