You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何拼接不同分辨率的视频?FFmpeg设置DAR后仍报错

Fixing FFmpeg Video Concatenation Error Despite Setting DAR to 16:9

Hey there! Adding setdar=16/9 is a solid first step to align aspect ratios, but FFmpeg's concat filter has stricter requirements than just matching display aspect ratio. Let's break down the common issues and fix your command.

Why Your Current Command Fails

The concat filter requires both videos to have identical video resolution, pixel format, frame rate, and audio parameters (sampling rate, channel count, etc.). Even if DAR matches, mismatches in any of these will throw an error.

Step 1: Check Your Video/Audio Parameters First

Run this command to get detailed specs for both videos:

ffmpeg -i /var/www/html/GetVideo/reklam/muzikli1.mp4 -i /var/www/html/GetVideo/tempvideo/sample.mp4

Look for these key values to compare:

  • Video: Resolution (e.g., 1920x1080), Frame rate, Pixel format (e.g., yuv420p)
  • Audio: Sample rate (e.g., 44100 Hz), Channels (e.g., stereo)

Step 2: Unified Command to Match All Parameters

Use this revised command to standardize every required parameter before concatenation. Replace the resolution/fps/audio values with what you found in Step 1:

ffmpeg -i /var/www/html/GetVideo/reklam/muzikli1.mp4 -i /var/www/html/GetVideo/tempvideo/sample.mp4 -filter_complex \
"[0:v]setdar=16/9,scale=1920:1080,fps=30,format=yuv420p[v0]; \
 [1:v]setdar=16/9,scale=1920:1080,fps=30,format=yuv420p[v1]; \
 [0:a]aformat=sample_rates=44100:channel_layouts=stereo[a0]; \
 [1:a]aformat=sample_rates=44100:channel_layouts=stereo[a1]; \
 [v0][a0][v1][a1]concat=n=2:v=1:a=1[v][a]" \
-map "[v]" -map "[a]" -c:v libx264 -c:a aac /var/www/html/GetVideo/reklam/out.mp4

Let's break down what each part does:

  • scale=1920:1080: Forces both videos to the same pixel resolution (adjust to match your source videos)
  • fps=30: Unifies frame rate (use the frame rate from your source videos)
  • format=yuv420p: Sets a universally compatible pixel format
  • aformat: Matches audio sampling rate and channel layout
  • -c:v libx264 -c:a aac: Ensures the output uses widely supported encoders

Step 3: If You Still Get Errors

If the command above doesn't work, try these checks:

  • Verify that both videos have no corrupted frames (use ffmpeg -v error -i input.mp4 -f null - to scan for errors)
  • If one video has variable frame rate (VFR), the fps=30 filter in the command will convert it to constant frame rate, which fixes most VFR-related concat issues

内容的提问来源于stack exchange,提问作者mcan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:56:16