[FFmpeg-user] How to split and then concatenate a video file?

Žygimantas Bruzgys un1x0nly at gmail.com
Thu Feb 21 11:34:53 CET 2013


On Wed, Feb 20, 2013 at 5:41 PM, Stefano Sabatini <stefasab at gmail.com> wrote:
> On date Wednesday 2013-02-20 15:17:28 +0100, Žygimantas Bruzgys wrote:
>> zybru at hp-6530b-bs:~/Desktop$ ffmpeg -i small.mp4 -f segment -vcodec
>> h264 -acodec mp3 -segment_time 2 -map 0 -reset_timestamps 0
>> out%03d.mp4
>
> What about using -reset_timestamps 1?

Ah, sorry. My mistake. Changing it to 1, did not save the situation.
Here is the output:

zybru at hp-6530b-bs:~/Desktop$ ffmpeg -i small.mp4 -f segment -vcodec
h264 -acodec mp3 -segment_time 2 -map 0 -reset_timestamps 1
out%03d.mp4
ffmpeg version N-50129-g951d39f Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb 20 2013 14:47:49 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --enable-gpl --enable-libfaac --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libtheora --enable-libvorbis --enable-libx264
--enable-nonfree --enable-version3 --enable-x11grab
--disable-stripping --enable-debug=3 --extra-cflags=-gstabs+
--disable-optimizations
  libavutil      52. 17.102 / 52. 17.102
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.100 / 54. 63.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 38.103 /  3. 38.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'small.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf54.61.100
  Duration: 00:01:00.00, start: 0.000000, bitrate: 1361 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x818 [SAR 1:1 DAR 960:409], 1239 kb/s, 24 fps, 24 tbr, 16k tbn, 48
tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 128 kb/s
    Metadata:
      handler_name    : SoundHandler
[libx264 @ 0x351df80] using SAR=1/1
[libx264 @ 0x351df80] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.1 Cache64
[libx264 @ 0x351df80] profile High, level 4.0
[libx264 @ 0x351df80] 264 - core 120 r2151 a3f4407 - H.264/MPEG-4 AVC
codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html -
options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7
psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1
8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2
threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250
keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
aq=1:1.00
Output #0, segment, to 'out%03d.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf54.63.100
    Stream #0:0(und): Video: h264, yuv420p, 1920x818 [SAR 1:1 DAR
960:409], q=-1--1, 90k tbn, 24 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3, 44100 Hz, stereo, fltp
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
  Stream #0:1 -> #0:1 (aac -> libmp3lame)
Press [q] to stop, [?] for help
frame= 1440 fps=8.8 q=28.0 Lsize=N/A time=00:01:00.00 bitrate=N/A
dup=16 drop=0
video:11561kB audio:938kB subtitle:0 global headers:0kB muxing
overhead -100.000172%
[libx264 @ 0x351df80] frame I:16    Avg QP:15.08  size: 37096
[libx264 @ 0x351df80] frame P:1016  Avg QP:20.03  size:  9881
[libx264 @ 0x351df80] frame B:408   Avg QP:23.28  size:  2954
[libx264 @ 0x351df80] consecutive B-frames: 59.2%  5.7%  9.8% 25.3%
[libx264 @ 0x351df80] mb I  I16..4: 42.5% 47.1% 10.4%
[libx264 @ 0x351df80] mb P  I16..4:  7.7% 10.0%  0.3%  P16..4: 23.7%
4.5%  1.2%  0.0%  0.0%    skip:52.5%
[libx264 @ 0x351df80] mb B  I16..4:  0.7%  0.7%  0.0%  B16..8: 26.8%
1.1%  0.1%  direct: 0.4%  skip:70.3%  L0:51.2% L1:47.9% BI: 0.9%
[libx264 @ 0x351df80] 8x8 transform intra:54.6% inter:86.7%
[libx264 @ 0x351df80] coded y,uvDC,uvAC intra: 22.8% 29.1% 2.1% inter:
4.7% 6.6% 0.0%
[libx264 @ 0x351df80] i16 v,h,dc,p: 32% 30% 16% 22%
[libx264 @ 0x351df80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 22% 34%  3%
3%  3%  4%  3%  3%
[libx264 @ 0x351df80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 21% 19%  5%
6%  6%  5%  4%  3%
[libx264 @ 0x351df80] i8c dc,h,v,p: 72% 14% 13%  2%
[libx264 @ 0x351df80] Weighted P-Frames: Y:0.4% UV:0.2%
[libx264 @ 0x351df80] ref P L0: 78.4%  8.7%  9.7%  3.2%  0.0%
[libx264 @ 0x351df80] ref B L0: 90.6%  8.1%  1.2%
[libx264 @ 0x351df80] ref B L1: 95.0%  5.0%
[libx264 @ 0x351df80] kb/s:1578.34



zybru at hp-6530b-bs:~/Desktop$ head -n 2 concat.lst; tail -n 2 concat.lst
file 'out000.mp4'
file 'out001.mp4'
file 'out012.mp4'
file 'out013.mp4'
zybru at hp-6530b-bs:~/Desktop$ ffmpeg -f concat -i concat.lst -c copy joined.mp4
ffmpeg version N-50129-g951d39f Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb 20 2013 14:47:49 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --enable-gpl --enable-libfaac --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libtheora --enable-libvorbis --enable-libx264
--enable-nonfree --enable-version3 --enable-x11grab
--disable-stripping --enable-debug=3 --extra-cflags=-gstabs+
--disable-optimizations
  libavutil      52. 17.102 / 52. 17.102
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.100 / 54. 63.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 38.103 /  3. 38.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[concat @ 0x2b61fc0] Estimating duration from bitrate, this may be inaccurate
Input #0, concat, from 'concat.lst':
  Duration: 00:00:00.03, start: 0.000000, bitrate: 76 kb/s
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x818 [SAR 1:1 DAR 960:409], 1371 kb/s, 21.52 fps, 24 tbr, 12288
tbn, 48 tbc
    Stream #0:1: Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo,
s16p, 126 kb/s
File 'joined.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'joined.mp4':
  Metadata:
    encoder         : Lavf54.63.100
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p,
1920x818 [SAR 1:1 DAR 960:409], q=2-31, 1371 kb/s, 21.52 fps, 12288
tbn, 12288 tbc
    Stream #0:1: Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, stereo, 126 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 1440 fps=0.0 q=-1.0 Lsize=   12561kB time=00:01:03.50
bitrate=1620.2kbits/s
video:11561kB audio:938kB subtitle:0 global headers:0kB muxing
overhead 0.494472%


zybru at hp-6530b-bs:~/Desktop$ ffprobe joined.mp4
ffprobe version N-50129-g951d39f Copyright (c) 2007-2013 the FFmpeg developers
  built on Feb 20 2013 14:47:49 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --enable-gpl --enable-libfaac --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libtheora --enable-libvorbis --enable-libx264
--enable-nonfree --enable-version3 --enable-x11grab
--disable-stripping --enable-debug=3 --extra-cflags=-gstabs+
--disable-optimizations
  libavutil      52. 17.102 / 52. 17.102
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.100 / 54. 63.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 38.103 /  3. 38.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'joined.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf54.63.100
  Duration: 00:01:03.51, start: 0.000000, bitrate: 1620 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x818 [SAR 1:1 DAR 960:409], 1491 kb/s, 22.69 fps, 24 tbr, 12288
tbn, 48 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz,
stereo, s16p, 128 kb/s
    Metadata:
      handler_name    : SoundHandler

Žygimantas


More information about the ffmpeg-user mailing list