如何用单条FFmpeg命令从视频列表生成MPEG DASH编码MP4
Absolutely doable! You can skip the tedious separate encoding + post-merging workflow entirely by combining FFmpeg's input concatenation tools with your existing encoding parameters in one command. Since your source videos share the same frame rate and resolution, here are two reliable approaches tailored to your needs:
1. Concat Demuxer (Recommended for Most Cases)
This method is cleaner and more efficient, especially if you have a long list of videos to process.
Step 1: Create an Input List File
Make a plain text file (e.g., input_videos.txt) and list each video path on a new line using this format:
file 'video_part1.mp4' file 'video_part2.mp4' file 'video_part3.mp4'
Use absolute paths if your videos are in different folders, or relative paths if they're in the same directory as your FFmpeg command.
Step 2: Run the Combined Command
Plug this list into your existing encoding pipeline with a few extra parameters:
ffmpeg -y -f concat -safe 0 -i input_videos.txt -c:a copy -c:v libx264 -x264opts 'keyint=48:min-keyint=48:no-scenecut' -r 24 -b:v 1500k -maxrate 1500k -bufsize 1000k -vf "scale=-1:816" out.mp4
-f concat: Tells FFmpeg to use the efficient concat demuxer for merging inputs.-safe 0: Allows using absolute file paths (omit this if you're only using relative paths).- The rest of the parameters match your original encoding command, ensuring the output meets your MPEG-DASH specifications.
2. Concat Filter (For Small Numbers of Videos)
If you don't want to create a text file, you can list all inputs directly in the command and use the concat filter:
ffmpeg -y -i video1.mp4 -i video2.mp4 -i video3.mp4 -filter_complex "[0:v][0:a][1:v][1:a][2:v][2:a]concat=n=3:v=1:a=1[v][a]" -map "[v]" -map "[a]" -c:v libx264 -x264opts 'keyint=48:min-keyint=48:no-scenecut' -r 24 -b:v 1500k -maxrate 1500k -bufsize 1000k -vf "scale=-1:816" -c:a copy out.mp4
n=3: Replace this number with the total count of input videos.[0:v][0:a][1:v][1:a]...: Orders each input's video and audio streams to maintain sync during merging.v=1:a=1: Specifies we want a single video and audio stream in the output.
Quick Notes
- If your source videos have incompatible audio encoding (e.g., not AAC), replace
-c:a copywith an audio encoding parameter like-c:a aac -b:a 128k. - The concat demuxer is faster for your workflow because it avoids unnecessary re-decoding of source streams where possible, though both methods will produce identical output quality since you're re-encoding the video anyway.
内容的提问来源于stack exchange,提问作者Massimo Vantaggio

