liveMp4Arguments function
The ffmpeg arguments that turn the recorder's input into an .mp4 at
output: H.264 at a steady 60 fps, which editors and browsers play, with
the chapters metadata file when there is one.
The video lasts exactly length, the time Metro recorded for. The iOS
Simulator only writes a frame when the screen changes, and can give its
last frame any length, so the last frame is held and then cut there.
Implementation
List<String> liveMp4Arguments(
String input,
String output, {
required Duration length,
String? chapters,
}) => [
'-y',
'-v',
'error',
'-i',
input,
if (chapters != null) ...['-i', chapters],
'-map',
'0:v:0',
'-map',
'0:a?',
if (chapters != null) ...['-map_metadata', '1', '-map_chapters', '1'],
'-vf',
'${_holdLastFrame(length)},fps=60,scale=trunc(iw/2)*2:trunc(ih/2)*2',
'-c:v',
'libx264',
'-preset',
'veryfast',
'-crf',
'20',
'-pix_fmt',
'yuv420p',
'-c:a',
'aac',
'-movflags',
'+faststart',
'-t',
_seconds(length),
output,
];