CESNET / UltraGrid

UltraGrid low-latency audio and video network transmission system
http://www.ultragrid.cz
Other
485 stars 55 forks source link

lavc hevc_videotoolbox cannot create compression session: -12908 #350

Closed sogorman closed 4 months ago

sogorman commented 8 months ago

Looking at both the most recent release as well as the latest nightly mac osx build it would appear that hevc_videotoolbox encoding is broken. The below was tested on an M1 and M2 running osx 14.1 (23B74)

./uv-qt.app/Contents/MacOS/uv -t testcard:1920:1080:30:UYVY -c libavcodec:encoder=hevc_videotoolbox:bitrate=2M  192.168.99.2

results in

UltraGrid 1.8.6 (tags/v1.8.6 rev 6328048 built Oct 20 2023 14:32:46)

Display device   : none
Capture device   : testcard
Audio capture    : none
Audio playback   : none
MTU              : 1500 B
Video compression: libavcodec:encoder=hevc_videotoolbox:bitrate=2M
Audio codec      : PCM
Network protocol : UltraGrid RTP
Audio FEC        : none
Video FEC        : none

[testcard] capture set to 1920x1080 @30.00p, codec UYVY, bpc 8, pattern: bars, audio off
Control socket listening on port 50134
[lavc] Using codec: H.265, encoder: hevc_videotoolbox
[lavc] Setting bitrate to 2000.0 kbps.
[lavc] Warning: Unknown encoder hevc_videotoolbox. Using default configuration values.
[lavc] Warning: Unable to find suitable preset for encoder hevc_videotoolbox.
[lavc hevc_videotoolbox @ 0x7fcb31a0a0c0] Error: cannot create compression session: -12908
[lavc hevc_videotoolbox @ 0x7fcb31a0a0c0] Try -allow_sw 1. The hardware encoder may be busy, or not supported.
[lavc] Could not open codec for pixel format yuv420p
[lavc] Setting bitrate to 2000.0 kbps.
[lavc] Warning: Unknown encoder hevc_videotoolbox. Using default configuration values.
[lavc] Warning: Unable to find suitable preset for encoder hevc_videotoolbox.
[lavc hevc_videotoolbox @ 0x7fcb31a0a0c0] Error: cannot create compression session: -12908
[lavc hevc_videotoolbox @ 0x7fcb31a0a0c0] Try -allow_sw 1. The hardware encoder may be busy, or not supported.
[lavc] Could not open codec for pixel format nv12
[lavc] Setting bitrate to 2000.0 kbps.
[lavc] Warning: Unknown encoder hevc_videotoolbox. Using default configuration values.
[lavc] Warning: Unable to find suitable preset for encoder hevc_videotoolbox.
[lavc hevc_videotoolbox @ 0x7fcb31806a40] Error: cannot create compression session: -12908
[lavc hevc_videotoolbox @ 0x7fcb31806a40] Try -allow_sw 1. The hardware encoder may be busy, or not supported.
[lavc] Could not open codec for pixel format p010le
[lavc] Codec supported pixel formats: videotoolbox_vld nv12 yuv420p bgra p010le
[lavc] Usable pixel formats: uyvy422 yuyv422 yuv422p yuvj422p uyvy422 yuv444p yuvj444p yuv420p yuvj420p nv12 yuv422p10le p210le yuv444p10le yuv420p10le p010le yuv444p12le yuv422p16le yuv444p16le rgb24 rgba gbrp bgr0 gbrp12le rgb48le
[lavc] No direct decoder format for: UYVY. Trying to convert with swscale instead.
[lavc] Setting bitrate to 2000.0 kbps.
[lavc] Warning: Unknown encoder hevc_videotoolbox. Using default configuration values.
[lavc] Warning: Unable to find suitable preset for encoder hevc_videotoolbox.
[lavc hevc_videotoolbox @ 0x7fcb31a0a0c0] Error: cannot create compression session: -12908
[lavc hevc_videotoolbox @ 0x7fcb31a0a0c0] Try -allow_sw 1. The hardware encoder may be busy, or not supported.
[lavc] Could not open codec for pixel format nv12
[lavc] Setting bitrate to 2000.0 kbps.
MartinPulec commented 8 months ago

Thanks for the info, I'll take a look.

MartinPulec commented 8 months ago

It looks like _videotoolboxhevc encoder doesn't work with Rosetta 2 (when invoked from x86_64 code); steps to reproduce:

curl -LO https://github.com/eugeneware/ffmpeg-static/releases/download/b6.0/ffmpeg-darwin-arm64
curl -LO https://github.com/eugeneware/ffmpeg-static/releases/download/b6.0/ffmpeg-darwin-x64
chmod +x ffmpeg-darwin*
./ffmpeg-darwin-arm64 -f lavfi -i testsrc -c:v hevc_videotoolbox -t 1 -f mp4 /dev/null -y  ;: works
./ffmpeg-darwin-x64 -f lavfi -i testsrc -c:v hevc_videotoolbox -t 1 -f mp4 /dev/null -y    ;: _does not_ work
MartinPulec commented 8 months ago

I'll perhaps postpone (eventually close) the problem for now since it is not directly in UG. AFAIK, it should work if you compiled native arm64 UG build. I've also created POC arm64 snapshot.

We will eventually switch to arm64 native builds in future and keep x64 builds separated.

If you'd intend to use the above build on regular basis, please let us know – as it is manually built, I'll try to rebuilt it from time to time then.

sogorman commented 8 months ago

Sounds good, appreciate you and the team!

MartinPulec commented 4 months ago

Hi, since we already build arm64 M1 (and later) builds (continuous and 1.9), I assume this issue is solved.