| | 31 | |
| | 32 | === Two-Pass ===#twopass |
| | 33 | |
| | 34 | In order to create more efficient encodes when a particular target bitrate should be reached, you should choose two-pass encoding. For two-pass, you need to run `ffmpeg` twice, with almost the same settings, except for: |
| | 35 | |
| | 36 | * In pass 1 and 2, use the `-pass 1` and `-pass 2` options, respectively. |
| | 37 | * In pass 1, output to a null file descriptor, not an actual file. (This will generate a logfile that ffmpeg needs for the second pass.) |
| | 38 | * In pass 1, you need to specify an output format (with `-f`) that matches the output format you will use in pass 2. |
| | 39 | * In pass 1, specify the audio codec used in pass 2; in many cases, `-an` in pass 1 will not work. |
| | 40 | |
| | 41 | {{{ |
| | 42 | ffmpeg -i input.mp4 -c:v libaom-av1 -strict -2 -b:v 2M -pass 1 -f matroska /dev/null && \ |
| | 43 | ffmpeg -i input.mp4 -c:v libaom-av1 -strict -2 -b:v 2M -pass 2 output.mkv |
| | 44 | }}} |
| | 45 | |
| | 46 | {{{ |
| | 47 | #!div style="border: 1px solid #e5e5c7; margin: 1em; background-color: #ffd;" |
| | 48 | '''Note:''' Windows users should use `NUL` instead of `/dev/null` and `^` instead of `\`. |
| | 49 | }}} |