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

feat(ffmpeg): allow custom common options #9432

Merged
merged 4 commits into from
Sep 20, 2023
Merged

feat(ffmpeg): allow custom common options #9432

merged 4 commits into from
Sep 20, 2023

Conversation

rutgerputter
Copy link

Just a code suggestion, feel free to comment. I hope this is up to you coding standards.

☑️ Resolves

🚧 Tasks

  • ...

🏁 Checklist

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>
Copy link
Member

@danxuliu danxuliu left a 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!

@rutgerputter
Copy link
Author

rutgerputter commented Sep 18, 2023

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 😄

@rutgerputter
Copy link
Author

rutgerputter commented Sep 18, 2023

Didn't need to close

@rutgerputter rutgerputter reopened this Sep 18, 2023
@danxuliu
Copy link
Member

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.

Thanks a lot! :-)

I've pulled your changes into https://github.com/rutgerputter/spreed-gpu, in the master branch.

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:

git push --force-with-lease spreed-gpu 92b74622e0:master

As soon as it is merged you can change again the tip of your master branch as you wish ;-)

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.

That is unexpected 🤔 Intel VAAPI should work with something like the following (as mentioned I will add a pull request to document all this):

outputvideo = -init_hw_device vaapi -vf format=nv12,hwupload -c:v vp8_vaapi -b:v 2M

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.

Let me know I can be of any help 😄

If you could check the above things it would be great :-) Thanks!

@rutgerputter
Copy link
Author

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.

Thanks a lot! :-)

I've pulled your changes into https://github.com/rutgerputter/spreed-gpu, in the master branch.

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:

git push --force-with-lease spreed-gpu 92b74622e0:master

Done! I hope it's now in the correct state to merge it 😄

As soon as it is merged you can change again the tip of your master branch as you wish ;-)

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.

That is unexpected 🤔 Intel VAAPI should work with something like the following (as mentioned I will add a pull request to document all this):

outputvideo = -init_hw_device vaapi -vf format=nv12,hwupload -c:v vp8_vaapi -b:v 2M

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.

Let me know I can be of any help 😄

If you could check the above things it would be great :-) Thanks!

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:

Sep 19 08:51:20 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Server:Start recording: https://cloud.maas-opleidingen.nl/ smfycxyr
Sep 19 08:51:20 cc445a4e063b nextcloud-talk-recording: INFO:werkzeug:172.19.0.8 - - [19/Sep/2023 08:51:20] "POST /api/v1/room/smfycxyr HTTP/1.1" 200 -
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[warning] Guessed Channel Layout for Input Stream #0.0 : stereo
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[x11grab @ 0x55cedbd69c80] [warning] Stream #0: not enough frames to estimate rate; consider increasing probesize
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[hwupload @ 0x55cedbd892c0] [error] A hardware device reference is required to upload frames to.
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[Parsed_hwupload_1 @ 0x55cedbd891c0] [error] Query format failed for 'Parsed_hwupload_1': Invalid argument
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[error] Error reinitializing filters!
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[error] Failed to inject frame into filter network: Invalid argument
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[fatal] Error while processing the decoded data for stream #1:0
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[pulse @ 0x55cedbd5e500] [warning] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording: ERROR:nextcloud.talk.recording.Server:Failed to start recording: https://cloud.maas-opleidingen.nl/ smfycxyr
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording: Traceback (most recent call last):
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording:   File "/usr/local/lib/python3.8/dist-packages/nextcloud/talk/recording/Server.py", line 170, in _startRecordingService
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording:     service.start(actorType, actorId)
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording:   File "/usr/local/lib/python3.8/dist-packages/nextcloud/talk/recording/Service.py", line 232, in start
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording:     raise Exception("recorder ended unexpectedly")
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording: Exception: recorder ended unexpectedly

IIRC, the init_hw_device needs to be defined before the input, otherwise it won`t work. Hence this MR 😉

@danxuliu
Copy link
Member

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 commit 43ecc699 for edition, git commit --signoff --amend, git rebase --continue and finally force push your master branch again. Thanks and sorry for the inconvenience!

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:

Sep 19 08:51:20 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Server:Start recording: https://cloud.maas-opleidingen.nl/ smfycxyr
Sep 19 08:51:20 cc445a4e063b nextcloud-talk-recording: INFO:werkzeug:172.19.0.8 - - [19/Sep/2023 08:51:20] "POST /api/v1/room/smfycxyr HTTP/1.1" 200 -
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[warning] Guessed Channel Layout for Input Stream #0.0 : stereo
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[x11grab @ 0x55cedbd69c80] [warning] Stream #0: not enough frames to estimate rate; consider increasing probesize
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[hwupload @ 0x55cedbd892c0] [error] A hardware device reference is required to upload frames to.
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[Parsed_hwupload_1 @ 0x55cedbd891c0] [error] Query format failed for 'Parsed_hwupload_1': Invalid argument
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[error] Error reinitializing filters!
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[error] Failed to inject frame into filter network: Invalid argument
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[fatal] Error while processing the decoded data for stream #1:0
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[pulse @ 0x55cedbd5e500] [warning] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording: ERROR:nextcloud.talk.recording.Server:Failed to start recording: https://cloud.maas-opleidingen.nl/ smfycxyr
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording: Traceback (most recent call last):
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording:   File "/usr/local/lib/python3.8/dist-packages/nextcloud/talk/recording/Server.py", line 170, in _startRecordingService
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording:     service.start(actorType, actorId)
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording:   File "/usr/local/lib/python3.8/dist-packages/nextcloud/talk/recording/Service.py", line 232, in start
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording:     raise Exception("recorder ended unexpectedly")
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording: Exception: recorder ended unexpectedly

IIRC, the init_hw_device needs to be defined before the input, otherwise it won`t work. Hence this MR 😉

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 to ffmpeg 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 install python3-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!

Rutger Putter and others added 3 commits September 20, 2023 09:59
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>
@rutgerputter
Copy link
Author

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 commit 43ecc699 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 😄

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:

Sep 19 08:51:20 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Server:Start recording: https://cloud.maas-opleidingen.nl/ smfycxyr
Sep 19 08:51:20 cc445a4e063b nextcloud-talk-recording: INFO:werkzeug:172.19.0.8 - - [19/Sep/2023 08:51:20] "POST /api/v1/room/smfycxyr HTTP/1.1" 200 -
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[warning] Guessed Channel Layout for Input Stream #0.0 : stereo
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[x11grab @ 0x55cedbd69c80] [warning] Stream #0: not enough frames to estimate rate; consider increasing probesize
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[hwupload @ 0x55cedbd892c0] [error] A hardware device reference is required to upload frames to.
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[Parsed_hwupload_1 @ 0x55cedbd891c0] [error] Query format failed for 'Parsed_hwupload_1': Invalid argument
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[error] Error reinitializing filters!
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[error] Failed to inject frame into filter network: Invalid argument
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[fatal] Error while processing the decoded data for stream #1:0
Sep 19 08:51:29 cc445a4e063b nextcloud-talk-recording: INFO:nextcloud.talk.recording.Service.recorder-https://cloud.maas-opleidingen.nl/-smfycxyr:[pulse @ 0x55cedbd5e500] [warning] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording: ERROR:nextcloud.talk.recording.Server:Failed to start recording: https://cloud.maas-opleidingen.nl/ smfycxyr
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording: Traceback (most recent call last):
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording:   File "/usr/local/lib/python3.8/dist-packages/nextcloud/talk/recording/Server.py", line 170, in _startRecordingService
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording:     service.start(actorType, actorId)
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording:   File "/usr/local/lib/python3.8/dist-packages/nextcloud/talk/recording/Service.py", line 232, in start
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording:     raise Exception("recorder ended unexpectedly")
Sep 19 08:51:31 cc445a4e063b nextcloud-talk-recording: Exception: recorder ended unexpectedly

IIRC, the init_hw_device needs to be defined before the input, otherwise it won`t work. Hence this MR 😉

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 to ffmpeg 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 install python3-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'

Copy link
Member

@danxuliu danxuliu left a 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 commit 43ecc699 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 to ffmpeg 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 install python3-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! :-)

@danxuliu danxuliu merged commit d5be55a into nextcloud:master Sep 20, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow editing of ffmpegCommon recording parameters for use of GPU acceleration
3 participants