Opened 3 years ago

Last modified 13 days ago

#9394 new enhancement

Support VP9 hardware acceleration for VideoToolBox

Reported by: WindowPain Owned by:
Priority: wish Component: avcodec
Version: git-master Keywords: videotoolbox
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

VideoToolBox has supported VP9 hardware acceleration since 2020, which enables 4K Youtube playback on Safari. It'd be nice if FFmpeg could support vp9 hwaccel. All macs newer than 2017 can benefit from this.

Change History (3)

comment:1 by jeeb, 3 years ago

I worked on this briefly during last winter (branch) and I got the decoder to initialize on a friend's piece of hardware, I never got to:

  1. Properly sharing the VP9 VPcc extradata generation logic between lavf and lavc (we already have a function over at lavf for this).
  2. Unhacking the decoder bits which were clearly failing.

in reply to:  1 comment:2 by WindowPain, 3 years ago

Replying to jeeb:

I worked on this briefly during last winter (branch) and I got the decoder to initialize on a friend's piece of hardware, I never got to:

  1. Properly sharing the VP9 VPcc extradata generation logic between lavf and lavc (we already have a function over at lavf for this).
  2. Unhacking the decoder bits which were clearly failing.


That's really nice. I tried your branch and this is what I'm getting. Are you still planning to work on this?

❯ ./ffmpeg -loglevel verbose -hwaccel videotoolbox -i '『GHOST IN THE SHELL_攻殻機動隊 4Kリマスター版』予告編-EHDTYrV7i5o.webm' -f null - 
ffmpeg version N-100633-g000eac3456 Copyright (c) 2000-2021 the FFmpeg developers
  built with Apple clang version 12.0.5 (clang-1205.0.22.11)
  configuration: 
  libavutil      56. 63.101 / 56. 63.101
  libavcodec     58.117.101 / 58.117.101
  libavformat    58. 65.101 / 58. 65.101
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7. 95.100 /  7. 95.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
[vp9 @ 0x7f873581b800] avcodec_default_get_buffer2 entered
Input #0, matroska,webm, from '『GHOST IN THE SHELL_攻殻機動隊 4Kリマスター版』予告編-EHDTYrV7i5o.webm':
  Metadata:
    encoder         : google/video-file
  Duration: 00:01:07.07, start: 0.000000, bitrate: 1384 kb/s
    Stream #0:0(eng): Video: vp9 (Profile 0), 1 reference frame, yuv420p(tv, bt709), 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 1k tbc (default)
Stream mapping:
  Stream #0:0 -> #0:0 (vp9 (native) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
[vp9 @ 0x7f8735014c00] avcodec_default_get_buffer2 entered
[vp9 @ 0x7f8735014c00] update_frame_pool failed! (Invalid argument)
[vp9 @ 0x7f8735014c00] get_buffer2 failed (Invalid argument)
[vp9 @ 0x7f8735014c00] get_buffer() failed
[vp9 @ 0x7f8735014c00] thread_get_buffer() failed
[vp9 @ 0x7f8735019e00] Not all references are available
[vp9 @ 0x7f873501a400] Not all references are available
[vp9 @ 0x7f873501aa00] Not all references are available
Error while decoding stream #0:0: Invalid argument
[vp9 @ 0x7f873501b000] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f8735014c00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f8735019e00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f873501a400] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f873501aa00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f873501b000] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f8735014c00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f8735019e00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f873501a400] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f873501aa00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f873501b000] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f8735014c00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f8735019e00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f873501a400] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f873501aa00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f873501b000] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f8735014c00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f8735019e00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f873501a400] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f873501aa00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f873501b000] avcodec_default_get_buffer2 entered
[vp9 @ 0x7f873501b000] update_frame_pool failed! (Invalid argument)
[vp9 @ 0x7f873501b000] get_buffer2 failed (Invalid argument)
[vp9 @ 0x7f873501b000] get_buffer() failed
[vp9 @ 0x7f873501b000] thread_get_buffer() failed
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f8735014c00] Not all references are available
Error while decoding stream #0:0: Invalid data found when processing input
[vp9 @ 0x7f8735019e00] Not all references are available
Error while decoding stream #0:0: Resource temporarily unavailable
    Last message repeated 1580 times
Error while decoding stream #0:0: Invalid data found when processing input
Error while decoding stream #0:0: Invalid argument
Error while decoding stream #0:0: Invalid data found when processing input
    Last message repeated 1 times
[graph 0 input from stream 0:0 @ 0x7f8734c06bc0] w:1920 h:1080 pixfmt:yuv420p tb:1/1000 fr:24000/1001 sar:0/1
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf58.65.101
    Stream #0:0(eng): Video: wrapped_avframe, 1 reference frame, yuv420p, 1920x1080 (0x0), q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn (default)
    Metadata:
      encoder         : Lavc58.117.101 wrapped_avframe
No more output streams to write to, finishing.00.00 bitrate=N/A speed=   0x    
frame=    0 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A speed=   0x    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (『GHOST IN THE SHELL_攻殻機動隊 4Kリマスター版』予告編-EHDTYrV7i5o.webm):
  Input stream #0:0 (video): 1608 packets read (11592459 bytes); 0 frames decoded; 
  Total: 1608 packets (11592459 bytes) demuxed
Output file #0 (pipe:):
  Output stream #0:0 (video): 0 frames encoded; 0 packets muxed (0 bytes); 
  Total: 0 packets (0 bytes) muxed
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
[AVIOContext @ 0x7f8734d057c0] Statistics: 11604190 bytes read, 0 seeks
Conversion failed!

comment:3 by nenkoru, 13 days ago

Worth mentioning that current HEAD of master supports accelerated VP9 decoding.

Note: See TracTickets for help on using tickets.