| 3 | | There is the null muxer, use it like this: |
| | 3 | There are several ways to utilize "null" in `ffmpeg`. This can be useful for testing and benchmarking purposes, creating inputs, and filtering. For example: |
| | 4 | |
| | 5 | * testing decoding speed |
| | 6 | * testing encoding speed without the cost of disk writes |
| | 7 | * testing speed of input from a device |
| | 8 | * creating a blank video "canvas" for filtering |
| | 9 | * making silent audio |
| | 10 | |
| | 11 | ---- |
| | 12 | |
| | 13 | = Null muxer = |
| | 14 | |
| | 15 | The [https://ffmpeg.org/ffmpeg-formats.html#null null muxer] does not generate any output file. It is mainly useful for testing or benchmarking purposes. |
| | 16 | |
| | 17 | == Decoding & demuxing == |
| | 18 | |
| | 19 | To test decoding and demuxing: |
| | 20 | |
| 29 | | in the FFMpeg output it specifies (in this case) |
| | 52 | *nix users can also use the `time` command. |
| | 53 | |
| | 54 | {{{ |
| | 55 | $ time ffmpeg -i input output |
| | 56 | ... |
| | 57 | real 0m3.365s |
| | 58 | user 0m8.533s |
| | 59 | sys 0m0.541s |
| | 60 | }}} |
| | 61 | |
| | 62 | |
| | 63 | ---- |
| | 64 | |
| | 65 | |
| | 66 | = Filters = |
| | 67 | |
| | 68 | There is a variety of null filters: |
| | 69 | |
| | 70 | == anull == |
| | 71 | |
| | 72 | The [https://ffmpeg.org/ffmpeg-filters.html#anull anull] audio filter will pass the audio source unchanged to the output. |
| | 73 | |
| | 74 | == null == |
| | 75 | |
| | 76 | The [https://ffmpeg.org/ffmpeg-filters.html#null null] video filter will pass the video source unchanged to the output. |
| | 77 | |
| | 78 | == anullsrc == |
| | 79 | |
| | 80 | The [https://ffmpeg.org/ffmpeg-filters.html#anullsrc anullsrc] audio source filter can create silent audio. For example, to add a silent audio stream to a video: |
| | 81 | |
| | 82 | {{{ |
| | 83 | ffmpeg -i input.mp4 -f lavfi -i anullsrc -c:v copy -c:a aac -shortest output.mp4 |
| | 84 | }}} |
| | 85 | |
| | 86 | anullsrc can be particularly useful with the [https://ffmpeg.org/ffmpeg-filters.html#concat concat filter] because all inputs to the filter must have the same number of streams. Example where `input0` and `input1` have video and stereo audio with 48000 Hz sample rate, and `input2` has video only: |
| | 87 | |
| | 88 | {{{ |
| | 89 | ffmpeg -i input0 -i input1 -i input2 -t 1 -f lavfi -i anullsrc=r=48000:cl=stereo -filter_complex \ |
| | 90 | "[0:v][0:a][1:v][1:a][2:v][3:a]concat=n=3:v=1:a=1[v][a]" \ |
| | 91 | -map "[v]" -map "[a]" output |
| | 92 | }}} |
| | 93 | |
| | 94 | Note the `-t 1` input option: you do not need to match this duration value with the associated video stream. It only needs to be shorter as the concat filter will pad the remaining duration with additional silence. |
| | 95 | |
| | 96 | == nullsrc == |
| | 97 | |
| | 98 | The [https://ffmpeg.org/ffmpeg-filters.html#nullsrc nullsrc] video source filter returns unprocessed video frames. It can be used as a foundation for other filters where the input is ignored. Example to generate noise in the luminance plane with the [https://ffmpeg.org/ffmpeg-filters.html#geq geq] filter: |
| | 99 | |
| | 100 | {{{ |
| | 101 | ffmpeg -f lavfi -i nullsrc=s=256x256:d=5 -vf "geq=random(1)*255:128:128" output |
| | 102 | }}} |
| | 103 | |
| | 104 | == anullsink == |
| | 105 | |
| | 106 | The [https://ffmpeg.org/ffmpeg-filters.html#anullsink anullsink] audio sink with do absolutely nothing with the input audio. |
| | 107 | |
| | 108 | == nullsink == |
| | 109 | |
| | 110 | The [https://ffmpeg.org/ffmpeg-filters.html#nullsink nullsink] video sink will do absolutely nothing with the input video. `ffmpeg` is "greedy" and will grab whatever stream it can find, so if your [https://ffmpeg.org/ffmpeg-filters.html#Filtergraph-syntax filtergraph] does not "output" anything it will just re-encode the inputs and ignore the filter. Example: |
| | 111 | |
| | 112 | {{{ |
| | 113 | ffmpeg -i input -filter_complex "[0:v]split[a][b];[a]nullsink" -map "[b]" output.mkv |
| | 114 | }}} |
| | 115 | |
| | 116 | In this case the `ffmpeg` output specifies: |
| | 117 | |