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

sergiogiogio at ovi.com sergiogiogio at ovi.com
Thu Jan 31 16:53:32 CET 2013


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
=========


More information about the ffmpeg-user mailing list