[FFmpeg-user] Use segment muxer and concat: protocol

Acer Yang yangacer at gmail.com
Sun Feb 12 06:28:23 CET 2012


Hi, everyone.

I try to segment a mp4 video into several fixed duration segments via
command as follow:

./ffmpeg -i input.mp4 -c copy -map 0 -f segment -segment_time 20 test%d.m4v

Output of ffmpeg is

ffmpeg version N-37771-gfd0b8d5 Copyright (c) 2000-2012 the FFmpeg
developers
  built on Feb 12 2012 00:29:57 with gcc 4.2.1 20070719  [FreeBSD]
  configuration: --enable-muxer=webm --enable-muxer=mp4 --enable-muxer=flv
--enable-muxer=h264 --enable-muxer=segment --enable-muxer=m4v
--enable-demuxer=flv --enable-demuxer=h264 --enable-demuxer=m4v
--enable-protocol=concat --enable-protocol=file --enable-protocol=pipe
--disable-ffplay
  libavutil      51. 39.100 / 51. 39.100
  libavcodec     54.  1.100 / 54.  1.100
  libavformat    54.  0.100 / 54.  0.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 62.100 /  2. 62.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
[h264 @ 0x28b3c400] concealing 786 DC, 786 AC, 786 MV errors
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2011-11-15 02:01:31
  Duration: 00:03:58.17, start: 0.000000, bitrate: 563 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x1080, 4301 kb/s, 29.97 fps, 29.97 tbr, 60k tbn, 59.94 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo,
s16, 151 kb/s
    Metadata:
      creation_time   : 2011-11-15 02:01:32
      handler_name    :
Output #0, segment, to 'test%d.m4v':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2011-11-15 02:01:31
    encoder         : Lavf54.0.100
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1920x1080,
q=2-31, 4301 kb/s, 29.97 fps, 30k tbn, 29.97 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, 151
kb/s
    Metadata:
      creation_time   : 2011-11-15 02:01:32
      handler_name    :
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
Truncating packet of size 19021 to 1920
Truncating packet of size 1308 to 1
frame=  977 fps=  0 q=-1.0 Lsize=       0kB time=00:00:32.59 bitrate=
0.0kbits/s
video:15699kB audio:609kB global headers:0kB muxing overhead -100.000000%


The ffmpeg splits the mp4 into test0.m4v and test1.m4v. Each segment can be
played in flash player correctly.
Then I try to merge/join these segments via command as follow:

./ffmpeg -i concat:"test0.m4v|test1.m4v" -c copy merge.m4v

// ...
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x28b0c200] multiple edit list entries, a/v
desync might occur, patch welcome
    Last message repeated 1 times
[h264 @ 0x28b39400] concealing 786 DC, 786 AC, 786 MV errors
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x28b0c200] max_analyze_duration 5000000 reached
at 5005118
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x28b0c200] decoding for stream 2 failed
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x28b0c200] Could not find codec parameters
(Video: h264 (avc1 / 0x31637661), 5084 kb/s)
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x28b0c200] decoding for stream 3 failed
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'concat:test0.m4v|test1.m4v':
  Metadata:
    compatible_brands: isomiso2avc1
    major_brand     : M4V
    minor_version   : 512
    encoder         : Lavf54.0.100
  Duration: 00:00:11.61, start: 0.000000, bitrate: 11527 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x1080, 3331 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo,
s16, 152 kb/s
    Metadata:
      handler_name    :
    Stream #0:2(und): Video: h264 (avc1 / 0x31637661), 5084 kb/s, 29.97
fps, 30k tbr, 30k tbn, 60k tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:3(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo,
s16, 151 kb/s
    Metadata:
      handler_name    :
File 'merge.m4v' already exists. Overwrite ? [y/N] y
Output #0, ipod, to 'merge.m4v':
  Metadata:
    compatible_brands: isomiso2avc1
    major_brand     : M4V
    minor_version   : 512
    encoder         : Lavf54.0.100
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1920x1080,
q=2-31, 3331 kb/s, 29.97 fps, 30k tbn, 30k tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, 152
kb/s
    Metadata:
      handler_name    :
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  635 fps=  0 q=-1.0 Lsize=    9030kB time=00:00:21.15
bitrate=3496.6kbits/s
video:8617kB audio:394kB global headers:0kB muxing overhead 0.209243%

However, the result video 'merge.m4v' only contains 'test0.m4v', i.e. the
first video appears in the concat: protocol.

Is there any workaround to solve this problem?

Thank you in advance.

--Acer


More information about the ffmpeg-user mailing list