Video

Video #

Downsample video bitrate to reduce file size #

What bitrate does this video have? (something like 1200Kb.

ffmpeg -i 2.mp4

Reduce to half of original bitrate:

ffmpeg -i 2.mp4 -t 10 -b 600k 2-out.mp4

GPU acceleration #

Run with nvidia-container:

 docker run --gpus all --rm \
    -it --entrypoint='bash' -v $(pwd):/tmp \
    jrottenberg/ffmpeg:4.1-nvidia \
    -ex /tmp/script.sh

script:

# audio and yuv conversion is done in CPU while the rest in GPU
ffmpeg \
  -hwaccel cuvid -c:v h264_cuvid \
  -i /tmp/input.mp4 \
  -preset:v slow \
  -vf "hwdownload,format=nv12,format=yuv420p,hwupload_cuda,scale_npp=854:480" \
  -g 30 \
  -bf 3 \
  -level:v 4.0 \
  -profile:v high \
  -vsync cfr \
  -strict -2 \
  -codec:a aac \
  -max_muxing_queue_size 1024 \
  -ac 2 \
  -f mp4 \
  -c:v h264_nvenc \
  /tmp/output.mp4
Calendar Last modified: March 28, 2020