[FFmpeg-user] How to split and then concatenate a video file?
Žygimantas Bruzgys
un1x0nly at gmail.com
Tue Feb 19 16:49:16 CET 2013
On Tue, Feb 19, 2013 at 2:28 PM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> Does it work if you reencode (instead of -c copy)?
With reencoding, segment produced less files (14, instead of 30). And
still contained glitches between split points. Output:
zybru at hp-6530b-bs:~/Desktop$ ffmpeg -i small.mp4 -f segment -vcodec
h264 -acodec mp3 -segment_time 2 -map 0 out%03d.mp4
ffmpeg version N-49277-g7003d65 Copyright (c) 2000-2013 the FFmpeg developers
built on Jan 25 2013 14:08:54 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-shared --enable-gpl --enable-nonfree
--enable-libfaac --enable-libx264 --enable-libxvid --enable-libmp3lame
--enable-libtheora --enable-libopenjpeg --disable-stripping
--enable-debug=3 --extra-cflags=-gstabs+ --disable-optimizations
libavutil 52. 15.103 / 52. 15.103
libavcodec 54. 90.100 / 54. 90.100
libavformat 54. 61.104 / 54. 61.104
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 33.100 / 3. 33.100
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 @ 0xdb8e60] using SAR=1/1
[libx264 @ 0xdb8e60] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.1 Cache64
[libx264 @ 0xdb8e60] profile High, level 4.0
[libx264 @ 0xdb8e60] 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.61.104
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=9.9 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 @ 0xdb8e60] frame I:16 Avg QP:15.08 size: 37096
[libx264 @ 0xdb8e60] frame P:1016 Avg QP:20.03 size: 9881
[libx264 @ 0xdb8e60] frame B:408 Avg QP:23.28 size: 2954
[libx264 @ 0xdb8e60] consecutive B-frames: 59.2% 5.7% 9.8% 25.3%
[libx264 @ 0xdb8e60] mb I I16..4: 42.5% 47.1% 10.4%
[libx264 @ 0xdb8e60] 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 @ 0xdb8e60] 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 @ 0xdb8e60] 8x8 transform intra:54.6% inter:86.7%
[libx264 @ 0xdb8e60] coded y,uvDC,uvAC intra: 22.8% 29.1% 2.1% inter:
4.7% 6.6% 0.0%
[libx264 @ 0xdb8e60] i16 v,h,dc,p: 32% 30% 16% 22%
[libx264 @ 0xdb8e60] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 22% 34% 3%
3% 3% 4% 3% 3%
[libx264 @ 0xdb8e60] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 21% 19% 5%
6% 6% 5% 4% 3%
[libx264 @ 0xdb8e60] i8c dc,h,v,p: 72% 14% 13% 2%
[libx264 @ 0xdb8e60] Weighted P-Frames: Y:0.4% UV:0.2%
[libx264 @ 0xdb8e60] ref P L0: 78.4% 8.7% 9.7% 3.2% 0.0%
[libx264 @ 0xdb8e60] ref B L0: 90.6% 8.1% 1.2%
[libx264 @ 0xdb8e60] ref B L1: 95.0% 5.0%
[libx264 @ 0xdb8e60] kb/s:1578.34
zybru at hp-6530b-bs:~/Desktop$ cat concat.lst | head -n 2; cat
concat.lst | tail -n 2
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-49277-g7003d65 Copyright (c) 2000-2013 the FFmpeg developers
built on Jan 25 2013 14:08:54 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-shared --enable-gpl --enable-nonfree
--enable-libfaac --enable-libx264 --enable-libxvid --enable-libmp3lame
--enable-libtheora --enable-libopenjpeg --disable-stripping
--enable-debug=3 --extra-cflags=-gstabs+ --disable-optimizations
libavutil 52. 15.103 / 52. 15.103
libavcodec 54. 90.100 / 54. 90.100
libavformat 54. 61.104 / 54. 61.104
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 33.100 / 3. 33.100
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
[concat @ 0x2424f80] 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
Output #0, mp4, to 'joined.mp4':
Metadata:
encoder : Lavf54.61.104
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= 12560kB time=00:01:03.50
bitrate=1620.2kbits/s
video:11561kB audio:938kB subtitle:0 global headers:0kB muxing
overhead 0.490097%
zybru at hp-6530b-bs:~/Desktop$ vlc joined.mp4
VLC media player 2.0.5 Twoflower (revision 2.0.5-0-g1661b7d)
[0xd59108] main libvlc: Running vlc with the default interface. Use
'cvlc' to use vlc without interface.
zybru at hp-6530b-bs:~/Desktop$ ffprobe joined.mp4
ffprobe version N-49277-g7003d65 Copyright (c) 2007-2013 the FFmpeg developers
built on Jan 25 2013 14:08:54 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-shared --enable-gpl --enable-nonfree
--enable-libfaac --enable-libx264 --enable-libxvid --enable-libmp3lame
--enable-libtheora --enable-libopenjpeg --disable-stripping
--enable-debug=3 --extra-cflags=-gstabs+ --disable-optimizations
libavutil 52. 15.103 / 52. 15.103
libavcodec 54. 90.100 / 54. 90.100
libavformat 54. 61.104 / 54. 61.104
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 33.100 / 3. 33.100
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.61.104
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
I've also tried to reencode while concatenating:
zybru at hp-6530b-bs:~/Desktop$ ffmpeg -f concat -i concat.lst -vcodec
h264 -acodec mp3 joined-reencoded.mp4
ffmpeg version N-49277-g7003d65 Copyright (c) 2000-2013 the FFmpeg developers
built on Jan 25 2013 14:08:54 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-shared --enable-gpl --enable-nonfree
--enable-libfaac --enable-libx264 --enable-libxvid --enable-libmp3lame
--enable-libtheora --enable-libopenjpeg --disable-stripping
--enable-debug=3 --extra-cflags=-gstabs+ --disable-optimizations
libavutil 52. 15.103 / 52. 15.103
libavcodec 54. 90.100 / 54. 90.100
libavformat 54. 61.104 / 54. 61.104
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 33.100 / 3. 33.100
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
[concat @ 0x1518fc0] 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
[libx264 @ 0x1540cc0] using SAR=1/1
[libx264 @ 0x1540cc0] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.1 Cache64
[libx264 @ 0x1540cc0] profile High, level 4.0
[libx264 @ 0x1540cc0] 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, mp4, to 'joined-reencoded.mp4':
Metadata:
encoder : Lavf54.61.104
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p,
1920x818 [SAR 1:1 DAR 960:409], q=-1--1, 12288 tbn, 24 tbc
Stream #0:1: Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, stereo, s16p
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (mp3 -> libmp3lame)
Press [q] to stop, [?] for help
frame= 152`1=28.0 Lsize= 12475kB time=00:01:03.50
bitrate=1609.1kbits/s dup=84 drop=0
video:11473kB audio:938kB subtitle:0 global headers:0kB muxing
overhead 0.507187%
[libx264 @ 0x1540cc0] frame I:16 Avg QP:12.73 size: 41454
[libx264 @ 0x1540cc0] frame P:978 Avg QP:19.91 size: 9912
[libx264 @ 0x1540cc0] frame B:530 Avg QP:23.35 size: 2624
[libx264 @ 0x1540cc0] consecutive B-frames: 50.9% 4.9% 10.4% 33.9%
[libx264 @ 0x1540cc0] mb I I16..4: 41.5% 46.6% 12.0%
[libx264 @ 0x1540cc0] mb P I16..4: 7.5% 10.2% 0.3% P16..4: 26.1%
4.0% 1.1% 0.0% 0.0% skip:50.9%
[libx264 @ 0x1540cc0] mb B I16..4: 0.5% 0.6% 0.0% B16..8: 23.6%
0.9% 0.1% direct: 0.4% skip:74.1% L0:50.8% L1:48.2% BI: 1.0%
[libx264 @ 0x1540cc0] 8x8 transform intra:55.7% inter:89.8%
[libx264 @ 0x1540cc0] coded y,uvDC,uvAC intra: 22.8% 31.1% 2.3% inter:
4.1% 6.8% 0.0%
[libx264 @ 0x1540cc0] i16 v,h,dc,p: 32% 30% 16% 22%
[libx264 @ 0x1540cc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 22% 34% 3%
3% 3% 4% 3% 3%
[libx264 @ 0x1540cc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 22% 19% 4%
6% 6% 5% 4% 3%
[libx264 @ 0x1540cc0] i8c dc,h,v,p: 71% 14% 14% 2%
[libx264 @ 0x1540cc0] Weighted P-Frames: Y:0.4% UV:0.2%
[libx264 @ 0x1540cc0] ref P L0: 77.0% 8.9% 10.5% 3.6% 0.0%
[libx264 @ 0x1540cc0] ref B L0: 87.9% 10.4% 1.7%
[libx264 @ 0x1540cc0] ref B L1: 94.7% 5.3%
[libx264 @ 0x1540cc0] kb/s:1480.08
zybru at hp-6530b-bs:~/Desktop$ ffprobe joined-reencoded.mp4
ffprobe version N-49277-g7003d65 Copyright (c) 2007-2013 the FFmpeg developers
built on Jan 25 2013 14:08:54 with gcc 4.6 (Ubuntu/Linaro
4.6.3-1ubuntu5)
configuration: --enable-shared --enable-gpl --enable-nonfree
--enable-libfaac --enable-libx264 --enable-libxvid --enable-libmp3lame
--enable-libtheora --enable-libopenjpeg --disable-stripping
--enable-debug=3 --extra-cflags=-gstabs+ --disable-optimizations
libavutil 52. 15.103 / 52. 15.103
libavcodec 54. 90.100 / 54. 90.100
libavformat 54. 61.104 / 54. 61.104
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 33.100 / 3. 33.100
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-reencoded.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf54.61.104
Duration: 00:01:03.53, start: 0.025057, bitrate: 1608 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
1920x818 [SAR 1:1 DAR 960:409], 1480 kb/s, 24 fps, 24 tbr, 12288 tbn,
48 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz,
stereo, s16p, 120 kb/s
Metadata:
handler_name : SoundHandler
> Does it work with higher values for segmet_time?
I have not tried it yet, but I suppose the result will be the same.
Žygimantas
More information about the ffmpeg-user
mailing list