You may add .global_args('-report')
for testing the correctness of an FFmpeg command line.
The -report
argument generates a log file with a name like ffmpeg-20210715-000009.log
.
One of the first text lines in the log file is the FFmpeg command line with arguments.
There are good ffmpeg-python examples here and here. You may also read the reference (it's not long).
You may use "special option names" as documented:
Arguments with special names such as -qscale:v (variable bitrate), -b:v (constant bitrate), etc. can be specified as a keyword-args dictionary as follows:
...
.output('out.mp4', **{'qscale:v': 3})
...
You can use the following command (using "special names"):
(
ffmpeg
.input('0.mp4')
.output('out.mkv', **{'c:v': 'libx265'}, preset='fast', crf=28, **{'tag:v': 'hvc1'}, **{'c:a': 'aac'}, **{'bitexact': None}, map_metadata='-1')
.global_args('-report')
.run()
)
In the reported log file the command line is:
ffmpeg -i 0.mp4 -bitexact -c:a aac -c:v libx265 -crf 28 -map_metadata -1 -preset fast -tag:v hvc1 out.mkv -report
It's the same as your posted command line except of the order of the output arguments.
For using less "special names", you may replace the special names with equivalent names:
- Replace:
c:v
with vcodec
- Replace:
c:a
with acodec
- Replace
tag:v
with vtag
There is probably a replacement for **{'bitexact': None}
, but I can't find it.
The updated code is:
(
ffmpeg
.input('0.mp4')
.output('out.mkv', vcodec='libx265', preset='fast', crf=28, vtag='hvc1', acodec='aac', **{'bitexact': None}, map_metadata='-1')
.global_args('-report')
.run()
)