-
Notifications
You must be signed in to change notification settings - Fork 441
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
feat(ffmpeg): allow custom common options #9432
Conversation
FFmpeg is the project/framework name, while "ffmpeg" is the name of the tool. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your contribution and sorry for the long, long delay.
I have been testing GPU acceleration for the encoder and I eventually realized that it can be already enabled just by modifying the outputvideo
parameter, without having to modify the global options. I will add documentation for that in another pull request.
Nevertheless, being able to set the fmmpeg executable and the global options can still be useful in some cases :-)
After such a long delay (sorry again) it would have been unfair to ask for changes, so I made them myself. I rebased on latest master to solve the conflict, fixed a related but previously existing typo that I noticed, renamed commonoptions
to common
and slightly adjusted its documentation, and also made the common options configurable in the benchmark tool. However, I could not force push to your repository to add those changes, so I pushed to rutgerputter-allow-custom-common-options in the main repository instead.
Could you reset your branch to point to the tip of rutgerputter-allow-custom-common-options? Thanks and sorry for the inconvenience!
Thank you so much for taking this into consideration and implementing the change. No worries for the delay, just happy I could contribute in some fashion. I've pulled your changes into https://github.com/rutgerputter/spreed-gpu, in the master branch. Also, enabling the use of a specific encoder needs to be done in the common options, at least in the intel vaapi case I'm using. Using only the outputvideo is not enough sadly. Let me know I can be of any help 😄 |
Didn't need to close |
Thanks a lot! :-)
Rather than merging the changes into the master branch, could you reset the master branch so its tip points to the last commit in the changes? That is, something like:
As soon as it is merged you can change again the tip of your master branch as you wish ;-)
That is unexpected 🤔 Intel VAAPI should work with something like the following (as mentioned I will add a pull request to document all this):
Could you check if that works for you? You may need to switch vp8_vaapi with h264_vaapi if VP8 encoding is not supported in your CPU/iGPU, but other than that it should not require other options.
If you could check the above things it would be great :-) Thanks! |
Done! I hope it's now in the correct state to merge it 😄
So, just for record, here is my current/working config: [ffmpeg]
# The options given to FFmpeg to specifiy common options. The options given here
# fully override the default options.
commonoptions = ffmpeg -loglevel level+warning -n -init_hw_device vaapi=intel:/dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_device intel -filter_hw_device intel -thread_queue_size 4096
# The options given to FFmpeg to encode the audio output. The options given here
# fully override the default options for the audio output.
outputaudio = -c:a libopus -b:a 128K
# The options given to FFmpeg to encode the video output. The options given here
# fully override the default options for the video output.
outputvideo = -vf format=nv12|vaapi,hwupload -c:v h264_vaapi -deadline:v realtime -crf 10 -b:v 2M
# The extension of the file for audio only recordings.
#extensionaudio = .ogg
# The extension of the file for audio and video recordings.
extensionvideo = .mkv If I change the common options back to default and use the outputvideo line you've suggested (with vaapi_h264), this is the error:
IIRC, the |
Almost :-) It seems that your commit is not signed off. We can still force merge, but it would be great if you could do something like
Mmm, maybe it depends on the ffmpeg version? 🤔 I have tested also with Could you try to run the following? You may need to manually install
Or, even, directly calling
Thanks! |
Signed-off-by: Rutger Putter <rutger.putter@siemens.com>
This is more consistent with the configuration file, and it will be also more consistent with the argument that will be added to the benchmark to customize the ffmpeg executable and global options. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com> Signed-off-by: Rutger Putter <rutger.putter@siemens.com>
Done! Looks like the pipeline is happy too 😄
So here is the output of the direct ffmpeg command and the version of ffmpeg in my docker container, it's the same one as when trying to record with these settings: root@cc445a4e063b:~# ffmpeg -loglevel level+warning -n -i ./Big_Buck_Bunny_720_10s_1MB.mp4 -c:a libopus -init_hw_device vaapi -vf format=nv12,hwupload -c:v h264_vaapi -b:v 1M ffmpeg-vaapi-test.mkv
[hwupload @ 0x55f810767b00] [error] A hardware device reference is required to upload frames to.
[Parsed_hwupload_1 @ 0x55f810401c00] [error] Query format failed for 'Parsed_hwupload_1': Invalid argument
[error] Error reinitializing filters!
[error] Failed to inject frame into filter network: Invalid argument
[fatal] Error while processing the decoded data for stream #0:0
root@cc445a4e063b:~# ffmpeg
ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I hope it's now in the correct state to merge it 😄
Almost :-) It seems that your commit is not signed off. We can still force merge, but it would be great if you could do something like
git rebase --interactive 43ecc699^
, mark commit43ecc699
for edition,git commit --signoff --amend
,git rebase --continue
and finally force push your master branch again. Thanks and sorry for the inconvenience!Done! Looks like the pipeline is happy too 😄
Thanks a lot!
Mmm, maybe it depends on the ffmpeg version? 🤔 I have tested also with
h264_vaapi
and it worked fine 🤷 Well, I did not record a call, but directly used the benchmark tool, although the order in which the options are given toffmpeg
should be the same in both cases (but maybe there is a bug there ;-) ).
Could you try to run the following? You may need to manually installpython3-psutil
(it will be added to the dependency list in a pull request that I am working on, but currently it is missing in master)python3 -m nextcloud.talk.recording.Benchmark --length 10 --verbose-extra --video-args='-init_hw_device vaapi -vf format=nv12,hwupload -c:v h264_vaapi -b:v 1M' {SOME-VIDEO-FILE} ./ffmpeg-vaapi-test.mkv
Or, even, directly calling
ffmpeg
with:ffmpeg -loglevel level+warning -n -i {SOME-VIDEO-FILE} -c:a libopus -init_hw_device vaapi -vf format=nv12,hwupload -c:v h264_vaapi -b:v 1M ffmpeg-vaapi-test.mkv
Thanks!
So here is the output of the direct ffmpeg command and the version of ffmpeg in my docker container, it's the same one as when trying to record with these settings:
root@cc445a4e063b:~# ffmpeg -loglevel level+warning -n -i ./Big_Buck_Bunny_720_10s_1MB.mp4 -c:a libopus -init_hw_device vaapi -vf format=nv12,hwupload -c:v h264_vaapi -b:v 1M ffmpeg-vaapi-test.mkv [hwupload @ 0x55f810767b00] [error] A hardware device reference is required to upload frames to. [Parsed_hwupload_1 @ 0x55f810401c00] [error] Query format failed for 'Parsed_hwupload_1': Invalid argument [error] Error reinitializing filters! [error] Failed to inject frame into filter network: Invalid argument [fatal] Error while processing the decoded data for stream #0:0 root@cc445a4e063b:~# ffmpeg ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}... Use -h to get full help or, even better, run 'man ffmpeg'
Interesting, thanks for the information. I used ffmpeg 4.3.6, so maybe it is indeed related to the version.
But independently of that... let's merge! :-)
Just a code suggestion, feel free to comment. I hope this is up to you coding standards.
☑️ Resolves
🚧 Tasks
🏁 Checklist
docs/
has been updated or is not required