Black/silent video with specific duration with ffmpeg 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)
Specify a PCM codec. The default codec is AAC, which has a priming sample that format in ffprobe accounts for, but stream won't, since the demuxer will have discarded it before sending it to the decoder for analysis.

P.S. your syntax is wrong - it should be ffmpeg -f lavfi -i color=c=black:s=3840x2160:r=25/1 -f lavfi -i anullsrc=cl=mono:r=48000 -c:v h264 -c:a pcm_s16be -t 3 out.mov

Options before an input are applied to the input. You've gotten away with it because -c:v h264 sets the video decoder for the following input. However, since it is an audio-only input, the effect is inert. And the default codec for MOV happens to be H264, so the outcome is what you desired.