FFmpeg - concat videos with different start times in filter-complex

Viewed 557

To compile a final video from multiple audio and video files with different start times, I got to the below command so far:

ffmpeg -i audio_1.flv -i audio_2.flv -i audio_3.flv -i audio_4.flv -i audio_5.flv -i video_1.flv -i video_2.flv -i video_3.flv -i video_4.flv -filter_complex \
"[0]adelay=9761[audio0];[1]adelay=183387[audio1];[2]adelay=694634[audio2];[3]adelay=740306[audio3];[4]adelay=775587[audio4];[audio0][audio1][audio2][audio3][audio4]amix=5[audios];\
[5]setpts=PTS-STARTPTS+30.236/TB[video0];[6]setpts=PTS-STARTPTS+201.314/TB[video1];[7]setpts=PTS-STARTPTS+702.615/TB[video2];[8]setpts=PTS-STARTPTS+921.682/TB[video3];[video0][video1][video2][video3]concat=n=4[videos]" -map [videos] -map [audios] -c:v h264 output.mp4

Apparently, the audio part would be compiled correctly with this section:

[0]adelay=9761[audio0];[1]adelay=183387[audio1];[2]adelay=694634[audio2];[3]adelay=740306[audio3];[4]adelay=775587[audio4];[audio0][audio1][audio2][audio3][audio4]amix=5[audios]

But for the video part, with this filter in the above command:

[5]setpts=PTS-STARTPTS+30.236/TB[video0];[6]setpts=PTS-STARTPTS+201.314/TB[video1];[7]setpts=PTS-STARTPTS+702.615/TB[video2];[8]setpts=PTS-STARTPTS+921.682/TB[video3];[video0][video1][video2][video3]concat=n=4[videos]

The final video isn't correct and has about triple times more length than all video segments accumulated. I tried overlay to combine videos with different start times, but it only works for 2 inputs, now for 3 or more input videos trying concat, but I got the More than 1000 frames duplicated message. I used -vsync 2 to remove this message, But the video still got too long.

0 Answers
Related