Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dav1d to replace aom, upgrade ffmpeg to 4.4.4 #136

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

brainos233
Copy link
Contributor

Although renpy has used aom as av1/avif's decoder, both fmpeg and libavif are using dav1d as the default decoder for AV1, Android 12 and newer version are using dav1d too, so it's good to let dav1d to replace aom.

When building ffmpeg with dav1d, it failed with libavcodec/libdav1d.c:143:7: error: no member named 'n_tile_threads' in 'struct Dav1dSettings', so updating ffmpeg to 4.4.4 to fix this error.

Choosing ffmpeg 4.4.4 because this version is still maintained by many distributions, can be patched easily using patches from these distributions.

Benchmarking on my r5 5600h laptop, decoding av1 video using ffmpeg built with dav1d was more than twice as fast as original ffmpeg with aom.

Test compiled successfully on android armeabi_v7a, windows x86_64, wasm, linux x86_64, linux armv7l, mac arm64.

FFmpeg Decoding Benchmark

$ .\ffmpeg_dav1d.exe -i D:\Movie\Big_Buck_Bunny_1080_10s_5MB.mp4 -benchmark -f null -
[libdav1d @ 00000268ea35aac0] libdav1d 1.4.2
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:\Movie\Big_Buck_Bunny_1080_10s_5MB.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomav01iso2mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    encoder         : Lavf58.63.100
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
  Duration: 00:00:10.00, start: 0.000000, bitrate: 4201 kb/s
  Stream #0:0(und): Video: av1 (Main) (av01 / 0x31307661), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 4199 kb/s, 30 fps, 30 tbr, 15360 tbn, 15360 tbc (default)
    Metadata:
      handler_name    : GPAC ISO Video Handler
      vendor_id       : [0][0][0][0]
[libdav1d @ 00000268ea3ad140] libdav1d 1.4.2
Stream mapping:
  Stream #0:0 -> #0:0 (av1 (libdav1d) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomav01iso2mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    genre           : Animation
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    encoder         : Lavf58.76.100
  Stream #0:0(und): Video: wrapped_avframe, yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn (default)
    Metadata:
      handler_name    : GPAC ISO Video Handler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc58.134.100 wrapped_avframe
frame=  300 fps=0.0 q=-0.0 Lsize=N/A time=00:00:10.00 bitrate=N/A speed=12.4x
video:157kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
bench: utime=4.844s stime=0.078s rtime=0.817s
bench: maxrss=103400kB

$ hyperfine ".\ffmpeg_dav1d.exe -i D:\Movie\Big_Buck_Bunny_1080_10s_5MB.mp4 -benchmark -f null -"
Benchmark 1: .\ffmpeg_dav1d.exe -i D:\Movie\Big_Buck_Bunny_1080_10s_5MB.mp4 -benchmark -f null -
  Time (mean ± σ):      1.159 s ±  0.041 s    [User: 5.125 s, System: 0.200 s]
  Range (min … max):    1.079 s …  1.228 s    10 runs

$ .\ffmpeg_aom.exe -i D:\Movie\Big_Buck_Bunny_1080_10s_5MB.mp4 -benchmark -f null -
[libaom-av1 @ 00000224eccb9d80] 3.5.0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:\Movie\Big_Buck_Bunny_1080_10s_5MB.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomav01iso2mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    encoder         : Lavf58.63.100
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
  Duration: 00:00:10.00, start: 0.000000, bitrate: 4201 kb/s
  Stream #0:0(und): Video: av1 (Main) (av01 / 0x31307661), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 4199 kb/s, 30 fps, 30 tbr, 15360 tbn, 15360 tbc (default)
    Metadata:
      handler_name    : GPAC ISO Video Handler
      vendor_id       : [0][0][0][0]
[libaom-av1 @ 00000224eccbb840] 3.5.0
Stream mapping:
  Stream #0:0 -> #0:0 (av1 (libaom-av1) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomav01iso2mp41
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    composer        : Sacha Goedegebure
    genre           : Animation
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    encoder         : Lavf58.76.100
  Stream #0:0(und): Video: wrapped_avframe, yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn (default)
    Metadata:
      handler_name    : GPAC ISO Video Handler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc58.134.100 wrapped_avframe
frame=  300 fps=151 q=-0.0 Lsize=N/A time=00:00:10.00 bitrate=N/A speed=5.02x
video:157kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
bench: utime=9.375s stime=0.109s rtime=2.003s
bench: maxrss=156648kB

$ hyperfine ".\ffmpeg_aom.exe -i D:\Movie\Big_Buck_Bunny_1080_10s_5MB.mp4 -benchmark -f null -"
Benchmark 1: .\ffmpeg_aom.exe -i D:\Movie\Big_Buck_Bunny_1080_10s_5MB.mp4 -benchmark -f null -
  Time (mean ± σ):      2.505 s ±  0.031 s    [User: 9.590 s, System: 0.176 s]
  Range (min … max):    2.447 s …  2.555 s    10 runs

@renpytom
Copy link
Member

What versions of windows does this support? We're going to support Windows 7 for the next release.

@brainos233
Copy link
Contributor Author

What versions of windows does this support? We're going to support Windows 7 for the next release.

I tested it on Windows 7 using VMware, I am sure that av1 video can be played normally.

image

But I think if decided to continue compatible with Windows 7, a parameter like os-version can be used to maintain a specific version of python for Windows 7 only, there is no need to lock all platforms and architectures into one version.

@renpytom
Copy link
Member

renpytom commented Jun 1, 2024

i like to keep all platforms on the same versions as much as possible, just because it minimizes how much I have to test. With so many platforms, there's only so much testing we can do.

That being said, Windows 7 is scheduled to be dropped soon, so it probably makes sense to take these changes early in the 8.4 release process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants