[FFmpeg-user] Failing to concatenate 2 mp4 fragments without re-encoding

Anatol anatol2002 at gmail.com
Fri Feb 1 05:39:43 CET 2013


For video only:
-Save the portions as ‘h264 raw’, without any muxing format
-Put the portions together by concatenating them together
Command lines:

ffmpeg -i input1.mp4 -vcodec copy -an -bsf:v h264_mp4toannexb output1.h264
ffmpeg -i input2.mp4 -vcodec copy -an -bsf:v h264_mp4toannexb output2.h264
cat output.h264 output1.h264 > output_merged.h264
ffmpeg -i output_merged.h264 -c:v copy -f mp4 output_merged.mp4

For audio u can use sox and then merge it all together

On Fri, Feb 1, 2013 at 6:31 AM, <sergiogiogio at ovi.com> wrote:

> <Carl Eugen Hoyos cehoyos at ag.or.at> writes:
> > <sergiogiogio <at> ovi.com> writes:
> >
> > > I am trying to concatenate 2 small mp4 fragments (H264 main, AAC)
> >
> > I suggest you try the new concat demuxer (that is different
> > from the concat protocol you have tested), find the
> > documentation here:
> > https://ffmpeg.org/ffmpeg-formats.html#concat
> Thanks, I tried the concat demuxer (-f concat -i concat.txt) but got the
> same error message in ffplay/ffprobe.
> >
> > Please do never post a part of the console output, always
> > post the complete, unedited console output (at least the
> > first 50 and the last 50 lines).
> >
> > Carl Eugen
>
> The first and last lines of console output are below:
> ====
> "%FFMPEG_DIR%\ffprobe.exe" -show_frames -show_streams
> 2parts.orig.mp4.ts.concat.ts.mp4.ts 2>&1 >
> 2parts.orig.mp4.ts.concat.ts.mp4.ts.debug.txt
> ffprobe version N-49448-gdc8dd2f Copyright (c) 2007-2013 the FFmpeg
> developers built on Jan 29 2013 17:50:41 with gcc 4.7.2 (GCC)
> configuration: --enable-gpl --enable-version3 --disable-w32threads
> --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r
> --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca
> --enable-libfreetype --enable-libgsm --enable-libmp3lame
> --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
> --enable-libopus --enable-librtmp --enable-libschroedinger
> --enable-libspeex --enable-libtheora --enable-libtwolame
> --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
> --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid
> --enable-zlib libavutil      52. 17.100 / 52. 17.100 libavcodec     54.
> 91.100 / 54. 91.100 libavformat    54. 61.104 / 54. 61.104 libavdevice
>  54.  3.102 / 54.  3.102 libavfilter     3. 34.101 /  3. 34.101 libswscale
>      2.  2.100 /  2.  2.100
>  libswresample   0. 17.102 / 0. 17.102 libpostproc    52.  2.100 / 52.
>  2.100
> [mpegts @ 002df8e0] max_analyze_duration 5000000 reached at 5000000
> microseconds
> Input #0, mpegts, from '2parts.orig.mp4.ts.concat.ts.mp4.ts': Duration:
> 00:03:43.69, start: 1.400000, bitrate: 758 kb/s Program 1 Metadata:
> service_name    : Service01 service_provider: FFmpeg Stream #0:0[0x100]:
> Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 640x360 [SAR 405:404
> DAR 180:101], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1[0x101](und):
> Audio: aac ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 81 kb/s
> [h264 @ 0343a860] top block unavailable for requested intra4x4 mode -1 at
> 0 0
> [h264 @ 0343a860] error while decoding MB 0 0, bytestream (18883)
> [h264 @ 0343a860] concealing 920 DC, 920 AC, 920 MV errors in I frame
> [h264 @ 03d2c360] [h264 @ 03d8b120] concealing 710 DC, 710 AC, 710 MV
> errors in P frame
> error while decoding MB 27 6, bytestream (-6)
> [h264 @ 03e34c80] [h264 @ 03e348a0] [h264 @ 03e35480] concealing 881 DC,
> 881 AC, 881 MV errors in P frame
> [h264 @ 03d8b120] error while decoding MB 32 8, bytestream (-7)
> error while decoding MB 31 16, bytestream (-7)
> [h264 @ 03e35480] [h264 @ 03df0060] concealing 702 DC, 702 AC, 702 MV
> errors in B frame
> concealing 298 DC, 298 AC, 298 MV errors in B frame
> [h264 @ 03439c80] [h264 @ 0343a860] [h264 @ 03e348a0] concealing 378 DC,
> 378 AC, 378 MV errors in B frame
> error while decoding MB 36 7, bytestream (-5)
> top block unavailable for requested intra mode at 5 0
> concealing 617 DC, 617 AC, 617 MV errors in B frame
> [h264 @ 03439c80] [h264 @ 0343a860] concealing 653 DC, 653 AC, 653 MV
> errors in B frame
> error while decoding MB 5 0, bytestream (4285)
> [h264 @ 0343a860] concealing 920 DC, 920 AC, 920 MV errors in P frame
> [h264 @ 03d2c360] error while decoding MB 25 21, bytestream (-7)
> [h264 @ 03d8b120] error while decoding MB 39 5, bytestream (-5)
> [h264 @ 03d2c360] concealing 104 DC, 104 AC, 104 MV errors in B frame
> [h264 @ 03d8b120] concealing 730 DC, 730 AC, 730 MV errors in B frame
> [h264 @ 03e344a0] [h264 @ 03e348a0] error while decoding MB 18 11,
> bytestream (-10)
> concealing 871 DC, 871 AC, 871 MV errors in P frame
> [h264 @ 03e34c80] [h264 @ 03e35480] [h264 @ 03e344a0] concealing 722 DC,
> 722 AC, 722 MV errors in B frame
> concealing 555 DC, 555 AC, 555 MV errors in B frame
> concealing 511 DC, 511 AC, 511 MV errors in B frame
> [h264 @ 03df0060] error while decoding MB 23 13, bytestream (-21)
> [h264 @ 03df0060] concealing 426 DC, 426 AC, 426 MV errors in B frame
> [h264 @ 03439c80] concealing 815 DC, 815 AC, 815 MV errors in P frame
> [h264 @ 0343a860] concealing 557 DC, 557 AC, 557 MV errors in B frame
> [h264 @ 03d2c360] concealing 378 DC, 378 AC, 378 MV errors in B frame
> [h264 @ 03d8b120] error while decoding MB 30 17, bytestream (-10)
> [h264 @ 03e344a0] top block unavailable for requested intra mode at 2 0
> [h264 @ 03d8b120] concealing 259 DC, 259 AC, 259 MV errors in B frame
> [h264 @ 03e344a0] error while decoding MB 2 0, bytestream (1391)
> [h264 @ 03e344a0] concealing 920 DC, 920 AC, 920 MV errors in P frame
> [h264 @ 03e348a0] [h264 @ 03e34c80] [h264 @ 03e35480] concealing 800 DC,
> 800 AC, 800 MV errors in B frame
> concealing 549 DC, 549 AC, 549 MV errors in B frame
> concealing 629 DC, 629 AC, 629 MV errors in B frame
> [h264 @ 03df0060] top block unavailable for requested intra4x4 mode -1 at
> 0 0
> [h264 @ 03df0060] error while decoding MB 0 0, bytestream (21880)
> [h264 @ 03df0060] concealing 920 DC, 920 AC, 920 MV errors in I frame
> [h264 @ 03439c80] concealing 839 DC, 839 AC, 839 MV errors in P frame
> [h264 @ 0343a860] concealing 864 DC, 864 AC, 864 MV errors in B frame
> [h264 @ 03d2c360] error while decoding MB 27 6, bytestream (-5)
> [h264 @ 03d8b120] top block unavailable for requested intra4x4 mode -1 at
> 11 0
> [h264 @ 03d2c360] concealing 702 DC, 702 AC, 702 MV errors in B frame
> [h264 @ 03d8b120] error while decoding MB 11 0, bytestream (4759)
> [h264 @ 03d8b120] [h264 @ 03e344a0] concealing 920 DC, 920 AC, 920 MV
> errors in P frame
> concealing 875 DC, 875 AC, 875 MV errors in B frame
> [h264 @ 03e348a0] error while decoding MB 35 9, bytestream (-6)
> [h264 @ 03e348a0] [h264 @ 03e34c80] concealing 574 DC, 574 AC, 574 MV
> errors in B frame
> error while decoding MB 23 2, bytestream (-16)
> [h264 @ 03e35480] [h264 @ 03e34c80] concealing 621 DC, 621 AC, 621 MV
> errors in P frame
> concealing 866 DC, 866 AC, 866 MV errors in B frame
> [h264 @ 03df0060] concealing 897 DC, 897 AC, 897 MV errors in B frame
> [h264 @ 03439c80] [h264 @ 0343a860] concealing 849 DC, 849 AC, 849 MV
> errors in B frame
> concealing 890 DC, 890 AC, 890 MV errors in B frame
> [h264 @ 03d2c360] concealing 879 DC, 879 AC, 879 MV errors in P frame
> [h264 @ 03d8b120] concealing 897 DC, 897 AC, 897 MV errors in B frame
> [h264 @ 03e344a0] error while decoding MB 1 7, bytestream (-6)
> [h264 @ 03e348a0] [h264 @ 03e344a0] error while decoding MB 7 2,
> bytestream (-6)
> concealing 688 DC, 688 AC, 688 MV errors in B frame
> [h264 @ 03e348a0] [h264 @ 03e34c80] [h264 @ 03e35480] concealing 882 DC,
> 882 AC, 882 MV errors in B frame
> concealing 644 DC, 644 AC, 644 MV errors in P frame
> concealing 819 DC, 819 AC, 819 MV errors in B frame
> [h264 @ 03df0060] error while decoding MB 13 5, bytestream (-12)
> [h264 @ 03df0060] concealing 756 DC, 756 AC, 756 MV errors in B frame
> [h264 @ 03439c80] concealing 897 DC, 897 AC, 897 MV errors in B frame
> [h264 @ 0343a860] [h264 @ 03d2c360] concealing 504 DC, 504 AC, 504 MV
> errors in P frame
> concealing 897 DC, 897 AC, 897 MV errors in B frame
> [h264 @ 03d8b120] error while decoding MB 37 5, bytestream (-5)
> [h264 @ 03d8b120] concealing 732 DC, 732 AC, 732 MV errors in B frame
> [h264 @ 03e344a0] concealing 897 DC, 897 AC, 897 MV errors in B frame
> [h264 @ 03e348a0] concealing 850 DC, 850 AC, 850 MV errors in P frame
> [h264 @ 03e34c80] concealing 770 DC, 770 AC, 770 MV errors in B frame
> [h264 @ 03e35480] error while decoding MB 25 2, bytestream (-7)
> [h264 @ 03e35480] concealing 864 DC, 864 AC, 864 MV errors in B frame
> ...
> [h264 @ 03f80060] concealing 485 DC, 485 AC, 485 MV errors in B frame
> [h264 @ 03949c80] concealing 653 DC, 653 AC, 653 MV errors in B frame
> [h264 @ 0394a860] concealing 695 DC, 695 AC, 695 MV errors in P frame
> [h264 @ 03ebc580] concealing 507 DC, 507 AC, 507 MV errors in B frame
> [h264 @ 03f1b560] concealing 645 DC, 645 AC, 645 MV errors in B frame
> [h264 @ 03fc4ca0] [h264 @ 03fc50a0] concealing 724 DC, 724 AC, 724 MV
> errors in B frame
> concealing 709 DC, 709 AC, 709 MV errors in P frame
> [h264 @ 03fc58c0] concealing 483 DC, 483 AC, 483 MV errors in B frame
> [h264 @ 03f60420] concealing 586 DC, 586 AC, 586 MV errors in B frame
> [h264 @ 03f80060] concealing 617 DC, 617 AC, 617 MV errors in B frame
> [h264 @ 03949c80] concealing 651 DC, 651 AC, 651 MV errors in P frame
> [h264 @ 0394a860] concealing 726 DC, 726 AC, 726 MV errors in B frame
> [h264 @ 03ebc580] concealing 682 DC, 682 AC, 682 MV errors in B frame
> [h264 @ 03f1b560] error while decoding MB 28 7, bytestream (-13)
> [h264 @ 03fc4ca0] concealing 374 DC, 374 AC, 374 MV errors in P frame
> [h264 @ 03f1b560] concealing 661 DC, 661 AC, 661 MV errors in B frame
> [h264 @ 03fc50a0] concealing 737 DC, 737 AC, 737 MV errors in B frame
> [h264 @ 03fc58c0] error while decoding MB 12 7, bytestream (-11)
> [h264 @ 03f60420] [h264 @ 03f80060] concealing 545 DC, 545 AC, 545 MV
> errors in B frame
> [h264 @ 03fc58c0] concealing 553 DC, 553 AC, 553 MV errors in P frame
> concealing 677 DC, 677 AC, 677 MV errors in B frame
> [h264 @ 03949c80] [h264 @ 0394a860] concealing 607 DC, 607 AC, 607 MV
> errors in B frame
> [h264 @ 03ebc580] error while decoding MB 20 7, bytestream (-18)
> concealing 716 DC, 716 AC, 716 MV errors in B frame
> [h264 @ 0394a860] concealing 669 DC, 669 AC, 669 MV errors in B frame
> [h264 @ 03f1b560] concealing 534 DC, 534 AC, 534 MV errors in P frame
> [h264 @ 03fc4ca0] error while decoding MB 35 8, bytestream (-7)
> [h264 @ 03fc4ca0] [h264 @ 03fc58c0] concealing 614 DC, 614 AC, 614 MV
> errors in B frame
> [h264 @ 03fc50a0] concealing 664 DC, 664 AC, 664 MV errors in B frame
> error while decoding MB 27 7, bytestream (-5)
> [h264 @ 03f60420] [h264 @ 03f80060] concealing 772 DC, 772 AC, 772 MV
> errors in P frame
> [h264 @ 03949c80] concealing 708 DC, 708 AC, 708 MV errors in B frame
> [h264 @ 03fc50a0] concealing 694 DC, 694 AC, 694 MV errors in B frame
> concealing 662 DC, 662 AC, 662 MV errors in B frame
> [h264 @ 0394a860] error while decoding MB 27 6, bytestream (-9)
> [h264 @ 0394a860] concealing 702 DC, 702 AC, 702 MV errors in B frame
> [h264 @ 03ebc580] concealing 495 DC, 495 AC, 495 MV errors in P frame
> [h264 @ 03f1b560] concealing 565 DC, 565 AC, 565 MV errors in B frame
> [h264 @ 03fc4ca0] concealing 667 DC, 667 AC, 667 MV errors in B frame
> [h264 @ 03fc50a0] error while decoding MB 2 7, bytestream (-9)
> [h264 @ 03fc58c0] concealing 407 DC, 407 AC, 407 MV errors in P frame
> [h264 @ 03f60420] [h264 @ 03fc50a0] top block unavailable for requested
> intra4x4 mode -1 at 0 0
> concealing 687 DC, 687 AC, 687 MV errors in B frame
> [h264 @ 03f60420] error while decoding MB 0 0, bytestream (16532)
> [h264 @ 03f60420] concealing 920 DC, 920 AC, 920 MV errors in I frame
> [h264 @ 03f80060] top block unavailable for requested intra mode at 26 0
> [h264 @ 03f80060] error while decoding MB 26 0, bytestream (1640)
> [h264 @ 03f80060] [h264 @ 03949c80] concealing 920 DC, 920 AC, 920 MV
> errors in P frame
> concealing 897 DC, 897 AC, 897 MV errors in B frame
> [h264 @ 0394a860] error while decoding MB 2 15, bytestream (-5)
> [h264 @ 0394a860] concealing 367 DC, 367 AC, 367 MV errors in B frame
>
> ====
>
>
>
>
> >________________________________
> > From: "sergiogiogio at ovi.com" <sergiogiogio at ovi.com>
> >To: "ffmpeg-user at ffmpeg.org" <ffmpeg-user at ffmpeg.org>
> >Sent: Thursday, January 31, 2013 11:53 PM
> >Subject: Failing to concatenate 2 mp4 fragments without re-encoding
> >
> >
> >Hello,
> >
> >
> >I am trying to concatenate 2 small mp4 fragments (H264 main, AAC) without
> re-encoding.
> >So far I have not succeeded in generating a "compatible" mp4 output file:
> my Sony Bravia TV renders video and audio of the first part correctly but
> fails to play the video of  the second part immediately after the "junction
> point", while audio continues normally.
> >After testing I discovered that I could make ffplay fail exactly in the
> same way as my TV by converting my mp4 output file to mpeg2 ts format.
> >
> >
> >Here are my steps (command lines and clip URLs below):
> >1- convert part1 and part2 from mp4 to mpeg2 ts with ffmpeg
> >2- concatenate part1 and part2 with ffmpeg
> >3 -run ffprobe or ffplay: no error
> >
> >4- convert output from mpeg2 ts to mp4
> >5- convert output from mp4 to mpeg2 ts
> >6- run ffprobe or ffplay: lots of errors (reproduced below)
> >
> >
> >Tests were carried out with
> >I have tried using MP4Box and TsRemuX with the same result (incompatible
> file).
> >I have also tried to demux the original mp4 files to  h264 and aac bit
> streams, concatenating the streams and remuxing the into mp4, with again
> the same results.
> >
> >
> >Thanks in advance for any help or suggestion.
> >sergiogiogio
> >
> >
> >
> >
> >1- Command lines:
> >Note: the fragments are from a french TV national news program (18MB in
> total)
> >========
> >SET FFMPEG_DIR=..\bin
> >SET CURL_DIR=..\bin
> >
> >
> >"%CURL_DIR%\curl.exe" "
> http://projects.developer.nokia.com/SingaporeBus/files/ffmpeg/part1.orig.mp4"
> -o "part1.orig.mp4"
> >"%CURL_DIR%\curl.exe" "
> http://projects.developer.nokia.com/SingaporeBus/files/ffmpeg/part2.orig.mp4"
> -o "part2.orig.mp4"
> >
> >
> >REM Convert part1 from MP4 to TS
> >"%FFMPEG_DIR%\ffmpeg.exe" -i part1.orig.mp4 -bsf h264_mp4toannexb -c copy
> -y part1.orig.mp4.ts
> >"%FFMPEG_DIR%\ffprobe.exe" -show_frames -show_streams part1.orig.mp4.ts >
> part1.orig.mp4.ts.debug.txt
> >
> >
> >REM Convert part2 from MP4 to TS
> >"%FFMPEG_DIR%\ffmpeg.exe" -i part2.orig.mp4 -bsf h264_mp4toannexb -c copy
> -y part2.orig.mp4.ts
> >"%FFMPEG_DIR%\ffprobe.exe" -show_frames -show_streams part2.orig.mp4.ts >
> part2.orig.mp4.ts.debug.txt
> >
> >
> >REM Concat part1 and part2 (TS) = (part1|part2)
> >"%FFMPEG_DIR%\ffmpeg.exe" -i "concat:part1.orig.mp4.ts|part2.orig.mp4.ts"
> -c copy -y 2parts.orig.mp4.ts.concat.ts
> >"%FFMPEG_DIR%\ffprobe.exe" -show_frames -show_streams
> 2parts.orig.mp4.ts.concat.ts > 2parts.orig.mp4.ts.concat.ts.debug.txt
> >
> >
> >REM Convert (part1|part2) from TS to mp4
> >"%FFMPEG_DIR%\ffmpeg.exe" -i 2parts.orig.mp4.ts.concat.ts -absf
> aac_adtstoasc -c copy -y 2parts.orig.mp4.ts.concat.ts.mp4
> >"%FFMPEG_DIR%\ffprobe.exe" -show_frames -show_streams
> 2parts.orig.mp4.ts.concat.ts.mp4 >
> 2parts.orig.mp4.ts.concat.ts.mp4.debug.txt
> >
> >
> >REM Convert (part1|part2) from mp4 to ts
> >"%FFMPEG_DIR%\ffmpeg.exe" -i 2parts.orig.mp4.ts.concat.ts.mp4 -bsf
> h264_mp4toannexb -c copy -y 2parts.orig.mp4.ts.concat.ts.mp4.ts
> >"%FFMPEG_DIR%\ffprobe.exe" -show_frames -show_streams
> 2parts.orig.mp4.ts.concat.ts.mp4.ts 2>&1 >
> 2parts.orig.mp4.ts.concat.ts.mp4.ts.debug.txt
> >=========
> >
> >
> >
> >2- Error output of ffprobe:
> >=========
> >
> >[h264 @ 0261d020] top block unavailable for requested intra4x4 mode -1 at
> 0 0
> >[h264 @ 0261d020] error while decoding MB 0 0, bytestream (18883)
> >[h264 @ 0261d020] concealing 920 DC, 920 AC, 920 MV errors in I frame
> >[h264 @ 028009a0] [h264 @ 0252a800] concealing 710 DC, 710 AC, 710 MV
> errors in P frame
> >error while decoding MB 29 6, bytestream (-10)
> >[h264 @ 0252a800] concealing 700 DC, 700 AC, 700 MV errors in B frame
> >[h264 @ 028009a0] error while decoding MB 34 8, bytestream (-5)
> >[h264 @ 0252a800] concealing 881 DC, 881 AC, 881 MV errors in P frame
> >[h264 @ 028009a0] [h264 @ 0261d020] concealing 615 DC, 615 AC, 615 MV
> errors in B frame
> >error while decoding MB 31 16, bytestream (-7)
> >[h264 @ 0261d020] concealing 298 DC, 298 AC, 298 MV errors in B frame
> >[h264 @ 028009a0] concealing 378 DC, 378 AC, 378 MV errors in B frame
> >[h264 @ 0252a800] error while decoding MB 36 7, bytestream (-7)
> >[h264 @ 0261d020] [h264 @ 0252a800] top block unavailable for requested
> intra mode at 5 0
> >concealing 653 DC, 653 AC, 653 MV errors in B frame
> >...
> >=========
> >
> >
> >
> >3- ffmpeg version
> >=========
> >ffmpeg version N-49448-gdc8dd2f Copyright (c) 2000-2013 the FFmpeg
> developers
> >  built on Jan 29 2013 17:50:41 with gcc 4.7.2 (GCC)
> >  configuration: --enable-gpl --enable-version3 --disable-w32threads
> --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r
> --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca
> --enable-libfreetype --enable-libgsm --enable-libmp3lame
> --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
> --enable-libopus --enable-librtmp --enable-libschroedinger
> --enable-libspeex --enable-libtheora --enable-libtwolame
> --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
> --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid
> --enable-zlib
> >  libavutil      52. 17.100 / 52. 17.100
> >  libavcodec     54. 91.100 / 54. 91.100
> >  libavformat    54. 61.104 / 54. 61.104
> >  libavdevice    54.  3.102 / 54.  3.102
> >  libavfilter     3. 34.101 /  3. 34.101
> >  libswscale      2.  2.100 /  2.  2.100
> >  libswresample   0. 17.102 /  0. 17.102
> >  libpostproc    52.  2.100 / 52.  2.100
> >=========
> >
> >
> >
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>


More information about the ffmpeg-user mailing list