# [FFmpeg] 建立多個輸出 ## 說明 若需要將來源轉換成兩個或多個輸出,不需要使用多組命令進行多次工作,只需要一組命令讓 ffmpeg 工作一次便可以完成多檔案輸出。 ## 各別使用不同的參數設定 規則: ```text ffmpeg [OPTIONS] -i INPUT [OPTIONS] outfile1 [OPTIONS] outfile2 ... [OPTIONS] outfileN ``` 輸出獨立的視訊與音訊檔: ```powershell ffmpeg -i input.mkv -map 0:v:0 -c copy video_only.mkv -map 0:a:0 -c copy audio_only.mka ``` 輸出三種解析度: ```powershell ffmpeg -i input.mkv -filter:v scale=1920:-8 -c:v libx264 -c:a aac output1.mp4 -filter:v scale=1280:-8 -c:v libx264 -c:a aac output2.mp4 -filter:v scale=640:-8 -c:v libx264 -c:a aac output3.mp4 ``` 擷取出三個指定片段: ```powershell ffmpeg -i input.mkv -ss 00:02:30 -to 00:03:10 -c:v libx264 -c:a aac cut1.mp4 -ss 00:12:00 -to 00:11:15 -c:v libx264 -c:a aac cut2.mp4 -ss 00:20:10 -to 00:20:50 -c:v libx264 -c:a aac cut3.mp4 ``` ## 每個輸出使用相同的篩選器組 規則: ```text ffmpeg [OPTIONS] -i INPUT -filter_complex "FILTERCHAIN,split=N[out1]...[outN]" -map "[out1]" [OPTIONS] outfile1 ... -map "[outN]" [OPTIONS] outfileN ``` 例: 輸入為 1920x800 分別輸出三種解析度且皆以黑邊填補到 16:9: ```powershell ffmpeg -i input_1920x800.mkv -t 5 -filter_complex "[0:v]pad='h=ih+280:y=140',split=3[out1][out2][out3]" -map "[out1]" -s 1920x1080 -c:v libx264 -c:a aac output_fhd.mp4 -map "[out2]" -s 1280x720 -c:v libx264 -c:a aac output_hd.mp4 -map "[out3]" -s 640x360 -c:v libx264 -c:a aac output_sd.mp4 ``` ## 每個輸出使用不同的篩選器組 規則: ```text ffmpeg [OPTIONS] -i INPUT -filter_complex "[in] FILTERCHAIN [out1];...;[in] FILTERCHAIN [outN]" -map "[out1]" [OPTIONS] outfile1 ... -map "[outN]" [OPTIONS] outfileN ``` 例: 輸入為 1920x800 分別輸出三種解析度且皆以黑邊填補到 16:9: ```powershell ffmpeg -i input_1920x800.mkv -filter_complex "[0:v]pad='iw:ih+280:0:140',split=3[out1][out2][out3];[out1]scale=1920:-8[out1];[out2]scale=1280:-8[out2];[out3]scale=640:-8[out3]" -map "[out1]" -c:v libx264 -c:a aac output_fhd.mp4 -map "[out2]" -c:v libx264 -c:a aac output_hd.mp4 -map "[out3]" -c:v libx264 -c:a aac output_sd.mp4 ``` ## 重複輸出 規則: ```text ffmpeg [OPTIONS] -i INPUT [OPTIONS] -f MUXER - | ffmpeg -f mpegts -i - -c copy outfile1 outfile2 ``` 直播同時在本機建立備份: ```powershell ffmpeg -i input.mkv -c:v libx264 -c:a aac -f mpegts - | ffmpeg -f mpegts -i - -c copy -f mpegts udp://1.2.3.4:5678 -c copy -f mpegts local.ts ``` ###### tags: `ffmpeg`
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.