<p>Specify a PCM codec. The default codec is AAC, which has a <a href="https://stackoverflow.com/a/42415886">priming sample</a> 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>

<p>P.S. your syntax is wrong - it should be <code>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</code></p>

<p>Options before an input are applied to the input. You've gotten away with it because <code>-c:v h264</code> 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.</p>

CC BY-SA 4.0
2019-04-15T13:05:56.530Z
Ouch. Thank you for pointing out the argument-order problem.
iter
CC BY-SA 4.0
2019-04-15T13:49:20.050Z
So if I play the file out, it will still play for 3.0s, correct? So if I want an accurate duration for a file with AAC streams, do I need to sum up the durations and start times of individual streams instead of relying on the container?
iter
CC BY-SA 4.0
2019-04-15T14:22:16.757Z
Which file? The one with AAC or PCM?
Gyan
CC BY-SA 4.0
2019-04-15T14:35:05.007Z
MOV with AAC. With PCM, all durations agree, so there's no question.
iter
CC BY-SA 4.0
2019-04-15T14:46:55.787Z
If your player's decoder knows to skip the priming sample, then 3.0s else 3.022s
Gyan
CC BY-SA 4.0
2019-04-15T14:50:38.717Z
Huh. So with MOV I can use PCM and avoid the ambiguity. But with other containers, like MP4, I don't think they accept PCM. Is there a way to avoid the ambiguity there?
iter
CC BY-SA 4.0
2019-04-15T15:39:36.227Z
Output to MOV with PCM and use mp4box to remux.
Gyan
CC BY-SA 4.0
2024-12-11T19:11:02.180Z
If you want to concatenate, use this to use the same tbn, fps is not enough: https://superuser.com/q/1555225/ `-video_track_timescale 30000`.
Gringo Suave
CC BY-SA 4.0
2019-04-15T04:46:28.970Z
2019-04-15T04:46:28.970Z
Gyan
<p>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:</p>

<pre><code>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
</code></pre>

<p>Sometimes, the prototype file has codecs that ffmpeg can read but not write, like <code>pcm_bluray</code>. So instead of trying to use the same codec as the prototype, I omit this parameter and let ffmpeg pick a default:</p>

<pre><code>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
</code></pre>

<p>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:</p>

<pre><code>{
    "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",
    }
}
</code></pre>

<pre><code>ffmpeg version 4.0.2-2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.2.0-7ubuntu1)
</code></pre>

CC BY-SA 4.0
2024-04-07T08:44:05.727Z
see also [Create muted video and black screen video with FFmpeg](https://stackoverflow.com/questions/46366150/create-muted-video-and-black-screen-video-with-ffmpeg)
milahu
<ffmpeg>
Black/silent video with specific duration with ffmpeg
iter
# Black/silent video with specific duration with ffmpeg

(Asked by: username_0 on 2019-04-15)

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)

**Tags:** ffmpeg

> **Comments:**
> **username_1**: see also [Create muted video and black screen video with FFmpeg](https://stackoverflow.com/questions/46366150/create-muted-video-and-black-screen-video-with-ffmpeg)  

---

## 1 answers

### Answer by username_2 on 2019-04-15. Score: 4 | Accepted answer

Specify a PCM codec. The default codec is AAC, which has a [priming sample](https://stackoverflow.com/a/42415886) 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.

> **Comments:**
> **username_0**: Ouch. Thank you for pointing out the argument-order problem.  
> **username_0**: So if I play the file out, it will still play for 3.0s, correct? So if I want an accurate duration for a file with AAC streams, do I need to sum up the durations and start times of individual streams instead of relying on the container?  
> **username_2**: Which file? The one with AAC or PCM?  
> **username_0**: MOV with AAC. With PCM, all durations agree, so there's no question.  
> **username_2**: If your player's decoder knows to skip the priming sample, then 3.0s else 3.022s  
> **username_0**: Huh. So with MOV I can use PCM and avoid the ambiguity. But with other containers, like MP4, I don't think they accept PCM. Is there a way to avoid the ambiguity there?  
> **username_2**: Output to MOV with PCM and use mp4box to remux.  
> **username_3**: If you want to concatenate, use this to use the same tbn, fps is not enough: https://superuser.com/q/1555225/ `-video_track_timescale 30000`.  

---

