| | 314 | |
| | 315 | ---- |
| | 316 | |
| | 317 | = Merged and mapped audio channels = |
| | 318 | |
| | 319 | This is born from screencasting, where you might want to record an interview over teleconference and still be able to isolate the audio streams to better deal with background noise later in post-processing. |
| | 320 | |
| | 321 | This example outputs a video with three audio options: the merged speaker+microphone streams, the speaker stream alone, and the microphone stream alone. |
| | 322 | |
| | 323 | x11grab provides stream 0, and is video only. |
| | 324 | |
| | 325 | stream 1 is the pulse "audio monitor", or what the speakers are playing. |
| | 326 | |
| | 327 | stream 2 is the pulseaudio default audio input device, meant to be a microphone, and in this case, stereo. |
| | 328 | |
| | 329 | "[a]" is the generated stream from merging stream 1 and stream 2, using amerge and then pan to retain stereo channels instead of 4.0 channels as seen above in "2 × stereo → stereo". |
| | 330 | |
| | 331 | These streams are then mapped in the order desired. |
| | 332 | |
| | 333 | |
| | 334 | |
| | 335 | {{{ |
| | 336 | #for "-f pulse -i 0", 0 is the pulseaudio id |
| | 337 | #of the audio that is going to the speakers |
| | 338 | #as determined from "pacmd list-sources" |
| | 339 | ffmpeg -video_size 1920x1080 -framerate 60 \ |
| | 340 | -f x11grab -i :0.0 \ |
| | 341 | -f pulse -i 0 \ |
| | 342 | -f pulse -i default \ |
| | 343 | -filter_complex "[1:a][2:a] amerge=inputs=2,pan=stereo|c0<c0+c2|c1<c1+c3[a]" \ |
| | 344 | -map 0 \ |
| | 345 | -map "[a]" \ |
| | 346 | -map 1 \ |
| | 347 | -map 2 \ |
| | 348 | -c:v libx264 -crf 17 -preset ultrafast \ |
| | 349 | output_filename.mkv |
| | 350 | |
| | 351 | }}} |