<div dir="ltr"><div class="gmail_extra">Hi guys,</div><div class="gmail_extra"><br></div><div class="gmail_extra">I've a problem joining CERTAIN mp4 files using the concatenation demuxer and copying the codec informations. This produce a result .mp4 that works perfectly, till the end of the first part is reached, and then a gray video (with audio working).</div><div class="gmail_extra"><br></div><div class="gmail_extra">I use libavformat/codec in my code, but I'm able to reproduce the very same result using ffmpeg stock tools, so I will complete the post with examples with those tools.</div><div class="gmail_extra"><br></div><div class="gmail_extra">[BRIEF]</div><div class="gmail_extra">I'd like to know if there is a way to detect mp4 files that are not compatibile with concat muxer since I found a workaround with an extra pass to fix the problem muxing to TS and then going back to MP4, but this needs twice the space, and I want to do it only if strictly necessary.</div><div class="gmail_extra"><br></div><div class="gmail_extra">[LONG]</div><div class="gmail_extra">The two files seems identical to me and have the same streams (and ids inside), ffprobe output:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/gabry/Downloads/171007_BrPA_Kidd_001.mp4':<br></div><div class="gmail_extra">  Metadata:</div><div class="gmail_extra">    major_brand     : M4V </div><div class="gmail_extra">    minor_version   : 1</div><div class="gmail_extra">    compatible_brands: M4V M4A mp42isom</div><div class="gmail_extra">    creation_time   : 2017-10-07 17:03:14</div><div class="gmail_extra">    description     : This video is about Untitled Project</div><div class="gmail_extra">    album_artist    : Sean Hanley</div><div class="gmail_extra">    artist          : Sean Hanley</div><div class="gmail_extra">    title           : 171007_BrPA_Kidd_001</div><div class="gmail_extra">  Duration: 00:50:59.68, start: 0.000000, bitrate: 7130 kb/s</div><div class="gmail_extra">    Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s (default)</div><div class="gmail_extra">    Metadata:</div><div class="gmail_extra">      creation_time   : 2017-10-07 17:03:14</div><div class="gmail_extra">      handler_name    : Core Media Audio</div><div class="gmail_extra">    Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 7000 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 50 tbc (default)</div><div class="gmail_extra">    Metadata:</div><div class="gmail_extra">      creation_time   : 2017-10-07 17:03:14</div><div class="gmail_extra">      handler_name    : Core Media Video</div><div class="gmail_extra">    Stream #0:2: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 72:72 DAR 16:9], 90k tbr, 90k tbn, 90k tbc</div><div class="gmail_extra"><br></div></div><div class="gmail_extra"><div class="gmail_extra">Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/gabry/Downloads/171007_BrPA_Kidd_002.mp4':</div><div class="gmail_extra">  Metadata:</div><div class="gmail_extra">    major_brand     : M4V </div><div class="gmail_extra">    minor_version   : 1</div><div class="gmail_extra">    compatible_brands: M4V M4A mp42isom</div><div class="gmail_extra">    creation_time   : 2017-10-07 17:21:03</div><div class="gmail_extra">    keywords        : My Movie 3</div><div class="gmail_extra">    album_artist    : Sean Hanley</div><div class="gmail_extra">    description     : This video is about 171007_BrPA_Kidd_002</div><div class="gmail_extra">    artist          : Sean Hanley</div><div class="gmail_extra">    title           : 171007_BrPA_Kidd_002</div><div class="gmail_extra">  Duration: 00:50:55.34, start: 0.000000, bitrate: 7138 kb/s</div><div class="gmail_extra">    Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 125 kb/s (default)</div><div class="gmail_extra">    Metadata:</div><div class="gmail_extra">      creation_time   : 2017-10-07 17:21:03</div><div class="gmail_extra">      handler_name    : Core Media Audio</div><div class="gmail_extra">    Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 7008 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 48k tbc (default)</div><div class="gmail_extra">    Metadata:</div><div class="gmail_extra">      creation_time   : 2017-10-07 17:21:03</div><div class="gmail_extra">      handler_name    : Core Media Video</div><div class="gmail_extra">    Stream #0:2: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 72:72 DAR 16:9], 90k tbr, 90k tbn, 90k tbc</div><div class="gmail_extra"><br></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">I thought the problem was in my code, but running ffmpeg (3.3.1) from the command line the result is the same, both using a simple files.txt with:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">file '171007_BrPA_Kidd_001.mp4'</div><div class="gmail_extra">file '171007_BrPA_Kidd_002.mp4'</div></div><div class="gmail_extra"><div><br></div><div>... or if I use a more complex specification with (I use unique streams since sometimes I get audio and video streams inverted in mp4 files, and I want to remove the MJPEG stream anyway):</div><div><br></div><div><div class="gmail_extra">file '171007_BrPA_Kidd_001.mp4'</div><div class="gmail_extra">stream</div><div class="gmail_extra">unique_stream_id 0x01</div><div class="gmail_extra"><div class="gmail_extra">stream</div><div class="gmail_extra">unique_stream_id 0x00</div></div><div class="gmail_extra">file '171007_BrPA_Kidd_002.mp4'</div></div><div class="gmail_extra"><br></div><div class="gmail_extra">The result of:</div><div class="gmail_extra"><br></div><div class="gmail_extra">ffmpeg -f concat -safe 0 -i test.txt -c copy out_NOT_WORKING.mp4<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">... is always a mp4 that works only in the first half.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I can anyway mux a correct mp4 without encoding anything doing this:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">ffmpeg -i 171007_BrPA_Kidd_002.mp4 -c copy -bsf:v h264_mp4toannexb 1.ts</div></div><div class="gmail_extra">ffmpeg -i 171007_BrPA_Kidd_002.mp4 -c copy -bsf:v h264_mp4toannexb 2.ts<br></div><div class="gmail_extra">ffmpeg -i concat:"1.ts|2.ts" -c copy -bsf:a aac_adtstoasc out_WORKING.mp4<br></div><div class="gmail_extra"><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div><b>Bye,</b></div></div><div><b> Gabry</b></div></div></div></div></div>
</div></div>