1

I have this script which I am working on to encode a video into smaller file size:

echo off
set arg1=%1
set _filename=%~n1
set _extension=%~x1
shift
ffmpeg -i %arg1% -c:v h264_amf -crf 18 -preset slow -c:a aac -b:a 128k -movflags +faststart -vf scale=-2:480,format=yuv420p %_filename%.480P%_extension%

It accepts one argument which is the video file and outputs a new file.

Testing with a video file size of 815,050 KB the output was even bigger 1,554,650 KB specifically.

I'm using h264_amf for the reason I am encoding on a machine with AMD GPU on Windows.

My goal here is to convert a ton of videos to about 500MB (or lower if the input size is lower than 500MB) each regardless of the quality since it will be played in a AI-enhancing video player so quality of the output is not important.

What's the correct ffmpeg parameters to achieve this?

1 Answer 1

2

h264_amf does not support -crf or -preset. If you want a specific output file size with this encoder then use -rc cbr and set the appropriate bitrate with -b:v.

Example for 1000 second input with approximate 500 MB output:

(500 MB * 8000) = 4000000 kb / 1000 seconds - 128kb audio bitrate - ~1% muxing overhead = -b:v 3832k

Simple example command:

ffmpeg -i input -c:v h264_amf -rc cbr -b:v 3832k -c:a aac -b:a 128k output.mp4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .