paulpacifico / shutter-encoder

A professional video compression tool accessible to all, mostly based on FFmpeg.
https://www.shutterencoder.com
GNU General Public License v3.0
1.08k stars 59 forks source link

custom ffmpeg #246

Closed macb74 closed 4 days ago

macb74 commented 1 week ago

Hi, i had issues with ffmpeg, not supporting my GPU (nothing happened when I tried to configure encoding via GPU). I found out, that my local ffmpeg is able to use GPU.

I added a option to configure local ffmpeg. Maybe you want to take over. https://github.com/macb74/shutter-encoder/commit/c2ac38f743081d5a4e62d73119b277324874b304

Thanks Martin

paulpacifico commented 1 week ago

Hi,

I saw your commit previously. Thanks for writing that code, but why not using a simple shortcut to your local FFmpeg?

The main problem is that I'm compiling FFmpeg with specific arguments which allow to use every codecs of the list and I'm not sure the local FFmpeg version has the same capabilities or that mean I need to check the availability of each codec before creating the function list.

What do you think? Paul.

macb74 commented 1 week ago

Hi, I completely understand why your deliver ffmpeg. this makes sense.

What do you mean with 'simple shortcut to your local FFmpeg'? I think I missed something, where do I have to set this link?

The option via UI made sense to me, because it is transparent and usable for every kind of user, but that's just a idea.

Regards Martin

paulpacifico commented 6 days ago

Forget what I've said, the shortcut workaround does not work on Windows...

I think I will implement your code, but I'm curious why you don't get the GPU working with my FFmpeg build? Did you use the latest drivers?

Paul.

macb74 commented 6 days ago

I am on linux. I have an NVIDIA GPU. With the delivered FFmpeg, I get an error. I tried AppImage and deb packuage.

With this, nothing happens... image

With this, I got the following error: image

-strict -2 -v quiet -hide_banner -ss 0ms -i "/home/martin/Videos/Test/Biathlon1.mov" -filter_complex "[0:v]scale=248:440:sws_flags=bilinear:sws_dither=none[v];[0:a:0]showvolume=f=0:w=248:h=4:t=0:b=0:v=0:o=v:s=0:p=0.5[volume];[v][volume]overlay=W-w:H-h" -r 29.97 -c:v bmp -an -f image2pipe -
Input #0, lavfi, from 'nullsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: wrapped_avframe, yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (wrapped_avframe (native) -> h264 (h264_nvenc))
Press [q] to stop, [?] for help
 -strict -2 -v quiet -hide_banner -ss 0ms -i "/home/martin/Videos/Test/Biathlon1.mov" -filter_complex "[0:v]scale=248:440:sws_flags=bilinear:sws_dither=none[v];[0:a:0]showvolume=f=0:w=248:h=4:t=0:b=0:v=0:o=v:s=0:p=0.5[volume];[v][volume]overlay=W-w:H-h" -r 29.97 -c:v bmp -an -f image2pipe -

Input #0, lavfi, from 'nullsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: wrapped_avframe, yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 25 tbn
[vost#0:0 @ 0x6e5c040] Unknown encoder 'h264_vaapi'
[vost#0:0 @ 0x6e5c040] Error selecting an encoder
Error opening output file -.
Error opening output files: Encoder not found

Input #0, lavfi, from 'nullsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: wrapped_avframe, yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (wrapped_avframe (native) -> h264 (h264_v4l2m2m))
Press [q] to stop, [?] for help
[h264_v4l2m2m @ 0x7289540] Could not find a valid device
[h264_v4l2m2m @ 0x7289540] can't configure encoder
[vost#0:0/h264_v4l2m2m @ 0x7289040] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[vf#0:0 @ 0x728a780] Error sending frames to consumers: Invalid argument
[vf#0:0 @ 0x728a780] Task finished with error code: -22 (Invalid argument)
[vf#0:0 @ 0x728a780] Terminating thread with return code -22 (Invalid argument)
[vost#0:0/h264_v4l2m2m @ 0x7289040] Could not open encoder before EOF
[vost#0:0/h264_v4l2m2m @ 0x7289040] Task finished with error code: -22 (Invalid argument)
[vost#0:0/h264_v4l2m2m @ 0x7289040] Terminating thread with return code -22 (Invalid argument)
[out#0/null @ 0x7288540] Nothing was written into output file, because at least one of its streams received no packets.
frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A speed=N/A    
Conversion failed!

Input #0, lavfi, from 'nullsrc':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: wrapped_avframe, yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 25 tbn
[vost#0:0 @ 0x6b67040] Unknown encoder 'h264_omx'
[vost#0:0 @ 0x6b67040] Error selecting an encoder
Error opening output file -.
Error opening output files: Encoder not found

Befehl: -strict -2 -hide_banner -threads 5 -hwaccel auto -i "/home/martin/Videos/Test/Biathlon1.mov" -r 30000/1001 -c:v libx264 -b:v 5994k -profile:v high -map v:0 -c:a aac -ar 48k -b:a 256k -map a:0 -pix_fmt yuv420p -timecode "01:00:00;00" -sws_flags bicubic -metadata creation_time="2024-11-20T09:18:40.094683819Z" -y "/home/martin/Videos/Test/Biathlon1_H265.mp4"
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/martin/Videos/Test/Biathlon1.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    creation_time   : 2024-07-28T20:27:14.000000Z
    encoder         : Blackmagic Design DaVinci Resolve Studio
  Duration: 00:02:00.12, start: 0.000000, bitrate: 17562 kb/s
  Stream #0:0[0x1]: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/unknown, progressive), 1080x1920 [SAR 1:1 DAR 9:16], 16023 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
      Metadata:
        creation_time   : 2024-07-28T20:27:14.000000Z
        handler_name    : VideoHandler
        vendor_id       :     
        encoder         : H.264 NVIDIA
        timecode        : 01:00:00;00
  Stream #0:1[0x2]: Audio: pcm_s16le (lpcm / 0x6D63706C), 48000 Hz, stereo, s16, 1536 kb/s (default)
      Metadata:
        creation_time   : 2024-07-28T20:27:14.000000Z
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74) (default)
      Metadata:
        creation_time   : 2024-07-28T20:27:14.000000Z
        handler_name    : TimeCodeHandler
        timecode        : 01:00:00;00
 -strict -2 -v quiet -hide_banner -ss 0ms -i "/home/martin/Videos/Test/Biathlon1.mov" -filter_complex "[0:v]scale=248:440:sws_flags=bilinear:sws_dither=none[v];[0:a:0]showvolume=f=0:w=248:h=4:t=0:b=0:v=0:o=v:s=0:p=0.5[volume];[v][volume]overlay=W-w:H-h" -r 29.97 -c:v bmp -an -f image2pipe -

Befehl: -strict -2 -hide_banner -threads 5 -hwaccel auto -i "/home/martin/Videos/Test/Biathlon1.mov" -r 30000/1001 -c:v h264_nvenc -b_ref_mode 0 -b:v 5994k -profile:v high -map v:0 -c:a aac -ar 48k -b:a 256k -map a:0 -pix_fmt yuv420p -timecode "01:00:00;00" -sws_flags bicubic -metadata creation_time="2024-11-20T09:20:27.967264467Z" -y "/home/martin/Videos/Test/Biathlon1_H265.mp4"
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/martin/Videos/Test/Biathlon1.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    creation_time   : 2024-07-28T20:27:14.000000Z
    encoder         : Blackmagic Design DaVinci Resolve Studio
  Duration: 00:02:00.12, start: 0.000000, bitrate: 17562 kb/s
  Stream #0:0[0x1]: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/unknown, progressive), 1080x1920 [SAR 1:1 DAR 9:16], 16023 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
      Metadata:
        creation_time   : 2024-07-28T20:27:14.000000Z
        handler_name    : VideoHandler
        vendor_id       :     
        encoder         : H.264 NVIDIA
        timecode        : 01:00:00;00
  Stream #0:1[0x2]: Audio: pcm_s16le (lpcm / 0x6D63706C), 48000 Hz, stereo, s16, 1536 kb/s (default)
      Metadata:
        creation_time   : 2024-07-28T20:27:14.000000Z
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74) (default)
      Metadata:
        creation_time   : 2024-07-28T20:27:14.000000Z
        handler_name    : TimeCodeHandler
        timecode        : 01:00:00;00

Befehl: -strict -2 -hide_banner -threads 5 -hwaccel auto -i "/home/martin/Videos/Test/Biathlon1.mov" -r 30000/1001 -c:v h264_nvenc -b_ref_mode 0 -b:v 5994k -profile:v high -map v:0 -c:a aac -ar 48k -b:a 256k -map a:0 -pix_fmt yuv420p -timecode "01:00:00;00" -sws_flags bicubic -metadata creation_time="2024-11-20T09:20:37.704813455Z" -y "/home/martin/Videos/Test/Biathlon1_H265.mp4"
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/martin/Videos/Test/Biathlon1.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    creation_time   : 2024-07-28T20:27:14.000000Z
    encoder         : Blackmagic Design DaVinci Resolve Studio
  Duration: 00:02:00.12, start: 0.000000, bitrate: 17562 kb/s
  Stream #0:0[0x1]: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/unknown, progressive), 1080x1920 [SAR 1:1 DAR 9:16], 16023 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
      Metadata:
        creation_time   : 2024-07-28T20:27:14.000000Z
        handler_name    : VideoHandler
        vendor_id       :     
        encoder         : H.264 NVIDIA
        timecode        : 01:00:00;00
  Stream #0:1[0x2]: Audio: pcm_s16le (lpcm / 0x6D63706C), 48000 Hz, stereo, s16, 1536 kb/s (default)
      Metadata:
        creation_time   : 2024-07-28T20:27:14.000000Z
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74) (default)
      Metadata:
        creation_time   : 2024-07-28T20:27:14.000000Z
        handler_name    : TimeCodeHandler
        timecode        : 01:00:00;00

Befehl: -strict -2 -hide_banner -threads 5 -hwaccel none -i "/home/martin/Videos/Test/Biathlon1.mov" -r 30000/1001 -c:v h264_nvenc -b_ref_mode 0 -b:v 5994k -profile:v high -map v:0 -c:a aac -ar 48k -b:a 256k -map a:0 -pix_fmt yuv420p -timecode "01:00:00;00" -sws_flags bicubic -metadata creation_time="2024-11-20T09:20:47.054693460Z" -y "/home/martin/Videos/Test/Biathlon1_H265.mp4"
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/martin/Videos/Test/Biathlon1.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    creation_time   : 2024-07-28T20:27:14.000000Z
    encoder         : Blackmagic Design DaVinci Resolve Studio
  Duration: 00:02:00.12, start: 0.000000, bitrate: 17562 kb/s
  Stream #0:0[0x1]: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/unknown, progressive), 1080x1920 [SAR 1:1 DAR 9:16], 16023 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
      Metadata:
        creation_time   : 2024-07-28T20:27:14.000000Z
        handler_name    : VideoHandler
        vendor_id       :     
        encoder         : H.264 NVIDIA
        timecode        : 01:00:00;00
  Stream #0:1[0x2]: Audio: pcm_s16le (lpcm / 0x6D63706C), 48000 Hz, stereo, s16, 1536 kb/s (default)
      Metadata:
        creation_time   : 2024-07-28T20:27:14.000000Z
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74) (default)
      Metadata:
        creation_time   : 2024-07-28T20:27:14.000000Z
        handler_name    : TimeCodeHandler
        timecode        : 01:00:00;00
[out#0/mp4 @ 0x7621ec0] Codec AVOption gop_timecode (MPEG GOP Timecode in hh:mm:ss[:;.]ff format. Overrides timecode_frame_start.) 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 decoder which was not actually used for any stream.
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvenc))
  Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help

I will try to debug, maybe I can find some more information.

macb74 commented 6 days ago

The first one is my local one, which is working, the second one is the one you are delivering.

martin@ortler:~/workspace/shutter-encoder/out/production/Library$ ffmpeg
ffmpeg version N-117812-gbbb0fdedb7 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 13 (Ubuntu 13.2.0-23ubuntu4)
  configuration: --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared
  libavutil      59. 47.100 / 59. 47.100
  libavcodec     61. 24.100 / 61. 24.100
  libavformat    61.  9.100 / 61.  9.100
  libavdevice    61.  4.100 / 61.  4.100
  libavfilter    10.  6.101 / 10.  6.101
  libswscale      8.  9.101 /  8.  9.101
  libswresample   5.  4.100 /  5.  4.100
Universal media converter
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'

martin@ortler:~/workspace/shutter-encoder/out/production/Library$ ./ffmpeg 
ffmpeg version N-116529-geb3cc508d8 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
  configuration: --pkg-config-flags=--static --ld=g++ --extra-libs='-lpthread -lm -lz' --extra-ldexeflags=-static --enable-pic --disable-shared --disable-sdl2 --disable-ffplay --disable-ffprobe --enable-static --enable-gpl --enable-version3 --enable-fontconfig --enable-iconv --enable-libass --enable-libdav1d --enable-libfreetype --enable-libharfbuzz --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libsnappy --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libvvenc --enable-libzimg --enable-lzma --enable-zlib --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libxvid --enable-libgsm --enable-libsvtav1 --enable-libaom --enable-ffnvcodec --enable-cuvid --enable-nvenc --enable-nvdec --enable-vdpau --enable-amf
  libavutil      59. 31.100 / 59. 31.100
  libavcodec     61. 11.100 / 61. 11.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
Universal media converter
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'
martin@ortler:~/workspace/shutter-encoder/out/production/Library$ 

cuda-nvcc is missing in your build

macb74 commented 6 days ago

This is what I get, running the cmd with the ffmpeg version delivered by you: Result: Memory access error (memory dump written)

martin@ortler:~/workspace/shutter-encoder/out/production/Library$ ./ffmpeg  -hwaccel auto -i "/home/martin/Videos/Marktlauf2024_.mp4" -c:v libx264 -b:v 4800k -profile:v high -level 5.1 -map v:0 -c:a aac -ar 48k -b:a 256k -map a:0 -pix_fmt yuv420p -timecode "01:00:00:00" -sws_flags bicubic -metadata creation_time="2024-11-20T09:37:17.383315786Z" -y "/home/martin/Videos/Marktlauf2024__H265.mp4"
ffmpeg version N-116529-geb3cc508d8 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
  configuration: --pkg-config-flags=--static --ld=g++ --extra-libs='-lpthread -lm -lz' --extra-ldexeflags=-static --enable-pic --disable-shared --disable-sdl2 --disable-ffplay --disable-ffprobe --enable-static --enable-gpl --enable-version3 --enable-fontconfig --enable-iconv --enable-libass --enable-libdav1d --enable-libfreetype --enable-libharfbuzz --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libsnappy --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libvvenc --enable-libzimg --enable-lzma --enable-zlib --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libxvid --enable-libgsm --enable-libsvtav1 --enable-libaom --enable-ffnvcodec --enable-cuvid --enable-nvenc --enable-nvdec --enable-vdpau --enable-amf
  libavutil      59. 31.100 / 59. 31.100
  libavcodec     61. 11.100 / 61. 11.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/martin/Videos/Marktlauf2024_.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2024-10-28T07:30:03.000000Z
    encoder         : Lavf60.20.100
  Duration: 00:02:21.79, start: 0.000000, bitrate: 5233 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/unknown, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 4967 kb/s, 24 fps, 24 tbr, 12288 tbn (default)
      Metadata:
        creation_time   : 2024-10-28T07:30:03.000000Z
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc60.37.100 libx264
        timecode        : 01:00:00:00
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 260 kb/s (default)
      Metadata:
        creation_time   : 2024-10-28T07:30:03.000000Z
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74)
      Metadata:
        creation_time   : 2024-10-28T07:30:03.000000Z
        handler_name    : VideoHandler
        timecode        : 01:00:00:00
Speicherzugriffsfehler (Speicherabzug geschrieben)
martin@ortler:~/workspace/shutter-encoder/out/production/Library$ 
paulpacifico commented 4 days ago

I'm currently adding the custom FFmpeg text field for the next release ;-)

Paul.

macb74 commented 4 days ago

marvelous, thank you.