anullsrc

doc

https://ffmpeg.org/ffmpeg-filters.html#anullsrc

Imagine you created a video from a image like this:

#! /bin/sh
ffmpeg -y -i /c/Windows/Web/Wallpaper/Nature/img1.jpg -filter_complex "
[0:v]loop=-1:size=2,trim=0:10,
scale=-1:1080,
pad=1920:1080:'(ow-iw)/2':0,
scale=1280:-1,
setsar=1,
setpts=PTS-STARTPTS,
format=yuv420p" 1.mp4 2>/dev/null

Of course, this video has no audio stream:

[me@host: ~]$ ffprobe -hide_banner 1.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 105 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 101 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler

This fact can be problematic if you want to concatenate videos. Assuming that you have a video with audio stream:

[me@host: ~]$ ffprobe -hide_banner 2.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
  Duration: 00:02:18.59, start: 0.000000, bitrate: 605 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 470 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

And if you want to concatinate like this:

[me@host: ~]$ # 1.mp4 (no audio) + 2.mp4 (has audio)
[me@host: ~]$ echo -e "file '1.mp4'\nfile '2.mp4'" > flist1
[me@host: ~]$ ffmpeg -y -f concat -safe 0 -i flist1 c1.mp4
[me@host: ~]$ # 2.mp4 (has audio) + 1.mp4 (no audio)
[me@host: ~]$ echo -e "file '2.mp4'\nfile '1.mp4'" > flist2
[me@host: ~]$ ffmpeg -y -f concat -safe 0 -i flist2 c2.mp4

In both cases ffmpeg does it without complaint, but what you might expect is probably the latter only:

[me@host: ~]$ ffprobe -hide_banner c1.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'c1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
  Duration: 00:02:28.52, start: 0.000000, bitrate: 438 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 436 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
[me@host: ~]$ ffprobe -hide_banner c2.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'c2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
  Duration: 00:02:28.60, start: 0.000000, bitrate: 562 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 436 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

The same problem with approaches other than “-f concat”:

[me@host: ~]$ ffmpeg -hide_banner -y -filter_complex "
> movie=1.mp4:streams=dv+da[v1][a1];
> movie=2.mp4:streams=dv+da[v2][a2];
> [v1][a1][v2][a2]concat=2" c3.mp4
[Parsed_movie_0 @ 00000000004b25e0] No audio stream with index '-1' found
[AVFilterGraph @ 00000000004b1c80] Error initializing filter 'movie' with args '1.mp4:streams=dv+da'
Error initializing complex filters.
Invalid argument
[me@host: ~]$ ffmpeg -hide_banner -y -filter_complex "
> movie=1.mp4:streams=dv[v1][a1];
> movie=2.mp4:streams=dv+da[v2][a2];
> [v1][a1][v2][a2]concat=2" c3.mp4
[AVFilterGraph @ 0000000000531ce0] No output pad can be associated to link label 'a1'.
Error initializing complex filters.
Invalid argument

In short, you need a way to create a silent audio stream.

If you want to add a silent audio stream when creating a video, for example:

[me@host: ~]$ ffmpeg -y -i /c/Windows/Web/Wallpaper/Nature/img1.jpg -filter_complex "
> [0:v]loop=-1:size=2,trim=0:10,
> scale=-1:1080,
> pad=1920:1080:'(ow-iw)/2':0,
> scale=1280:-1,
> setsar=1,
> setpts=PTS-STARTPTS,
> format=yuv420p;
> anullsrc=r=48000:cl=stereo
> ,atrim=0:10,asetpts=PTS-STARTPTS
> " 1a1.mp4
   ...
[me@host: ~]$ ffprobe -hide_banner 1a1.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1a1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
  Duration: 00:00:10.02, start: 0.000000, bitrate: 111 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 101 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[me@host: ~]$ # you can also use "aevalsrc" to generate silence audio stream.
[me@host: ~]$ ffmpeg -y -i /c/Windows/Web/Wallpaper/Nature/img1.jpg -filter_complex "
> [0:v]loop=-1:size=2,trim=0:10,
> scale=-1:1080,
> pad=1920:1080:'(ow-iw)/2':0,
> scale=1280:-1,
> setsar=1,
> setpts=PTS-STARTPTS,
> format=yuv420p;
> aevalsrc='0|0':s=48000:d=10:c=stereo
> " 1a2.mp4
   ...
[me@host: ~]$ ffprobe -hide_banner 1a2.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1a2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
  Duration: 00:00:10.02, start: 0.000000, bitrate: 111 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 101 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

Or, if you want to generate it in a filter graph that uses the “concat” filter, for example:

[me@host: ~]$ ffmpeg -hide_banner -y -filter_complex "
> movie=1.mp4:streams=dv[v1];
> aevalsrc='0|0':s=48000:d=10:c=stereo[a1];
> movie=2.mp4:streams=dv+da[v2][a2];
> [v1][a1][v2][a2]concat=2:a=1:v=1" c3a.mp4
   ...
[me@host: ~]$ ffprobe -hide_banner c3a.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'c3a.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
  Duration: 00:02:28.59, start: 0.000000, bitrate: 562 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 436 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 120 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
see also

making silence audio stream