GithubHelp home page GithubHelp logo

davidbejarcaceres / ffmpeg-cuda-useful-commands Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1 KB

This project is intended to have some useful pre-defined command line commands to use with ffmpeg and CUDA

amd-cpu cuda ffmpeg ffmpeg-command video-encoder video-encoding

ffmpeg-cuda-useful-commands's Introduction

Custom commands for ffmpeg video conversion (CUDA):

Here we can find a set of commands to use in video conversion with ffmpeg and common configurations (resolution, bitrate, encoding, etc), some custom commands to transcode using cuda and AMD AMF

Codecs (CUDA):

Decoders for cuda:

1. h264_cuvid -> Nvidia CUVID H264 decoder (codec h264)
2. hevc_cuvid -> Nvidia CUVID HEVC decoder (codec hevc)
3. av1_cuvid -> Nvidia CUVID AV1 decoder (codec av1)
4. mjpeg_cuvid -> Nvidia CUVID MJPEG decoder (codec mjpeg)
5. mpeg1_cuvid -> Nvidia CUVID MPEG1VIDEO decoder (codec mpeg1video)
6. mpeg2_cuvid -> Nvidia CUVID MPEG2VIDEO decoder (codec mpeg2video)
7. mpeg4_cuvid -> Nvidia CUVID MPEG4 decoder (codec mpeg4)
8. vc1_cuvid -> Nvidia CUVID VC1 decoder (codec vc1)
9. vp8_cuvid -> Nvidia CUVID VP8 decoder (codec vp8)
10. vp9_cuvid -> Nvidia CUVID VP9 decoder (codec vp9)

Encoders for cuda:

1. h264_nvenc
2. hevc_nvenc
3. libsvtav1 -> AV1 (SVT-AV1 Encoder and Decoder)

Encoder for AMD (up to 2x faster compared to libx264 | libx265):

1. h264_amf
2. hevc_amf

Encoder for AV1:

1. libsvtav1 -> AV1 (SVT-AV1 Encoder and Decoder) No GPU support

#########################################################################

Most used ffmpeg flags:

  1. -c:v -> To inidicate codec of the video track
  2. -c:a copy -> To copy audio from source
  3. -vf scale=1280:720 -> To resize the video to new resolution
  4. -vf scale_cuda=1280:720 -> To resize with CUDA
  5. -hwaccel cuvid -> Inidicates Hardware acceleration to use (cuda | cuvid)
  6. -hwaccel_output_format cuvid -> Inidicates acceleration mode to use (cuda | cuvid)
  7. -noautorotate -> Prevents from auto rotate, sometimes ffmpeg rotate portrait videos

#########################################################################

Examples:

Only CPU:

This uses encoder h264 for video, and copy audio from metadata, uses -noautorotate in case is a portrait video

ffmpeg -noautorotate -i input.mp4 -c:a copy -c:v h264 output.mp4

Encode CPU AMD:

This uses AMD custom encoder, only for AMD CPUs, can accelerate up to 2x:

ffmpeg -noautorotate -i input.mp4 -c:a copy -c:v h264 output.mp4

Resize video CPU:

Resize video with CPU and filter -vf scale=1280:720:

ffmpeg -noautorotate -i input.mp4 -vf scale=1280:720 -c:a copy -c:v h264 output.mp4

Encode using GPU CUDA:

Transcode using CUDA, with encoder h264_nvenc:

ffmpeg -noautorotate -y -vsync 0 -hwaccel cuvid -hwaccel_output_format cuvid -i input.mp4 -c:a copy -c:v h264_nvenc output.mp4 

Transcode using GPU CUDA (max performance):

Transcode using CUDA, using decoder cuda hevc_cuvid for input stream video, can accelerate 25% the process:

ffmpeg -noautorotate -y -vsync 0 -hwaccel cuvid -hwaccel_output_format cuvid -c:v hevc_cuvid -i input.mp4 -c:a copy -c:v hevc_nvenc output.mp4

Resize video on GPU CUDA:

Resize video using CUDA, using filter -vf scale_cuda=1280:720 for input stream video:

ffmpeg -y -vsync 0 -hwaccel cuvid -c:v hevc_cuvid -i input.mp4 -vf scale_cuda=1280:720 -c:a copy -c:v hevc_nvenc  output.mp4

Decode with GPU CUDA + Encode CPU (AV1):

Decode using CUDA and encode using CPU for the new AV1 codec, decoder cuda hevc_cuvid, and libsvtav1 for encoding (more about AV1):

ffmpeg -y -vsync 0 -noautorotate -y -vsync 0 -hwaccel cuvid -hwaccel_output_format cuvid -c:v hevc_cuvid  -i input.mp4 -c:a copy -c:v libsvtav1 output.mp4

ffmpeg-cuda-useful-commands's People

Contributors

davidbejarcaceres avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.