Problems with proxy files and hardware support

Hi,

I’ve tried proxy generation with hardware support and eventually got to the point where ffmpeg finds my GPU, but stops with an error: [hevc_nvenc @ 0x56209e044300] B frames as references are not supported.

Google found this on stackoverflow which mentions an additional command line parameter (-b_ref_mode 0).

However, I can’t seem to find a simple way to modify shotcut’s ffmpeg parameters. Is there another way to do this apart from modifying the code and recompiling?

Thanks!

I do not think that option should be needed. You can see the command line that Shotcut generates for proxy in View > Application Log. It includes -g 1 -bf 0 for no B frames. It is working for me on RTX 3060. There is no easy way to modify this command line if you are not a regular Shotcut developer. I followed your link and its links to read more about this. It looks like it might be an issue with older cards. It is ridiculous that this option needs to be added; however, I can add it for the next release (but not the beta that was already prepared this morning). You can get it from tomorrow’s daily builds in GitHub Actions.

Hi Dan,

thanks for the quick reply and your hint at the application log!

I took the ffmpeg call from there:

ffmpeg -loglevel verbose -i in.mp4 -max_muxing_queue_size 9999 -map 0:a? -map 0:V? -map_metadata 0 -ignore_unknown -vf yadif=deint=interlaced,scale=width=-2:height=540:in_range=mpeg:out_range=mpeg -color_range mpeg -color_primaries bt709 -color_trc bt709 -colorspace bt709 -f mp4 -codec:a ac3 -b:a 256k -pix_fmt yuv420p -codec:v hevc_nvenc -rc constqp -qp:v 37 -g 1 -bf 0 -y out.mp4

and ran it with the ffmpeg provided by my distribution where it succeeded:

command line output with ffmpeg 4.4.2
# ffmpeg -loglevel verbose -i in.mp4 -max_muxing_queue_size 9999 -map '0:a?' -map '0:V?' -map_metadata 0 -ignore_unknown -vf yadif=deint=interlaced,scale=width=-2:height=540:in_range=mpeg:out_range=mpeg -color_range mpeg -color_primaries bt709 -color_trc bt709 -colorspace bt709 -f mp4 -codec:a ac3 -b:a 256k -pix_fmt yuv420p -codec:v hevc_nvenc -rc constqp -qp:v 37 -g 1 -bf 0 -y out.mp4
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  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
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2023-09-29T06-43-02+0200_0718.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    creation_time   : 2023-09-29T06:43:02.000000Z
    encoder         : Lavf56.15.102
  Duration: 00:00:29.20, start: 0.000000, bitrate: 93160 kb/s
  Stream #0:0(und): Video: hevc (Main 10), 1 reference frame (hvc1 / 0x31637668), yuv420p10le(tv, left), 3840x2160, 93159 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 29 tbc (default)
    Metadata:
      creation_time   : 2023-09-29T06:43:02.000000Z
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
Stream map '0:a?' matches no streams; ignoring.
Codec AVOption b (set bitrate (in bits/s)) specified for output file #0 (out.mp4) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> hevc (hevc_nvenc))
Press [q] to stop, [?] for help
[Parsed_scale_1 @ 0x559b2d8fa000] w:-2 h:540 flags:'bicubic' interl:0
[graph 0 input from stream 0:0 @ 0x559b2d8fb4c0] w:3840 h:2160 pixfmt:yuv420p10le tb:1/30000 fr:30000/1001 sar:0/1
[Parsed_scale_1 @ 0x559b2d8fa000] w:3840 h:2160 fmt:yuv420p10le sar:0/1 -> w:960 h:540 fmt:yuv420p sar:0/1 flags:0x4
[hevc_nvenc @ 0x559b2d8df940] Loaded Nvenc version 12.0
[hevc_nvenc @ 0x559b2d8df940] Nvenc initialized successfully
[hevc_nvenc @ 0x559b2d8df940] 1 CUDA capable devices found
[hevc_nvenc @ 0x559b2d8df940] [ GPU #0 - < NVIDIA GeForce GTX 1060 6GB > has Compute SM 6.1 ]
[hevc_nvenc @ 0x559b2d8df940] supports NVENC
Output #0, mp4, to 'out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    creation_time   : 2023-09-29T06:43:02.000000Z
    encoder         : Lavf58.76.100
  Stream #0:0(und): Video: hevc (Main), 1 reference frame (hev1 / 0x31766568), yuv420p(tv, bt709, progressive, left), 960x540 (0x0), q=2-31, 2000 kb/s, 29.97 fps, 30k tbn (default)
    Metadata:
      creation_time   : 2023-09-29T06:43:02.000000Z
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc58.134.100 hevc_nvenc
    Side data:
      cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A
No more output streams to write to, finishing.e=00:00:28.62 bitrate= 586.0kbits/s speed=1.15x
frame=  875 fps= 35 q=29.0 Lsize=    2200kB time=00:00:29.16 bitrate= 617.9kbits/s speed=1.16x
video:2195kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.198352%
Input file #0 (2023-09-29T06-43-02+0200_0718.mp4):
  Input stream #0:0 (video): 875 packets read (339982325 bytes); 875 frames decoded;
  Total: 875 packets (339982325 bytes) demuxed
Output file #0 (out.mp4):
  Output stream #0:0 (video): 875 frames encoded; 875 packets muxed (2248019 bytes);
  Total: 875 packets (2248019 bytes) muxed
[AVIOContext @ 0x559b2d8dffc0] Statistics: 2 seeks, 12 writeouts
[hevc_nvenc @ 0x559b2d8df940] Nvenc unloaded
[AVIOContext @ 0x559b2d8c71c0] Statistics: 340022510 bytes read, 2 seeks

This is the ffmpeg version from my system:

ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --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-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
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
libswscale      5.  9.100 /  5.  9.100
libswresample   3.  9.100 /  3.  9.100
libpostproc    55.  9.100 / 55.  9.100

which is much older than the version shotcut uses:

ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 12.2.0 (GCC)
configuration: --prefix=/app --enable-rpath --enable-gpl --enable-version3 --disable-static --enable-shared --disable-doc --disable-alsa --enable-libfontconfig --enable-libfreetype --enable-libopus --enable-libpulse --enable-librsvg --enable-libvpx --enable-libdav1d --enable-libxml2 --enable-libx264 --enable-libx265 --enable-libmp3lame --enable-libtheora --enable-libvmaf --enable-libvorbis --enable-libwebp --enable-libaom --enable-libzimg --disable-decoder=libaom_av1 --enable-nvenc --enable-vaapi
libavutil      58.  2.100 / 58.  2.100
libavcodec     60.  3.100 / 60.  3.100
libavformat    60.  3.100 / 60.  3.100
libavdevice    60.  1.100 / 60.  1.100
libavfilter     9.  3.100 /  9.  3.100
libswscale      7.  1.100 /  7.  1.100
libswresample   4. 10.100 /  4. 10.100
libpostproc    57.  1.100 / 57.  1.100

I get the same error when I invoke shotcut’s ffmpeg directly:

command line output with ffmpeg 6.0
flatpak run --command=ffmpeg org.shotcut.Shotcut -loglevel verbose -i 2023-09-29T06-43-02+0200_0718.mp4 -max_muxing_queue_size 9999 -map '0:a?' -map '0:V?' -map_metadata 0 -ignore_unknown -vf yadif=deint=interlaced,scale=width=-2:height=540:in_range=mpeg:out_range=mpeg -color_range mpeg -color_primaries bt709 -color_trc bt709 -colorspace bt709 -f mp4 -codec:a ac3 -b:a 256k -pix_fmt yuv420p -codec:v hevc_nvenc -rc constqp -qp:v 37 -g 1 -bf 0 -y out2.mp4
ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (GCC)
  configuration: --prefix=/app --enable-rpath --enable-gpl --enable-version3 --disable-static --enable-shared --disable-doc --disable-alsa --enable-libfontconfig --enable-libfreetype --enable-libopus --enable-libpulse --enable-librsvg --enable-libvpx --enable-libdav1d --enable-libxml2 --enable-libx264 --enable-libx265 --enable-libmp3lame --enable-libtheora --enable-libvmaf --enable-libvorbis --enable-libwebp --enable-libaom --enable-libzimg --disable-decoder=libaom_av1 --enable-nvenc --enable-vaapi
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2023-09-29T06-43-02+0200_0718.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    creation_time   : 2023-09-29T06:43:02.000000Z
    encoder         : Lavf56.15.102
  Duration: 00:00:29.20, start: 0.000000, bitrate: 93161 kb/s
  Stream #0:0[0x1](und): Video: hevc (Main 10), 1 reference frame (hvc1 / 0x31637668), yuv420p10le(tv, left), 3840x2160, 93159 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
    Metadata:
      creation_time   : 2023-09-29T06:43:02.000000Z
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
Stream map '0:a?' matches no streams; ignoring.
[out#0/mp4 @ 0x55aa3f036fc0] Codec AVOption b (set bitrate (in bits/s)) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> hevc (hevc_nvenc))
Press [q] to stop, [?] for help
[Parsed_scale_1 @ 0x55aa3f220280] w:-2 h:540 flags:'' interl:0
[graph 0 input from stream 0:0 @ 0x55aa3f2209c0] w:3840 h:2160 pixfmt:yuv420p10le tb:1/30000 fr:30000/1001 sar:0/1
[Parsed_scale_1 @ 0x55aa3f220280] w:3840 h:2160 fmt:yuv420p10le sar:0/1 -> w:960 h:540 fmt:yuv420p sar:0/1 flags:0x00000004
[hevc_nvenc @ 0x55aa3f040140] Loaded Nvenc version 12.0
[hevc_nvenc @ 0x55aa3f040140] Nvenc initialized successfully
[hevc_nvenc @ 0x55aa3f040140] 1 CUDA capable devices found
[hevc_nvenc @ 0x55aa3f040140] [ GPU #0 - < NVIDIA GeForce GTX 1060 6GB > has Compute SM 6.1 ]
[hevc_nvenc @ 0x55aa3f040140] B frames as references are not supported
[hevc_nvenc @ 0x55aa3f040140] No capable devices found

Once I add the -b_ref_mode 0 parameter mentioned in the stackoverflow post, it works just fine. Thank you in advance for adding it already, I’ll check out the nightly as soon as I can.

From a pure developer perspective I’d advocate for factoring out the command line parameters in an application specific data file (e.g. xml or json) and loading it on program startup. It won’t slow down shotcut, but you’ll gain separation of code & data, which improves maintainability, proper git diffs for your data and the ability for users to add custom parameters when necessary. And you don’t have to recompile every time you make a change :slight_smile:

If you like I can create a Github ticket.

Cheers!

There is a fair amount of logic involved.

If you like I can create a Github ticket.

You can create a pull request with the change, but an Issue ticket for this will be closed.

Hi Dan,

it’d be certainly interesting and fun to dust off my C++ skills but I from a pure user perspective I see very little advantage in custom ffmpeg parameters. Being quite constraint in time these days I think I’ll pass :slight_smile:

However, thank you very much for your work in providing and maintaining this great software. I know how much of a time sink an open source project can be and I appreciate your effort a lot!

On a side note, it boggles my mind how much faster and smoother video editing with VN is on my phone (S23+) compared to my current desktop PC (i5-7600K CPU @ 3.80GHz, GeForce GTX 1060 6GB).
There’s not even a hint of lagging, skipping or any other performance problem on my phone, even after applying a LUT, color corrections, reversing videos etc. I figured my desktop PC should have an advantage here, but apparently not.
Now I have the choice between a great UI (keyboard, mouse, big screen) and mediocre performance or a mediocre UI (two fingers, small screen) and great performance :see_no_evil:

Does the phone support USB-C external monitor and mouse/keyboard over Bluetooth to fix the UI issues? Such as NexDock:

https://nexdock.com/tech-specs/

On the flip side, I have found Shotcut performance to be excellent with proxies and Preview Scaling, even for green screen work. The difference being that the phone uses GPU while Shotcut uses CPU (I have GPU Effects disabled for now due to needing the green screen filter).

Many great options!

1 Like

Hey Austin, great options here, thank you!

After editing another short movie with Shotcut I really started to enjoy it. The trick is to use proxy files all over (of course) and do the grading in the end (which is best practice any way I think). If I feel the need to re-edit I just turn off the grading.

The downside of my phone editing app is that it’s a subscription only app (after 100 videos or so) which I really don’t like. I’d not have any qualms about a one-time license fee, but those subscription models are getting out of hand…

For practicability reasons I’d be interested in a tablet for editing photos & videos on the go, but I don’t really want to switch editing tools (darktable & shotcut vs proprietary apps). Maybe a juicier notebook could fill the gap.

1 Like