I'm trying to generate video files that follow a "prototype" file as much as possible (frame rate, dimensions, container format, codecs, etc.) but show a black screen with silent audio. Here's one command line that works fine, and produces a 3-second-long file:
ffmpeg -f lavfi -i color=c=black:s=3840x2160:r=25/1 -c:v h264 -f lavfi -i anullsrc=cl=mono:r=48000 -c:a pcm_s16be -t 3 out.mov
Sometimes, the prototype file has codecs that ffmpeg can read but not write, like pcm_bluray
. So instead of trying to use the same codec as the prototype, I omit this parameter and let ffmpeg pick a default:
ffmpeg -f lavfi -i color=c=black:s=3840x2160:r=25/1 -c:v h264 -f lavfi -i anullsrc=cl=mono:r=48000 -t 3 out.mov
To my surprise, I get a file that's 3.022s long. What's interesting is that both the streams are 3.0s long, but container duration is longer:
{
"streams": [
{
"index": 0,
"codec_name": "h264",
"time_base": "1/12800",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 38400,
"duration": "3.000000",
"nb_frames": "75",
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "LC",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 144000,
"duration": "3.000000",
}
],
"format": {
"nb_streams": 2,
"nb_programs": 0,
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"format_long_name": "QuickTime / MOV",
"start_time": "0.000000",
"duration": "3.022000",
}
}
ffmpeg version 4.0.2-2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 8 (Ubuntu 8.2.0-7ubuntu1)