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

Config: Add Apple Video Toolbox hardware transcoding support for macOS #1843

Merged
merged 2 commits into from
Jan 3, 2022

Conversation

aniqueta
Copy link
Contributor

@aniqueta aniqueta commented Dec 28, 2021

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 ffmpeg transcoding using libx264. ffmpeg threw an error of Unrecognized option 'num_output_buffers'. This got me digging further, and for macOS, ffmpeg can use Video Toolbox for hardware accelerated video encoding/transcoding.

These proposed changes to the code are to recognize when PHOTOPRISM_FFMPEG_ENCODER is set to h264_videotoolbox and then to provide ffmpeg the appropriate option string. The same options as libx264 are not available for h264_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. #513

Unit test: make test had 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.

@lastzero
Copy link
Member

lastzero commented Jan 3, 2022

Thanks! I have not tested it on macOS, but I trust that it works for you :)

@lastzero lastzero merged commit 24577aa into photoprism:develop Jan 3, 2022
@lastzero lastzero added the please-test Ready for acceptance test label Jan 3, 2022
@lastzero lastzero self-requested a review January 3, 2022 12:36
@lastzero lastzero changed the title Enable Apple Video Toolbox hardware acceleration for macOS Videos: Enable Apple Video Toolbox hardware acceleration for macOS Jan 3, 2022
@lastzero lastzero changed the title Videos: Enable Apple Video Toolbox hardware acceleration for macOS Videos: Add Apple Video Toolbox hardware acceleration support for macOS Jan 3, 2022
@lastzero lastzero changed the title Videos: Add Apple Video Toolbox hardware acceleration support for macOS Videos: Add Apple Video Toolbox hardware transcoding support for macOS Jan 3, 2022
@lastzero lastzero changed the title Videos: Add Apple Video Toolbox hardware transcoding support for macOS Config: Add Apple Video Toolbox hardware transcoding support for macOS Jan 6, 2022
@lastzero lastzero added released Available in the stable release and removed please-test Ready for acceptance test labels Mar 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Available in the stable release
Projects
Status: Release 🌈
Development

Successfully merging this pull request may close these issues.

None yet

2 participants