user10894: 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

user32537: I was going to comment on paulzag's comment, but I need 50 reputation (what a stupid system).
For me, the filter and demuxer weren't working at all, but I found out about "Concat protocol" on ffmpeg's site, which worked prefectly for me: https://trac.ffmpeg.org/wiki/Concatenate#protocol
I used the "intermediate files" method, which uses MPEG-2 TS files.
Previous to this, the video was freezing at the first insertion for about 3 seconds, and then playing the rest of the video at half FPS. I think it was due to the videos being encoded using different settings.
Now it perfectly combines both videos together with no issue.
From the site:

While the demuxer works at the stream level, the concat protocol works at the file level. Certain files (MPEG-2 transport streams, possibly others) can be concatenated. This is analogous to using cat on UNIX-like systems or copy on Windows.
Instructions
The following command concatenates three MPEG-2 TS files and concatenates them without re-encoding:
ffmpeg -i "concat:input1.ts|input2.ts|input3.ts" -c copy output.ts

Using intermediate files
If you have MP4 files, these could be losslessly concatenated by first transcoding them to MPEG-2 transport streams. With H.264 video and AAC audio, the following can be used:
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts 
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4

Using named pipes to avoid intermediate files
If you're using a system that supports named pipes, you can use those to avoid creating intermediate files. This sends stderr (to which ffmpeg sends all the written data) to /dev/null, to avoid cluttering up the command-line:
mkfifo temp1 temp2 
ffmpeg -y -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp1 2> /dev/null & \
ffmpeg -y -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp2 2> /dev/null & \
ffmpeg -f mpegts -i "concat:temp1|temp2" -c copy -bsf:a aac_adtstoasc output.mp4 

The additional -y switch is needed to force ffmpeg to write to existing files temp1 and temp2, which are the named pipes. Without the switch, the first two ffmpeg programs running in the background will not produce any output because they wait for interactive yes/no answers to the questions whether to overwrite existing files.
All MPEG codecs (MPEG-4 Part 10 / AVC, MPEG-4 Part 2, MPEG-2 Video, MPEG-1 Audio Layer II, MPEG-2 Audio Layer III (MP3), MPEG-4 Part III (AAC)) are supported in the MPEG-TS container format, although the commands above would require some alteration (e.g., the -bsf bitstream filters will have to be changed).


user11459: 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.

10894: <p>I have big videos with different types of properties and trying to collect some part of these videos by ffmpeg.</p>

<p>I use this command to cut specific parts:</p>

<p><code>scale video &gt;&gt; scale png &gt;&gt; pad scaled_video &gt;&gt; add icon to padded_scaled_video &gt;&gt; encode.</code></p>

<blockquote>
  <p>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";</p>
</blockquote>

<p>Which works perfectly.</p>

<p>and then try to merge these videos with this command:</p>

<blockquote>
  <p>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";</p>
</blockquote>

<p>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.</p>

<p>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?</p>

<p>This is <code>-report</code> log output:
<a href="https://drive.google.com/open?id=0B_kWzdnSIxuQY09QWWZGVTBPdHM" rel="nofollow">https://drive.google.com/open?id=0B_kWzdnSIxuQY09QWWZGVTBPdHM</a></p>
 32537: <p>I was going to comment on paulzag's comment, but I need 50 reputation (what a stupid system).</p>
<p>For me, the filter and demuxer weren't working at all, but I found out about &quot;Concat protocol&quot; on ffmpeg's site, which worked prefectly for me: <a href="https://trac.ffmpeg.org/wiki/Concatenate#protocol" rel="nofollow noreferrer">https://trac.ffmpeg.org/wiki/Concatenate#protocol</a></p>
<p>I used the &quot;intermediate files&quot; method, which uses MPEG-2 TS files.</p>
<p>Previous to this, the video was freezing at the first insertion for about 3 seconds, and then playing the rest of the video at half FPS. I think it was due to the videos being encoded using different settings.</p>
<p>Now it perfectly combines both videos together with no issue.</p>
<p>From the site:</p>
<blockquote>
<p>While the demuxer works at the stream level, the concat protocol works at the file level. Certain files (MPEG-2 transport streams, possibly others) can be concatenated. This is analogous to using <code>cat</code> on UNIX-like systems or <code>copy</code> on Windows.</p>
<p><strong>Instructions</strong></p>
<p>The following command concatenates three MPEG-2 TS files and concatenates them without re-encoding:</p>
<pre><code>ffmpeg -i &quot;concat:input1.ts|input2.ts|input3.ts&quot; -c copy output.ts
</code></pre>
<p><strong>Using intermediate files</strong></p>
<p>If you have MP4 files, these could be losslessly concatenated by first transcoding them to MPEG-2 transport streams. With H.264 video and AAC audio, the following can be used:</p>
<pre><code>ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts 
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i &quot;concat:intermediate1.ts|intermediate2.ts&quot; -c copy -bsf:a aac_adtstoasc output.mp4
</code></pre>
<p><strong>Using named pipes to avoid intermediate files</strong></p>
<p>If you're using a system that supports named pipes, you can use those to avoid creating intermediate files. This sends stderr (to which ffmpeg sends all the written data) to <code>/dev/null</code>, to avoid cluttering up the command-line:</p>
<pre><code>mkfifo temp1 temp2 
ffmpeg -y -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp1 2&gt; /dev/null &amp; \
ffmpeg -y -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp2 2&gt; /dev/null &amp; \
ffmpeg -f mpegts -i &quot;concat:temp1|temp2&quot; -c copy -bsf:a aac_adtstoasc output.mp4 
</code></pre>
<p>The additional <code>-y</code> switch is needed to force ffmpeg to write to existing files <code>temp1</code> and <code>temp2</code>, which are the named pipes. Without the switch, the first two ffmpeg programs running in the background will not produce any output because they wait for interactive yes/no answers to the questions whether to overwrite existing files.</p>
<p>All MPEG codecs (MPEG-4 Part 10 / AVC, MPEG-4 Part 2, MPEG-2 Video, MPEG-1 Audio Layer II, MPEG-2 Audio Layer III (MP3), MPEG-4 Part III (AAC)) are supported in the MPEG-TS container format, although the commands above would require some alteration (e.g., the <code>-bsf</code> bitstream filters will have to be changed).</p>
</blockquote>
 11459: <p>Glad you fixed your problem. For anyone else coming across the question...</p>

<p>The problem is that <code>concat demuxer</code> only works when multimedia streams are the same.</p>

<p>As described <a href="http://ffmpeg.org/ffmpeg-formats.html#concat-1" rel="nofollow">here</a>, all files must have the same streams (same codecs, same time base, etc.).</p>

<p>So you have to use a filter, forcing a re-encode. See <a href="https://www.ffmpeg.org/faq.html#How-can-I-concatenate-video-files_003f" rel="nofollow">this</a> reference.</p>
