Config: Add Apple Video Toolbox hardware transcoding support for macOS #1843
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I know Docker installation is the priority right now, and binaries for macOS or other platforms may or may not come in the future. Perhaps these modifications will be useful in the future if/when that comes.
For my use case, I prefer to run Photoprism on macOS without Docker, due to disk I/O performance of Docker on Mac. Photoprism compiles and runs smoothly already. Thank you.
What did not work was
ffmpegtranscoding usinglibx264.ffmpegthrew an error ofUnrecognized option 'num_output_buffers'.This got me digging further, and for macOS,ffmpegcan use Video Toolbox for hardware accelerated video encoding/transcoding.These proposed changes to the code are to recognize when
PHOTOPRISM_FFMPEG_ENCODERis set toh264_videotoolboxand then to provideffmpegthe appropriate option string. The same options aslibx264are not available forh264_videotoolbox. The proposed code is trying to mimic how Intel QuickSync is recognized and used.It's been running very well for me over the past week, and the transcoding is fast (500ms on an old machine) for Live Photos. The hover functionality to trigger the Live Photo feels instantaneous.
My coding experience is limited, and I'm new to this excellent project. I hope this helps give back, is useful, and is not too much hassle to review. Given most devices can decode H.264 High Profile Level 5.1, it is hard coded as such, and this can be made to be set by new environment variables too.
One could also modify this to add an option to transcode to HEVC, using the
hevc_videotoolbox, and while that may save bandwidth, not every client device is compatible with HEVC. I see there is another pull to use HEVC when the client can play it. #513Unit test:
make testhad 310 tests pass, with one exception, which is unrelated to this pull request, as it occurred when testing a build without the code changes in this pull request.Acceptance test: Most of these worked. There were some errors They also are unrelated to the pull request, as the same ones occurred when testing a build without the code changes in this pull request.
Thanks again for an excellent project.