VP9 encoding takes about 5x as much time as transcoding with ffmpeg #95743
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
9 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#95743
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Arch Linux
Graphics card: Nvidia 1080
Blender Version
Broken: probably all versions
Steps to reproduce
trailer.blend
Video: F13163407
Compare render time to
ffmpeg -loglevel 58 -y -i in.mp4 -ss 0 -to 0.5 -c:a libopus -b:a 128000 -c:v libvpx-vp9 -deadline best -b:v 3472630 out-ffmpeg.webm
There is significant difference: 30s with ffmpeg vs. 200s with Blender
Also see codec settings for comparison:
P3006 vs. P3005
Added subscriber: @lolpb
Added subscriber: @mano-wii
Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
4 hours vs 11 minutes is actually a big difference. But I don't think this can be confirmed as a bug.
The developers are aware of the limitations and are continuously working to improve performance and other aspects of the video editor.
But due to the difference, I am forwarded to the #vfx_video team in the possibility of a bug.
Added subscriber: @iss
Changed status from 'Needs Developer To Reproduce' to: 'Needs User Info'
If I understand correctly, you render 60 seconds at 60fps ant the process takes 4 hours? That shouldn't happen.
You say
Broken: untested
- what does this mean? Or did you mean that 3.1.0 is broken?I need to fully reproduce this issue here, so first thing I need is .blend file. Issue could be with input movie file too, so I will need that as well unless this happens even with generator strip like color or text.
Here rendering took about 11 minutes
By broken I mean that didn't test any Blender version where the video didn't render, because really only tested 3.1.0 Beta.
Rendering 60 seconds of playtime at 60 fps takes 4 hours to render, not 60 seconds to render, hope I express myself properly.
Also, time would depend on CPU. Mine is Intel 6700HQ. Will add examples as soon as I can, but can't promise anything soon.
In any case, it should happen the same with any example I guess...
Yes, performance will depend on CPU, but I don't think it would be that slow even with sinlge core CPU. After 8 cores, returns seem to be diminishing anyway at least with full hd media.
Here are all the source, project and result files.
Rendering
out-ffmpeg.webm
withffmpeg
takes2m 11s
.Rendering
0001-0600.webm
withBlender
takes31m 20s
and has double video bitrate than requested in UI settings (about 8Mbps instead of 4Mbps aproximately).Folder
BL_proxy
is removed due to large size.https://mega.nz/folder/UAN0BDQY#AtnS2aW7FaUWLMzyick-Qw
Changed status from 'Needs User Info' to: 'Confirmed'
Can confirm this looks to be quite slow. From quick look I see this is caused by particular output settings. If I render with default settings for VSE it's much faster. In provided ffmpeg script you did not specify
-deadline best
option. This is equivalent to slowest encoding speed option in Blender. By default ffmpeg will use "Good" encoding speed.Checking with good speed, it took 1 minute to complete render with ffmpeg. Blender did complete in 4.5 minutes. Not great, but much better than 30 minutes.
With slowest speed, it took 5 minutes to complete render with ffmpeg. Blender did complete in 25.5 minutes. So there is still significant difference which may be worth investigating.
This seems to be specific to vp9 codec. H264 with sampe settings was done in 20 seconds. So I assume this is a bug
New test with ffmpeg, my believe was that ffmpeg used best encoding speed by default:
-deadline best
: 12m 8sAlso would like to know why rendered video in Blender does not meet set bitrate, so size is much bigger than desired. Any clue why it's so difficult to set?
Added subscriber: @EAW
It appears that VP9 encoding times and sizes vary wildly based upon encoding settings.
Here is a table of 19 different encodings of the same 80 second 1080p clip that took between 1 and 131 minutes to complete, resulting in file sizes ranging between 4.4MB and 1.06GB
https://developers.google.com/media/vp9/bitrate-modes#results
The line graph on the following page shows the relative difference between each encoding speed, with speed 1 (the second slowest) only taking 44% of the time as the slowest speed setting of 0.
https://streaminglearningcenter.com/codecs/encoding-vp9-in-ffmpeg-an-update.html
And here are some charts showing that VP9 and x265 taking 12.5x and 16x times longer to encode compared to x254, which fits with your 20 second x264 vs 4.5 minute VP9 @ISS. Getting that compression down to half the size just takes longer.
https://www.streamingmedia.com/Articles/Editorial/Featured-Articles/Good-News-AV1-Encoding-Times-Drop-to-Near-Reasonable-Levels-130284.aspx
I am guessing that this is due to the settings that Blender is sending to FFMpeg. It might be that they are more generalized to the x264 specification people are used to using, and not the particular VP9 only settings that VP9 needs to be performant.
Do you mean x264 not x254?
The reason to use VP9/Opus is that web browsers except Edge don't have licenses to play H.265 media embedded in websites due to pantents. Also other H.264 / WMV/WMA+DRM etc. may have similar issues.
Checked this report again, I don't see any codec parameter causing time difference, so issue may be with general ffmpeg settings, but that I would not consider to be a bug. So will change classification to known issue.
As workaround I would avoid using slowest VP9 encoding speed if encoding time is concern.
Perhaps with "good" speed, there is another parameter "speed" that can be set within range 0-5 that can improve performance (with penalties in quality of course), but ffmpeg default is 0 and so I don't think this is necessary. If you need such precise encoder control, it's probably best to render images and use ffmpeg with manual setup.
Thanks for the follow-up.
Video render works but takes an awful amount of timeto VP9 encoding takes about 5x as much time as transcoding with ffmpegAdded subscriber: @hamdio
Assigning to @hamdio, I have updated description to include simple reproducible case and codec settings in use. Could have left the note, that there is not as dramatic difference with h264 for example, so feel free to investigate.
The buffer mode and rate control settings seems to be the issue here, when encoding in blender it's:
while ffmpeg defaults are:
So possibly blender uses incompatible or irrelevant defaults for vp9.
I also realised
libvpx
has been compiled without multithread and avx support:vs what I've for ffmpeg in wsl:
I'll try to recompile blender's avcodec lib in my local and investigate further the codec option default causing buffer/rc difference,
Added subscriber: @LazyDodo
took a closer look, it does the right thing for exotic instruction support, so that we could enable, still have to check why threading was disabled.
@hamdio Thanks for checking, do you know how to change buffer parameters? I tried to pass some arguments, but I wasn't able to change the numbers. Also I have read, that this should only define interval in which codec checks if specified bitrate specs are met, so did not think, that it can have much effect...
Good idea to check compile settings, I did not pay much attention, because I thought I won't understand implications eh.
hmm, I also don't know exactly what param in ffmpeg sets libvpx for that buffer/rate-control settings, still it'd be good to understand the difference. will read ffmpeg code/investigate that.
but thanks to @LazyDodo I've tested with a re-compiled libs:
and even with the same buffer/rate-control settings, it's definitely much more faster. To put the numbers here can I ask the method you did the time measurements above.
Just measured the time spend between
BKE_ffmpeg_start
andBKE_ffmpeg_end
throughout the rendering and here are the results by only changing the ffmpeg libs with multithread and avx enabled libvpx.On a laptop with
i9-10980HK
(8 Cores and 16G Ram), using a17f74ab341b026387fef6b741e3c0901780526c:--enable-sse4_1 --enable-sse3 --enable-ssse3 --enable-avx --enable-avx2 --disable-unit-tests --disable-examples --enable-vp8 --enable-vp9 --target=x86_64-win64-gcc
):time ffmpeg -loglevel 58 -y -i in.mp4 -ss 0 -to 0.5 -c:a libopus -b:a 128000 -c:v libvpx-vp9 -deadline best -b:v 3472630 out-ffmpeg.webm
) on the same systemSo enabling multithreading for libvpx seems to be helping this vp9 performance issue. Which is already on the TODO list for next release.
@iss I can confirm blender is not doing anything wrong with the vp9 encoder buffer settings, it's all configurable and I can play with
rc_2pass_vbr_maxsection_pct
andrc_buf_sz
ofvpxenc
through the available options (Bitrate, Min/Max Bitrate and Buffer) in encoder output settings panel. Observed the values exactly as described in ffmpeg documentation :The difference between ffmpeg command was just because not providing any buffer setting, so one can get the same
rc_buf_sz
out from ffmpeg viaSo this slowness is purely because of missing
vpxenc
multithreading capability. As a result assigning it to @LazyDodo to enable it on the next ffmpeg build.@hamdio Thanks for analysis, Since we don't do 2-pass encoding, I don't think it's necessary to set these. question is if
buf-sz
andbuf-optimal-sz
should be calculated from bitrate or just set to some default value or could be kept as is...@LazyDodo If compile options will be changed, shall we look at difference in mainly libx264 too before libs are updated? Maybe there are some fps to be squeezed out...
I can build with whatever flags you desire, he current x264 flags are pretty close to stock if someone has improvements to suggest i'll be happy to make some test builds to see if they improve things, i don't think a vp9 ticket is the ideal place to discuss this though.
This issue was referenced by
aa788b759a
Changed status from 'Confirmed' to: 'Resolved'
Than you!!!
Added subscriber: @Emi_Martinez