Closed singhkays closed 2 years ago
I do not have a Mac even for testing, so nothing I could well vet, but I am not opposed to adding hardware acceleration options. I am actually working on NVENC HEVC capabilities at the moment.
If you (or anyone) has access to one, please provide the output of:
ffmpeg -h encoder=hevc_videotoolbox
and the configuration of:
ffmpeg -version
Can also provide h264_videotoolbox
, but honestly I am not really working towards adding more H.264 at this time
I'm happy to help test this as well as if you can build a native Apple Silicon build. Here are the outputs you requested
➜ ~ ffmpeg -h encoder=hevc_videotoolbox
ffmpeg version git-2021-01-09-42ee389 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.28)
configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-42ee389_6 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --disable-libjack --disable-indev=jack --enable-opencl --enable-videotoolbox --disable-htmlpages --enable-libfdk-aac --enable-nonfree
libavutil 56. 63.100 / 56. 63.100
libavcodec 58.115.102 / 58.115.102
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
libpostproc 55. 8.100 / 55. 8.100
Encoder hevc_videotoolbox [VideoToolbox H.265 Encoder]:
General capabilities: delay hardware
Threading capabilities: none
Supported pixel formats: videotoolbox_vld nv12 yuv420p p010le
hevc_videotoolbox AVOptions:
-profile <int> E..V....... Profile (from 0 to 3) (default 0)
main 1 E..V....... Main Profile
main10 2 E..V....... Main10 Profile
-allow_sw <boolean> E..V....... Allow software encoding (default false)
-require_sw <boolean> E..V....... Require software encoding (default false)
-realtime <boolean> E..V....... Hint that encoding should happen in real-time if not faster (e.g. capturing from camera). (default false)
-frames_before <boolean> E..V....... Other frames will come before the frames in this session. This helps smooth concatenation issues. (default false)
-frames_after <boolean> E..V....... Other frames will come after the frames in this session. This helps smooth concatenation issues. (default false)
➜ ~ ffmpeg -version
ffmpeg version git-2021-01-09-42ee389 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.28)
configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-42ee389_6 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --disable-libjack --disable-indev=jack --enable-opencl --enable-videotoolbox --disable-htmlpages --enable-libfdk-aac --enable-nonfree
libavutil 56. 63.100 / 56. 63.100
libavcodec 58.115.102 / 58.115.102
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
libpostproc 55. 8.100 / 55. 8.100
➜ ~ ffmpeg -h encoder=h264_videotoolbox
ffmpeg version git-2021-01-09-42ee389 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.28)
configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-42ee389_6 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --disable-libjack --disable-indev=jack --enable-opencl --enable-videotoolbox --disable-htmlpages --enable-libfdk-aac --enable-nonfree
libavutil 56. 63.100 / 56. 63.100
libavcodec 58.115.102 / 58.115.102
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
libpostproc 55. 8.100 / 55. 8.100
Encoder h264_videotoolbox [VideoToolbox H.264 Encoder]:
General capabilities: delay
Threading capabilities: none
Supported pixel formats: videotoolbox_vld nv12 yuv420p
h264_videotoolbox AVOptions:
-profile <int> E..V....... Profile (from 0 to 5) (default 0)
baseline 1 E..V....... Baseline Profile
main 2 E..V....... Main Profile
high 3 E..V....... High Profile
extended 4 E..V....... Extend Profile
-level <int> E..V....... Level (from 0 to 52) (default 0)
1.3 13 E..V....... Level 1.3, only available with Baseline Profile
3.0 30 E..V....... Level 3.0
3.1 31 E..V....... Level 3.1
3.2 32 E..V....... Level 3.2
4.0 40 E..V....... Level 4.0
4.1 41 E..V....... Level 4.1
4.2 42 E..V....... Level 4.2
5.0 50 E..V....... Level 5.0
5.1 51 E..V....... Level 5.1
5.2 52 E..V....... Level 5.2
-coder <int> E..V....... Entropy coding (from 0 to 2) (default 0)
cavlc 1 E..V....... CAVLC entropy coding
vlc 1 E..V....... CAVLC entropy coding
cabac 2 E..V....... CABAC entropy coding
ac 2 E..V....... CABAC entropy coding
-a53cc <boolean> E..V....... Use A53 Closed Captions (if available) (default true)
-allow_sw <boolean> E..V....... Allow software encoding (default false)
-require_sw <boolean> E..V....... Require software encoding (default false)
-realtime <boolean> E..V....... Hint that encoding should happen in real-time if not faster (e.g. capturing from camera). (default false)
-frames_before <boolean> E..V....... Other frames will come before the frames in this session. This helps smooth concatenation issues. (default false)
-frames_after <boolean> E..V....... Other frames will come after the frames in this session. This helps smooth concatenation issues. (default false)
wow not a lot of options, makes it easier for moi!
For a build have to wait on github actions support for it: https://github.com/actions/virtual-environments/issues/2187
For a build have to wait on github actions support for it: actions/virtual-environments#2187
Ooh..that's going to take a while :| Is it possible for me to compile a native build myself?
If you goal is to just run it, should be able to do that: https://github.com/cdgriffith/FastFlix#running-from-source-code Good first step to make sure of either way, I do not know if all the packages are supported on the new macs yet.
If you want to actually do the work to make a redistributable executable, you could go through the steps in the build script and see how it works out: https://github.com/cdgriffith/FastFlix/blob/master/.github/workflows/build_mac.yaml
If you goal is to just run it, should be able to do that: https://github.com/cdgriffith/FastFlix#running-from-source-code Good first step to make sure of either way, I do not know if all the packages are supported on the new macs yet.
Yep, I tried this already with Python 3.9.1 (Apple Silicon installer). Looks like the Python itself is still "Intel" architecture and hasn't transitioned to Apple Silicon. I'm assuming building the redistributable will also be an Intel version.
Interesting readings about Apple Silicon software porting:
Hope that helps !
Personally, I don't mind using Fastflix with Rosetta 2. What is important to me, as mentioned in the first post, is the use of "Apple Silicon" encoders. What I did was to download the pre compiled version of ffmpeg from here: https://www.osxexperts.net/
And then pointing FastFlix to that location. If you look into top/ps/activity monitor and expand the process of FastFlix / Python you should recognize a "Apple Silicon" process while encoding. Works for me.
Plus, the binary from the URL above also includes support ARM Neon, which speeds up the encoding significantly!
Another way would be using Homebrew to install ffmpeg binaries. BUT, those don't include the ARM Neon patch. Resulting in lower fps - at least for me.
Bump this to M1 MAX encoders :) What needs to be done, just getting the ARM patches into the Homebrew build?
ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 13.0.0 (clang-1300.0.29.3)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/4.4.1_2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Encoder hevc_videotoolbox [VideoToolbox H.265 Encoder]:
General capabilities: delay hardware
Threading capabilities: none
Supported pixel formats: videotoolbox_vld nv12 yuv420p bgra p010le
hevc_videotoolbox AVOptions:
-profile <int> E..V....... Profile (from 0 to 3) (default 0)
main 1 E..V....... Main Profile
main10 2 E..V....... Main10 Profile
-alpha_quality <double> E..V....... Compression quality for the alpha channel (from 0 to 1) (default 0)
-allow_sw <boolean> E..V....... Allow software encoding (default false)
-require_sw <boolean> E..V....... Require software encoding (default false)
-realtime <boolean> E..V....... Hint that encoding should happen in real-time if not faster (e.g. capturing from camera). (default false)
-frames_before <boolean> E..V....... Other frames will come before the frames in this session. This helps smooth concatenation issues. (default false)
-frames_after <boolean> E..V....... Other frames will come after the frames in this session. This helps smooth concatenation issues. (default false)
These are M1 Max and presumably M1 Pro encoders if that would be helpful anywhere
ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 13.0.0 (clang-1300.0.29.3)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/4.4.1_2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
and dis ffmpeg version
I have created a new branch with hevc_videotoolbox support. Any brave users willing to test would be greatly appreciated as I don't have a box to try it on.
git clone https://github.com/cdgriffith/FastFlix.git
cd FastFlix
git checkout videotoolbox
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
python -m fastflix
There should be a new dropdown option for HEVC videotoolbox. Please test to make sure it works / try to break it!
Nice, will try it out in upcoming days. :) By any chance, could you add avc (h264_videotoolbox) support as well?
By any chance, could you add avc (h264_videotoolbox) support as well?
Yup, will add that if this one works well. Just easier to do one at a time.
@E-t-z I've added support for h264 in that branch as well if you can test it out!
@cdgriffith will take a look on Sunday, sorry for the delay.
h265_videotoolbox seemed to work quite well.
H265 and H264 added with https://github.com/cdgriffith/FastFlix/releases/tag/4.9.0 !
How do I select videotoolbox encoder?
Looking at the code I suspect the issue is requires
which should be videotoolbox
as per ffmpeg version/configuration provided above, eg --enable-videotoolbox
in:
% ffmpeg -version
ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with Apple clang version 13.1.6 (clang-1316.0.21.2.5)
configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.0.1-with-options_2 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --enable-opencl --enable-audiotoolbox --enable-videotoolbox --enable-neon --disable-htmlpages
You are totally right @sublimal, good catch, thank you!
Ok hopefully that did it, please let me know if not working with https://github.com/cdgriffith/FastFlix/releases/tag/4.9.4 !
Hi, do you have plans to support the Apple M1 hardware encoders that are supported in ffmpeg? h264_videotoolbox for H.264, hevc_videotoolbox for H.265
These are available in FFmpeg builds https://trac.ffmpeg.org/wiki/HWAccelIntro#VideoToolbox