I have big videos with different types of properties and trying to collect some part of these videos by ffmpeg.

I use this command to cut specific parts:

scale video >> scale png >> pad scaled_video >> add icon to padded_scaled_video >> encode.

ffmpeg.StartInfo.Arguments = @"/c ffmpeg.exe -i " + VideoIn + " -i " + imageIn + " -filter_complex \"[0:v] scale='if(gt(a,6/4),480,-2)':'if(gt(a,6/4),-2,320)' [scaledv], [1:v] scale=iw*.5:ih*.5 [scaledicon], [scaledv] pad=480:320:(ow-iw)/2:(oh-ih)/2:black [scaledpaddedv], [scaledpaddedv][scaledicon] overlay=25:25,setsar=1:1 [finalv]\" -map \"[finalv]\" -map 0:a" + " -ss " + startCut.ToString() + " -c:v libx264 -preset slow -crf 20 -c:a aac -t " + duration.ToString() + " " + VideoOut + " -y -report";

Which works perfectly.

and then try to merge these videos with this command:

ffmpeg.StartInfo.Arguments = "/c ffmpeg.exe -f concat -safe 0 -i \"" + concatTextDirectory + "\" -c copy -vf \"subtitles=\\'" + videoInSrt + "\\':force_style='FontName=DejaVu Serif,FontSize=26'\" -c:v libx264 -preset slow -crf 20 -c:a aac " + videoOut + " -y -report";

Which again works ok if cutted video parts are from the same type of video, and if they aren't there will be no video and only audio or jittery video on non-similar video parts. The first cutted video part is dominant on other parts.

Question is most of the time video parts are not from the same video type and output is not playable. How could I cut video parts to be similar in properties to work without problem on concatenation part?

This is -report log output: https://drive.google.com/open?id=0B_kWzdnSIxuQY09QWWZGVTBPdHM


Glad you fixed your problem. For anyone else coming across the question...

The problem is that concat demuxer only works when multimedia streams are the same.

As described here, all files must have the same streams (same codecs, same time base, etc.).

So you have to use a filter, forcing a re-encode. See this reference.


End up using filters as this answer guides >> https://video.stackexchange.com/a/15479/10894

ffmpeg.StartInfo.Arguments = "/c ffmpeg.exe -i C:\\Users\\mtst\\Desktop\\Clips\\h\\a1.mp4 -i C:\\Users\\mtst\\Desktop\\Clips\\h\\a2.mp4 -i C:\\Users\\mtst\\Desktop\\Clips\\h\\a3.mp4 -filter_complex \"[0:v]setpts=PTS-STARTPTS[v0]; [0:a]asetpts=PTS-STARTPTS[a0]; [1:v]setpts=PTS-STARTPTS[v1]; [1:a]asetpts=PTS-STARTPTS[a1]; [2:v]setpts=PTS-STARTPTS[v2]; [2:a]asetpts=PTS-STARTPTS[a2]; [v0][a0][v1][a1][v2][a2]concat=n=3:v=1:a=1[v][a]\" -map \"[v]\" -map \"[a]\" -c:v libx264 -preset slow -crf 20 -c:a aac " + videoOut + " -y -report";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.