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

Unable to make H.264 NVENC work #3107

Closed
mattlazarowitz opened this issue Jan 27, 2025 · 2 comments
Closed

Unable to make H.264 NVENC work #3107

mattlazarowitz opened this issue Jan 27, 2025 · 2 comments

Comments

@mattlazarowitz
Copy link

Motion and MotionEyeversion info:

motionEye Version  0.43.1b2
Motion Version  4.7.0
OS Version  Ubuntu 24.04

Here is the output from my nvidia-smi command:

nvidia-smi
Mon Jan 27 22:16:36 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.120                Driver Version: 550.120        CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  Quadro P620                    Off |   00000000:01:00.0 Off |                  N/A |
| 34%   37C    P8             N/A /  N/A  |       2MiB /   2048MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

FFMPEG version:

ffmpeg -h
ffmpeg version 6.1.1-3ubuntu5 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 13 (Ubuntu 13.2.0-23ubuntu3)

More info from FFMPEG:

ffmpeg -codecs | grep nvenc
ffmpeg version 6.1.1-3ubuntu5 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 13 (Ubuntu 13.2.0-23ubuntu3)
  configuration: --prefix=/usr --extra-version=3ubuntu5 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --disable-omx --enable-gnutls --enable-libaom --enable-libass --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libharfbuzz --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-openal --enable-opencl --enable-opengl --disable-sndio --enable-libvpl --disable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-ladspa --enable-libbluray --enable-libjack --enable-libpulse --enable-librabbitmq --enable-librist --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libx264 --enable-libzmq --enable-libzvbi --enable-lv2 --enable-sdl2 --enable-libplacebo --enable-librav1e --enable-pocketsphinx --enable-librsvg --enable-libjxl --enable-shared
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
 DEV.L. av1                  Alliance for Open Media AV1 (decoders: libdav1d libaom-av1 av1 av1_cuvid av1_qsv) (encoders: libaom-av1 librav1e libsvtav1 av1_nvenc av1_qsv av1_vaapi)
 DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m h264_qsv h264_cuvid) (encoders: libx264 libx264rgb h264_nvenc h264_qsv h264_v4l2m2m h264_vaapi)
 DEV.L. hevc                 H.265 / HEVC (High Efficiency Video Coding) (decoders: hevc hevc_qsv hevc_v4l2m2m hevc_cuvid) (encoders: libx265 hevc_nvenc hevc_qsv hevc_v4l2m2m hevc_vaapi)

And here is a log snippet from MotionEye when motion is triggered:

[1:ml1:Camera1] [NTC] [ALL] motion_detected: Motion detected - starting event 1.
[1:ml1:Camera1] [DBG] [EVT] exec_command: Executing external command '/usr/local/lib/python3.12/dist-packages/motioneye/scripts/relayevent.sh "/etc/motioneye/motioneye.conf" start 1'
[1:ml1:Camera1] [INF] [EVT] event_ffmpeg_newfile: Source FPS 29
[1:ml1:Camera1] [NTC] [ENC] ffmpeg_set_codec_preferred: Using codec h264_nvenc
[1:ml1:Camera1] [INF] [ENC] ffmpeg_set_quality: h264_nvenc codec vbr/crf/bit_rate: 12
[1:ml1:Camera1] [INF] [ENC] ffmpeg_avcodec_log: Undefined constant or missing '(' in 'ultrafast'
[1:ml1:Camera1] [INF] [ENC] ffmpeg_avcodec_log: Unable to parse option value "ultrafast"
[1:ml1:Camera1] [INF] [ENC] ffmpeg_avcodec_log: Error setting option preset to value ultrafast.

According the Nvidia GPU matrix the Quadro P620 has one NVENC unit and supports 8 concurrent streams. It also supports everything except AV1.

Do I need to use a different version/build of FFMPEG? Is there an issue with the way MotionEye/Motion is invoking it? Is this a known issue, and if so, is there a fix?

@mattlazarowitz
Copy link
Author

It looks like the issue is between motion and ffmpeg.
From Motion:
https://github.com/Motion-Project/motion/blob/8d69cbf27a1c2fcffd7ff0f5558f3e7de277b8d1/src/ffmpeg.c#L540

It sounds like the format for the presets was changed some time ago and 'ultrafast' is no longer a thing (in trying to look at ffmpeg's git logs, it seems like it was removed some time ago).

Is there a way for MotionEye to override the options Motion uses when it calls ffmpeg?
If so, can that be handled automatically int he future for the h.264 nvenc option?

@mattlazarowitz
Copy link
Author

The root cause of the problem is motion. It's not set up to work with nvenc.
I've been hacking on Motion with a local build to get it working and have acceptable quality.
I'll go raise the issue over in the Motion repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant