VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Hi all,

    First time here, so nice to meet you all
    Seems like you are having an awesome community, happy to find this forum.


    Regarding my question:

    I'm building a small software that merge images into a video using FFMPEG.
    Using this command ({injected parameters}):

    Code:
    ffmpeg -r {newFPS} -f image2 -s {_resolution} -start_number {totalImagesMerged + 1} -i \"{_outputAllFramesPath}{_outputAllFramesFilePattern}\" -vframes {chunkFramesCount} -vcodec libx264 -crf 25 -pix_fmt yuv420p \"{_outputAllVideoChunksPath}Chunk_{chunkNumber}.mp4\"
    I've manage to do so, but it's super slow 🐌 with my CPU.

    I would like to take advantage of my GPU (RTX 3080) capabilities to do so in order to get a better performance 🐅 regarding compute time.

    I'm using windows and get some problems following this guide on how to compile FFMPEG with the right Nvidia flags, and recently encounter this Reddit post about using Nvidia flag with the pre compiled version.

    Flags like:
    Code:
    hevc_nvenc , -hwaccel cuda, -hwaccel_output_format cuda
    I tried to use some of them in my command above but failed, I'm not sure I'm using them as expected.

    How can I tweak the command above to use my GPU? Can I do it without recompiling FFMPEG?

    I'll appreciate any help
    Quote Quote  
  2. Can I do it without recompiling FFMPEG?
    On Windows, most prebuild ffmpeg version nowadays support hwaccel&co. If you are on Windows you could also use https://github.com/m-ab-s/media-autobuild_suite to compile your own ffmpeg version.
    No clue how it is with the default builds that come with most Linux distributions or MacOS. If your ffmpeg version isn't build with nvenc support, you can't use it.

    If you want to use nvenc instead of libx264 here's an example call, where I tried to adjust your call:
    Code:
    ffmpeg -y -noautorotate -nostdin -hwaccel cuda -hwaccel_output_format cuda -threads 1 -r {newFPS} -f image2 -s {_resolution} -start_number {totalImagesMerged + 1} -i \"{_outputAllFramesPath}{_outputAllFramesFilePattern}\" -vframes {chunkFramesCount} -an -sn -vf zscale=rangein=tv:range=tv -pix_fmt yuv420p -vsync 0 -vcodec hevc_nvenc -profile:v 1 -level 0 -tier main -cq 18.00 -b:v 0k -2pass 0 -qmin 0 -qmax 51 -surfaces 32 -nonref_p 1 -strict_gop 1 \"{_outputAllVideoChunksPath}Chunk_{chunkNumber}.mp4\"
    But no clue, whether nvenc can decode the images you try to open.

    Here's also an example where I convert a 10bit AVC source to 10bit HEVC
    Code:
    ffmpeg -y -noautorotate -nostdin -hwaccel cuda -hwaccel_output_format cuda -threads 1 -i "G:\TestClips&Co\files\10bit Test.mkv" -map 0:0 -an -sn -vf zscale=rangein=tv:range=tv -pix_fmt yuv420p10le -strict -1 -vsync 0 -vcodec hevc_nvenc -profile:v 1 -level 0 -tier main -cq 18.00 -b:v 0k -2pass 0 -qmin 0 -qmax 51 -surfaces 32 -nonref_p 1 -strict_gop 1 "E:\Output\10bit Testmp4"
    Maybe this helps.


    Cu Selur
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  3. Thanks Cu Selur,

    When i tried to run :

    Code:
    ffmpeg -y -noautorotate -nostdin -hwaccel cuda -hwaccel_output_format cuda -threads 1 -r {newFPS} -f image2 -s {_resolution} -start_number {totalImagesMerged + 1} -i \"{_outputAllFramesPath}{_outputAllFramesFilePattern}\" -vframes {chunkFramesCount} -an -sn -vf zscale=rangein=tv:range=tv -pix_fmt yuv420p -vsync 0 -vcodec hevc_nvenc -profile:v 1 -level 0 -tier main -cq 18.00 -b:v 0k -2pass 0 -qmin 0 -qmax 51 -surfaces 32 -nonref_p 1 -strict_gop 1 \"{_outputAllVideoChunksPath}Chunk_{chunkNumber}.mp4\"
    I got the following error:


    Code:
    br, 30 tbn
    Stream mapping:
      Stream #0:0 -> #0:0 (mjpeg (native) -> hevc (hevc_nvenc))
    Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scale_0'
    Error reinitializing filters!
    Failed to inject frame into filter network: Function not implemented
    Error while processing the decoded data for stream #0:0
    Conversion failed!
    Any thoughts?
    Quote Quote  
  4. Any thoughts?
    1. post the complete output of ffmpeg, as it should show way more about the input and the targeted output,.. Maybe also add '-loglevel debug' to see where the issue occurs exactly. (I suspect the problem is with using zscale)
    2. remove "-vf zscale=rangein=tv:range=tv" and see if it works.
    You should also read up on vui signaling and properly signal color matrix&co in the output.
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  5. Thanks for the input,
    I finally got it working

    Just realized that my params order was wrong,
    + I've added bitrate and got an amazing results 🤩🤩 using this command:

    Code:
    ffmpeg -r 30 -f image2 -s 4000x2000 -start_number 1 -i "D:\AllFrames\out-%d.jpg" -vframes 119 -vcodec h264_nvenc -preset slow -b:v 100M -pix_fmt yuv420p "D:\Output\Chunk_1.mp4"
    Thanks for the help!
    Quote Quote  
  6. Okay, you are then not using NVDec for decoding and only NVEnc for encoding, but I guess there probably won't be much difference in speed anyway.

    Cu Selur
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  7. well I need them both
    But in this specific scenario yep, encoding it is

    Thanks for the help man
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!