[FFmpeg-user] Fixed GOP encoding for HLS

Andrew Sinclair ajsinclair at gmail.com
Wed Dec 12 05:56:03 CET 2012


To wrap this one up and assist anyone else trying to do this here is how I
am achieving good results i.e. nicely aligned m3u8 files. Though there is
definitely some issue in regard to the lengths of the segments as reported
in the m3u8 files.

In summary best thing I have found so far is to drop the scenecut frame
hints i.e. -g and -keyint_min and only add the -force_key_frames

Apologies for the format of the output below but I have had to wrap this
all up in a series of Python scripts where I am also using ffprobe to check
that I have keyframes exactly where I want them.

Encode cmd: ffmpeg -y -i /home/parallels/Videos/131375031.mp4 -pix_fmt
yuv420p -vcodec libx264 -r 24.0     -profile:v baseline -b:v 500k -maxrate
500k  -force_key_frames
0:00:06,0:00:12,0:00:18,0:00:24,0:00:30,0:00:36,0:00:42,0:00:48,0:00:54,0:01:00,0:01:06,0:01:12,0:01:18,0:01:24,0:01:30,0:01:36,0:01:42,0:01:48,0:01:54,0:02:00,0:02:06,0:02:12,0:02:18,0:02:24,0:02:30,0:02:36,0:02:42,0:02:48,0:02:54,0:03:00,0:03:06,0:03:12,0:03:18,0:03:24,0:03:30,0:03:36,0:03:42,0:03:48,0:03:54,0:04:00,0:04:06,0:04:12,0:04:18,0:04:24,0:04:30,0:04:36,0:04:42,0:04:48,0:04:54,0:05:00,0:05:06,0:05:12,0:05:18,0:05:24,0:05:30,0:05:36,0:05:42
     -s 640x360
/home/parallels/encodes/hls/131375031/131375031_500_640x360.ts
('', "ffmpeg version N-45739-g04bf2e7 Copyright (c) 2000-2012 the FFmpeg
developers\n  built on Oct 20 2012 13:34:12 with gcc 4.6 (Ubuntu/Linaro
4.6.3-1ubuntu5)\n  configuration: --enable-gpl --enable-libfaac
--enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-librtmp --enable-libtheora
--enable-libvorbis --enable-libvpx --enable-x11grab --enable-libx264
--enable-nonfree --enable-version3\n  libavutil      51. 76.100 / 51.
76.100\n  libavcodec     54. 67.100 / 54. 67.100\n  libavformat    54.
33.100 / 54. 33.100\n  libavdevice    54.  3.100 / 54.  3.100\n
 libavfilter     3. 19.103 /  3. 19.103\n  libswscale      2.  1.101 /  2.
 1.101\n  libswresample   0. 16.100 /  0. 16.100\n  libpostproc    52.
 1.100 / 52.  1.100\nInput #0, mov,mp4,m4a,3gp,3g2,mj2, from
'/home/parallels/Videos/131375031.mp4':\n  Metadata:\n    major_brand     :
mp42\n    minor_version   : 0\n    compatible_brands: mp42mp41isomavc1\n
 creation_time   : 2012-11-30 01:25:50\n  Duration: 00:05:45.35, start:
0.046440, bitrate: 1710 kb/s\n    Stream #0:0(und): Video: h264 (High)
(avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1549 kb/s, 23.98
fps, 23.98 tbr, 24k tbn, 47.95 tbc\n    Metadata:\n      creation_time   :
2012-11-30 01:25:50\n      handler_name    : L-SMASH Video Handler\n
 Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16,
157 kb/s\n    Metadata:\n      creation_time   : 2012-11-30 01:25:50\n
 handler_name    : L-SMASH Audio Handler\n[libx264 @ 0x1c0af00] VBV maxrate
specified, but no bufsize, ignored\n[libx264 @ 0x1c0af00] using
SAR=1/1\n[libx264 @ 0x1c0af00] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.2 AVX\n[libx264 @ 0x1c0af00] profile Constrained Baseline,
level 3.0\nOutput #0, mpegts, to
'/home/parallels/encodes/hls/131375031/131375031_500_640x360.ts':\n
 Metadata:\n    major_brand     : mp42\n    minor_version   : 0\n
 compatible_brands: mp42mp41isomavc1\n    encoder         : Lavf54.33.100\n
   Stream #0:0(und): Video: h264, yuv420p, 640x360 [SAR 1:1 DAR 16:9],
q=-1--1, 500 kb/s, 90k tbn, 24 tbc\n    Metadata:\n      creation_time   :
2012-11-30 01:25:50\n      handler_name    : L-SMASH Video Handler\n
 Stream #0:1(und): Audio: mp2, 44100 Hz, stereo, s16, 128 kb/s\n
 Metadata:\n      creation_time   : 2012-11-30 01:25:50\n      handler_name
   : L-SMASH Audio Handler\nStream mapping:\n  Stream #0:0 -> #0:0 (h264 ->
libx264)\n  Stream #0:1 -> #0:1 (aac -> mp2)\nPress [q] to stop, [?] for
help\nframe=   70 fps=0.0 q=40.0 size=     152kB time=00:00:03.04 bitrate=
408.4kbits/s dup=1 drop=0    \rframe=  142 fps=142 q=36.0 size=     330kB
time=00:00:06.10 bitrate= 442.7kbits/s dup=1 drop=0    \rframe=  252
fps=167 q=24.0 size=     482kB time=00:00:10.20 bitrate= 387.1kbits/s dup=1
drop=0    \rframe=  338 fps=168 q=22.0 size=     670kB time=00:00:14.27
bitrate= 384.4kbits/s dup=1 drop=0    \rframe=  404 fps=157 q=21.0 size=
  981kB time=00:00:16.31 bitrate= 492.7kbits/s dup=2 drop=0    \rframe=
 442 fps=143 q=30.0 size=    1493kB time=00:00:18.37 bitrate= 665.5kbits/s
dup=2 drop=0    \rframe=  483 fps=134 q=32.0 size=    1736kB
time=00:00:20.41 bitrate= 696.5kbits/s dup=2 drop=0    \rframe=  528
fps=128 q=34.0 size=    1999kB time=00:00:22.45 bitrate= 729.2kbits/s dup=2
drop=0    \rframe=  575 fps=124 q=36.0 size=    2238kB time=00:00:24.49
bitrate= 748.6kbits/s dup=2 drop=0    \rframe=  626 fps=122 q=36.0 size=
 2410kB time=00:00:26.52 bitrate= 744.3kbits/s dup=2 drop=0    \rframe=
 676 fps=120 q=36.0 size=    2615kB time=00:00:28.59 bitrate= 749.1kbits/s
dup=2 drop=0    \rframe=  763 fps=124 q=32.0 size=    2791kB
time=00:00:31.64 bitrate= 722.5kbits/s dup=2 drop=0    \rframe=  823
fps=124 q=34.0 size=    2942kB time=00:00:34.70 bitrate= 694.5kbits/s dup=2
drop=0    \rframe=  893 fps=125 q=32.0 size=    3090kB time=00:00:37.78
bitrate= 669.9kbits/s dup=2 drop=0    \rframe=  965 fps=126 q=29.0 size=
 3245kB time=00:00:40.84 bitrate= 650.8kbits/s dup=2 drop=0    \rframe=
1050 fps=129 q=29.0 size=    3421kB time=00:00:43.90 bitrate= 638.4kbits/s
dup=2 drop=0    \rframe= 1125 fps=130 q=28.0 size=    3600kB
time=00:00:46.98 bitrate= 627.7kbits/s dup=2 drop=0    \rframe= 1188
fps=130 q=27.0 size=    3787kB time=00:00:49.02 bitrate= 632.8kbits/s dup=2
drop=0    \rframe= 1247 fps=129 q=26.0 size=    3966kB time=00:00:52.07
bitrate= 623.9kbits/s dup=2 drop=0    \rframe= 1307 fps=128 q=26.0 size=
 4156kB time=00:00:54.11 bitrate= 629.2kbits/s dup=2 drop=0    \rframe=
1367 fps=128 q=26.0 size=    4347kB time=00:00:57.19 bitrate= 622.6kbits/s
dup=2 drop=0    \rframe= 1427 fps=128 q=25.0 size=    4528kB
time=00:00:59.23 bitrate= 626.2kbits/s dup=3 drop=0    \rframe= 1480
fps=127 q=25.0 size=    4708kB time=00:01:01.27 bitrate= 629.4kbits/s dup=3
drop=0    \rframe= 1533 fps=126 q=25.0 size=    4917kB time=00:01:03.30
bitrate= 636.3kbits/s dup=3 drop=0    \rframe= 1584 fps=125 q=25.0 size=
 5135kB time=00:01:06.39 bitrate= 633.6kbits/s dup=3 drop=0    \rframe=
1635 fps=124 q=26.0 size=    5358kB time=00:01:08.42 bitrate= 641.4kbits/s
dup=3 drop=0    \rframe= 1687 fps=123 q=26.0 size=    5572kB
time=00:01:10.46 bitrate= 647.7kbits/s dup=3 drop=0    \rframe= 1733
fps=122 q=27.0 size=    5814kB time=00:01:12.50 bitrate= 656.9kbits/s dup=3
drop=0    \rframe= 1775 fps=121 q=28.0 size=    6158kB time=00:01:14.56
bitrate= 676.5kbits/s dup=3 drop=0    \rframe= 1817 fps=120 q=32.0 size=
 6647kB time=00:01:15.58 bitrate= 720.3kbits/s dup=3 drop=0    \rframe=
1872 fps=119 q=32.0 size=    6861kB time=00:01:18.64 bitrate= 714.7kbits/s
dup=3 drop=0    \rframe= 1927 fps=119 q=32.0 size=    7086kB
time=00:01:20.68 bitrate= 719.5kbits/s dup=3 drop=0    \rframe= 1977
fps=118 q=32.0 size=    7232kB time=00:01:22.74 bitrate= 715.9kbits/s dup=3
drop=0    \rframe= 2033 fps=118 q=32.0 size=    7394kB time=00:01:24.78
bitrate= 714.4kbits/s dup=3 drop=0    \rframe= 2093 fps=118 q=32.0 size=
 7602kB time=00:01:27.83 bitrate= 709.0kbits/s dup=3 drop=0    \rframe=
2156 fps=118 q=31.0 size=    7752kB time=00:01:29.87 bitrate= 706.6kbits/s
dup=3 drop=0    \rframe= 2226 fps=119 q=31.0 size=    7953kB
time=00:01:32.95 bitrate= 700.9kbits/s dup=3 drop=0    \rframe= 2283
fps=119 q=31.0 size=    8128kB time=00:01:36.01 bitrate= 693.5kbits/s dup=3
drop=0    \rframe= 2339 fps=118 q=31.0 size=    8335kB time=00:01:37.03
bitrate= 703.7kbits/s dup=3 drop=0    \rframe= 2392 fps=118 q=31.0 size=
 8529kB time=00:01:39.07 bitrate= 705.3kbits/s dup=4 drop=0    \rframe=
2456 fps=118 q=31.0 size=    8734kB time=00:01:42.15 bitrate= 700.4kbits/s
dup=4 drop=0    \rframe= 2516 fps=118 q=30.0 size=    8892kB
time=00:01:44.19 bitrate= 699.1kbits/s dup=4 drop=0    \rframe= 2578
fps=118 q=27.0 size=    9038kB time=00:01:47.24 bitrate= 690.4kbits/s dup=4
drop=0    \rframe= 2644 fps=119 q=29.0 size=    9216kB time=00:01:50.33
bitrate= 684.3kbits/s dup=4 drop=0    \rframe= 2703 fps=119 q=29.0 size=
 9352kB time=00:01:52.36 bitrate= 681.8kbits/s dup=4 drop=0    \rframe=
2756 fps=118 q=28.0 size=    9527kB time=00:01:54.40 bitrate= 682.2kbits/s
dup=4 drop=0    \rframe= 2805 fps=118 q=29.0 size=    9726kB
time=00:01:56.44 bitrate= 684.2kbits/s dup=4 drop=0    \rframe= 2864
fps=118 q=28.0 size=    9909kB time=00:01:59.52 bitrate= 679.2kbits/s dup=4
drop=0    \rframe= 2924 fps=118 q=28.0 size=   10092kB time=00:02:01.56
bitrate= 680.1kbits/s dup=4 drop=0    \rframe= 2992 fps=118 q=28.0 size=
10274kB time=00:02:04.61 bitrate= 675.4kbits/s dup=4 drop=0    \rframe=
3052 fps=118 q=27.0 size=   10412kB time=00:02:07.67 bitrate= 668.0kbits/s
dup=4 drop=0    \rframe= 3109 fps=118 q=27.0 size=   10612kB
time=00:02:09.73 bitrate= 670.0kbits/s dup=4 drop=0    \rframe= 3169
fps=118 q=27.0 size=   10784kB time=00:02:12.79 bitrate= 665.3kbits/s dup=4
drop=0    \rframe= 3234 fps=118 q=26.0 size=   10952kB time=00:02:14.83
bitrate= 665.4kbits/s dup=4 drop=0    \rframe= 3289 fps=118 q=26.0 size=
11135kB time=00:02:17.91 bitrate= 661.4kbits/s dup=4 drop=0    \rframe=
3352 fps=118 q=27.0 size=   11506kB time=00:02:19.95 bitrate= 673.5kbits/s
dup=4 drop=0    \rframe= 3407 fps=118 q=27.0 size=   11765kB
time=00:02:22131375031_500_640x360.ts
.01 bitrate= 678.7kbits/s dup=5 drop=0    \rframe= 3468 fps=118 q=28.0
size=   12010kB time=00:02:25.04 bitrate= 678.3kbits/s dup=5 drop=0
 \rframe= 3542 fps=119 q=28.0 size=   12293kB time=00:02:27.11 bitrate=
684.6kbits/s dup=5 drop=0    \rframe= 3609 fps=119 q=27.0 size=   12472kB
time=00:02:30.16 bitrate= 680.4kbits/s dup=5 drop=0    \rframe= 3675
fps=119 q=27.0 size=   12731kB time=00:02:33.22 bitrate= 680.7kbits/s dup=5
drop=0    \rframe= 3741 fps=119 q=27.0 size=   12902kB time=00:02:35.26
bitrate= 680.7kbits/s dup=5 drop=0    \rframe= 3788 fps=119 q=27.0 size=
13051kB time=00:02:37.32 bitrate= 679.6kbits/s dup=5 drop=0    \rframe=
3834 fps=118 q=27.0 size=   13250kB time=00:02:39.36 bitrate= 681.1kbits/s
dup=5 drop=0    \rframe= 3882 fps=118 q=27.0 size=   13428kB
time=00:02:41.39 bitrate= 681.5kbits/s dup=5 drop=0    \rframe= 3926
fps=117 q=27.0 size=   13589kB time=00:02:43.43 bitrate= 681.1kbits/s dup=5
drop=0    \rframe= 3981 fps=117 q=27.0 size=   13786kB time=00:02:45.50
bitrate= 682.4kbits/s dup=5 drop=0    \rframe= 4039 fps=117 q=27.0 size=
13946kB time=00:02:48.55 bitrate= 677.8kbits/s dup=5 drop=0    \rframe=
4096 fps=117 q=27.0 size=   14150kB time=00:02:50.59 bitrate= 679.5kbits/s
dup=5 drop=0    \rframe= 4151 fps=117 q=27.0 size=   14319kB
time=00:02:52.65 bitrate= 679.4kbits/s dup=5 drop=0    \rframe= 4209
fps=117 q=26.0 size=   14502kB time=00:02:55.71 bitrate= 676.1kbits/s dup=5
drop=0    \rframe= 4266 fps=117 q=26.0 size=   14722kB time=00:02:57.75
bitrate= 678.5kbits/s dup=5 drop=0    \rframe= 4317 fps=117 q=27.0 size=
14976kB time=00:02:59.78 bitrate= 682.4kbits/s dup=5 drop=0    \rframe=
4370 fps=117 q=27.0 size=   15229kB time=00:03:02.84 bitrate= 682.3kbits/s
dup=5 drop=0    \rframe= 4421 fps=117 q=28.0 size=   15502kB
time=00:03:04.90 bitrate= 686.8kbits/s dup=6 drop=0    \rframe= 4480
fps=117 q=28.0 size=   15695kB time=00:03:06.94 bitrate= 687.8kbits/s dup=6
drop=0    \rframe= 4536 fps=116 q=28.0 size=   15928kB time=00:03:09.01
bitrate= 690.4kbits/s dup=6 drop=0    \rframe= 4597 fps=117 q=28.0 size=
16127kB time=00:03:12.04 bitrate= 687.9kbits/s dup=6 drop=0    \rframe=
4672 fps=117 q=27.0 size=   16356kB time=00:03:15.12 bitrate= 686.7kbits/s
dup=6 drop=0    \rframe= 4726 fps=117 q=27.0 size=   16543kB
time=00:03:16.14 bitrate= 690.9kbits/s dup=6 drop=0    \rframe= 4782
fps=117 q=27.0 size=   16729kB time=00:03:19.19 bitrate= 688.0kbits/s dup=6
drop=0    \rframe= 4837 fps=117 q=27.0 size=   16930kB time=00:03:21.23
bitrate= 689.2kbits/s dup=6 drop=0    \rframe= 4900 fps=117 q=27.0 size=
17076kB time=00:03:24.31 bitrate= 684.7kbits/s dup=6 drop=0    \rframe=
4947 fps=116 q=27.0 size=   17250kB time=00:03:26.35 bitrate= 684.8kbits/s
dup=6 drop=0    \rframe= 4998 fps=116 q=27.0 size=   17389kB
time=00:03:28.39 bitrate= 683.5kbits/s dup=6 drop=0    \rframe= 5047
fps=116 q=27.0 size=   17596kB time=00:03:30.43 bitrate= 685.0kbits/s dup=6
drop=0    \rframe= 5105 fps=116 q=27.0 size=   17795kB time=00:03:32.49
bitrate= 686.0kbits/s dup=6 drop=0    \rframe= 5171 fps=116 q=26.0 size=
17965kB time=00:03:35.55 bitrate= 682.8kbits/s dup=6 drop=0    \rframe=
5229 fps=116 q=26.0 size=   18142kB time=00:03:37.58 bitrate= 683.0kbits/s
dup=6 drop=0    \rframe= 5274 fps=116 q=27.0 size=   18473kB
time=00:03:39.62 bitrate= 689.0kbits/s dup=6 drop=0    \rframe= 5314
fps=115 q=28.0 size=   18859kB time=00:03:41.69 bitrate= 696.9kbits/s dup=6
drop=0    \rframe= 5358 fps=115 q=29.0 size=   19154kB time=00:03:43.72
bitrate= 701.3kbits/s dup=6 drop=0    \rframe= 5412 fps=115 q=29.0 size=
19402kB time=00:03:45.76 bitrate= 704.0kbits/s dup=7 drop=0    \rframe=
5473 fps=115 q=29.0 size=   19634kB time=00:03:47.82 bitrate= 706.0kbits/s
dup=7 drop=0    \rframe= 5537 fps=115 q=29.0 size=   19809kB
time=00:03:50.88 bitrate= 702.8kbits/s dup=7 drop=0    \rframe= 5605
fps=115 q=29.0 size=   19973kB time=00:03:53.94 bitrate= 699.4kbits/s dup=7
drop=0    \rframe= 5670 fps=116 q=28.0 size=   20131kB time=00:03:56.99
bitrate= 695.8kbits/s dup=7 drop=0    \rframe= 5746 fps=116 q=28.0 size=
20358kB time=00:04:00.08 bitrate= 694.6kbits/s dup=7 drop=0    \rframe=
5813 fps=116 q=28.0 size=   20558kB time=00:04:03.13 bitrate= 692.6kbits/s
dup=7 drop=0    \rframe= 5870 fps=116 q=28.0 size=   20738kB
time=00:04:05.17 bitrate= 692.9kbits/s dup=7 drop=0    \rframe= 5925
fps=116 q=28.0 size=   20914kB time=00:04:06.19 bitrate= 695.9kbits/s dup=7
drop=0    \rframe= 5995 fps=116 q=28.0 size=   21154kB time=00:04:09.27
bitrate= 695.2kbits/s dup=7 drop=0    \rframe= 6063 fps=116 q=28.0 size=
21384kB time=00:04:12.33 bitrate= 694.2kbits/s dup=7 drop=0    \rframe=
6119 fps=116 q=28.0 size=   21659kB time=00:04:14.36 bitrate= 697.5kbits/s
dup=7 drop=0    \rframe= 6178 fps=116 q=28.0 size=   21867kB
time=00:04:17.45 bitrate= 695.8kbits/s dup=7 drop=0    \rframe= 6228
fps=116 q=28.0 size=   22132kB time=00:04:19.48 bitrate= 698.7kbits/s dup=7
drop=0    \rframe= 6281 fps=116 q=29.0 size=   22458kB time=00:04:21.52
bitrate= 703.5kbits/s dup=7 drop=0    \rframe= 6354 fps=116 q=29.0 size=
22686kB time=00:04:24.58 bitrate= 702.4kbits/s dup=7 drop=0    \rframe=
6405 fps=116 q=29.0 size=   22942kB time=00:04:26.64 bitrate= 704.8kbits/s
dup=8 drop=0    \rframe= 6450 fps=116 q=29.0 size=   23153kB
time=00:04:28.68 bitrate= 705.9kbits/s dup=8 drop=0    \rframe= 6511
fps=116 q=29.0 size=   23395kB time=00:04:31.74 bitrate= 705.3kbits/s dup=8
drop=0    \rframe= 6578 fps=116 q=29.0 size=   23570kB time=00:04:33.77
bitrate= 705.3kbits/s dup=8 drop=0    \rframe= 6640 fps=116 q=29.0 size=
23744kB time=00:04:36.86 bitrate= 702.6kbits/s dup=8 drop=0    \rframe=
6695 fps=116 q=29.0 size=   23956kB time=00:04:38.89 bitrate= 703.6kbits/s
dup=8 drop=0    \rframe= 6759 fps=116 q=29.0 size=   24164kB
time=00:04:41.95 bitrate= 702.1kbits/s dup=8 drop=0    \rframe= 6831
fps=116 q=28.0 size=   24312kB time=00:04:45.03 bitrate= 698.7kbits/s dup=8
drop=0    \rframe= 6901 fps=117 q=28.0 size=   24493kB time=00:04:48.09
bitrate= 696.5kbits/s dup=8 drop=0    \rframe= 6968 fps=117 q=28.0 size=
24720kB time=00:04:51.14 bitrate= 695.5kbits/s dup=8 drop=0    \rframe=
7025 fps=117 q=28.0 size=   24966kB time=00:04:53.18 bitrate= 697.6kbits/s
dup=8 drop=0    \rframe= 7095 fps=117 q=28.0 size=   25121kB
time=00:04:55.25 bitrate= 697.0kbits/s dup=8 drop=0    \rframe= 7187
fps=117 q=27.0 size=   25277kB time=00:04:59.32 bitrate= 691.8kbits/s dup=8
drop=0    \rframe= 7305 fps=118 q=26.0 size=   25399kB time=00:05:04.44
bitrate= 683.4kbits/s dup=8 drop=0    \rframe= 7404 fps=119 q=25.0 size=
25586kB time=00:05:08.52 bitrate= 679.4kbits/s dup=9 drop=0    \rframe=
7495 fps=120 q=24.0 size=   25833kB time=00:05:12.62 bitrate= 676.9kbits/s
dup=9 drop=0    \rframe= 7583 fps=120 q=24.0 size=   26133kB
time=00:05:15.67 bitrate= 678.2kbits/s dup=9 drop=0    \rframe= 7671
fps=120 q=24.0 size=   26405kB time=00:05:19.75 bitrate= 676.5kbits/s dup=9
drop=0    \rframe= 7763 fps=121 q=23.0 size=   26668kB time=00:05:23.85
bitrate= 674.6kbits/s dup=9 drop=0    \rframe= 7863 fps=122 q=23.0 size=
26918kB time=00:05:27.93 bitrate= 672.4kbits/s dup=9 drop=0    \rframe=
7961 fps=122 q=22.0 size=   27175kB time=00:05:32.03 bitrate= 670.5kbits/s
dup=9 drop=0    \rframe= 8064 fps=123 q=21.0 size=   27423kB
time=00:05:36.10 bitrate= 668.4kbits/s dup=9 drop=0    \rframe= 8180
fps=124 q=21.0 size=   27599kB time=00:05:41.22 bitrate= 662.6kbits/s dup=9
drop=0    \rframe= 8289 fps=124 q=32766.0 Lsize=   27751kB time=00:05:45.40
bitrate= 658.2kbits/s dup=9 drop=0    \r\nvideo:19331kB audio:5397kB
subtitle:0 global headers:0kB muxing overhead 12.222082%\n[libx264 @
0x1c0af00] frame I:240   Avg QP:19.95  size: 18762\n[libx264 @ 0x1c0af00]
frame P:8049  Avg QP:23.65  size:  1900\n[libx264 @ 0x1c0af00] mb I
 I16..4: 36.2%  0.0% 63.8%\n[libx264 @ 0x1c0af00] mb P  I16..4:  1.9%  0.0%
 1.0%  P16..4: 30.6%  7.4%  2.5%  0.0%  0.0%    skip:56.6%\n[libx264 @
0x1c0af00] final ratefactor: 21.84\n[libx264 @ 0x1c0af00] coded y,uvDC,uvAC
intra: 43.8% 58.3% 27.7% inter: 6.8% 13.9% 0.6%\n[libx264 @ 0x1c0af00] i16
v,h,dc,p: 42% 32%  8% 18%\n[libx264 @ 0x1c0af00] i4
v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 21% 14%  6%  8%  8%  7%  6%  6%\n[libx264 @
0x1c0af00] i8c dc,h,v,p: 52% 25% 18%  5%\n[libx264 @ 0x1c0af00] ref P L0:
69.7% 19.1% 11.2%\n[libx264 @ 0x1c0af00] kb/s:458.52\n")
Encode completed: 131375031_500_640x360.ts
ffprobe -show_frames
/home/parallels/encodes/hls/131375031/131375031_500_640x360.ts

##### This is my parsed output showing that I have I frames exactly where I
want them ####
Found I frame as expected at 144.0
Found I frame as expected at 288.0
Found I frame as expected at 432.0
Found I frame as expected at 576.0
Found I frame as expected at 720.0
Found I frame as expected at 864.0
Found I frame as expected at 1008.0
Found I frame as expected at 1152.0
Found I frame as expected at 1296.0
Found I frame as expected at 1440.0
Found I frame as expected at 1584.0
Found I frame as expected at 1728.0
Found I frame as expected at 1872.0
Found I frame as expected at 2016.0
Found I frame as expected at 2160.0
Found I frame as expected at 2304.0
Found I frame as expected at 2448.0
Found I frame as expected at 2592.0
Found I frame as expected at 2736.0
Found I frame as expected at 2880.0
Found I frame as expected at 3024.0
Found I frame as expected at 3168.0
Found I frame as expected at 3312.0
Found I frame as expected at 3456.0
Found I frame as expected at 3600.0
Found I frame as expected at 3744.0
Found I frame as expected at 3888.0
Found I frame as expected at 4032.0
Found I frame as expected at 4176.0
Found I frame as expected at 4320.0
Found I frame as expected at 4464.0
Found I frame as expected at 4608.0
Found I frame as expected at 4752.0
Found I frame as expected at 4896.0
Found I frame as expected at 5040.0
Found I frame as expected at 5184.0
Found I frame as expected at 5328.0
Found I frame as expected at 5472.0
Found I frame as expected at 5616.0
Found I frame as expected at 5760.0
Found I frame as expected at 5904.0
Found I frame as expected at 6048.0
Found I frame as expected at 6192.0
Found I frame as expected at 6336.0
Found I frame as expected at 6480.0
Found I frame as expected at 6624.0
Found I frame as expected at 6768.0
Found I frame as expected at 6912.0
Found I frame as expected at 7056.0
Found I frame as expected at 7200.0
Found I frame as expected at 7344.0
Found I frame as expected at 7488.0
Found I frame as expected at 7632.0
Found I frame as expected at 7776.0
Found I frame as expected at 7920.0
Found I frame as expected at 8064.0
Found I frame as expected at 8208.0

#### This is the full list of I Frames generated which shows additional
frames likely generated on scenecut so maintains maximum efficiency/quality
trade off

0,3,83,110,144,185,245,288,299,355,432,446,522,562,576,603,652,712,720,827,864,869,922,954,1008,1029,1090,1123,1139,1152,1177,1210,1238,1275,1296,1301,1331,1373,1398,1435,1440,1460,1479,1514,1584,1614,1633,1664,1695,1710,1727,1728,1746,1768,1797,1814,1835,1872,1998,2014,2016,2033,2042,2077,2132,2148,2160,2164,2204,2225,2252,2271,2282,2304,2319,2376,2399,2431,2448,2512,2513,2514,2535,2555,2575,2592,2613,2686,2736,2779,2880,2903,3024,3034,3064,3168,3194,3237,3266,3279,3291,3312,3323,3358,3442,3450,3456,3489,3578,3600,3604,3634,3682,3744,3888,3930,3975,4024,4032,4092,4131,4176,4194,4253,4265,4303,4320,4367,4397,4434,4464,4483,4512,4551,4608,4624,4689,4752,4803,4840,4896,4945,5007,5040,5066,5102,5141,5170,5184,5196,5211,5223,5237,5246,5266,5297,5318,5328,5373,5388,5413,5441,5457,5472,5490,5564,5616,5647,5694,5704,5742,5760,5899,5904,5936,5974,6048,6052,6070,6092,6119,6132,6155,6166,6180,6192,6206,6226,6239,6269,6291,6317,6332,6336,6340,6351,6366,6376,6384,6397,6406,6415,6426,6433,6456,6480,6528,6553,6577,6590,6602,6611,6619,6624,6628,6639,6649,6654,6669,6704,6751,6768,6816,6832,6855,6903,6912,6916,6937,6945,7008,7056,7200,7344,7488,7632,7776,7920,8064,8208,


Segmenting file: ffmpeg -y -i
/home/parallels/encodes/hls/131375031/131375031_500_640x360.ts -codec copy
-map 0 -f segment -segment_list
/home/parallels/encodes/hls/131375031/index_500.m3u8 -segment_time 6
 -segment_list_type m3u8 131375031_500_640x360_%03d.ts
('', "ffmpeg version N-45739-g04bf2e7 Copyright (c) 2000-2012 the FFmpeg
developers\n  built on Oct 20 2012 13:34:12 with gcc 4.6 (Ubuntu/Linaro
4.6.3-1ubuntu5)\n  configuration: --enable-gpl --enable-libfaac
--enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-librtmp --enable-libtheora
--enable-libvorbis --enable-libvpx --enable-x11grab --enable-libx264
--enable-nonfree --enable-version3\n  libavutil      51. 76.100 / 51.
76.100\n  libavcodec     54. 67.100 / 54. 67.100\n  libavformat    54.
33.100 / 54. 33.100\n  libavdevice    54.  3.100 / 54.  3.100\n
 libavfilter     3. 19.103 /  3. 19.103\n  libswscale      2.  1.101 /  2.
 1.101\n  libswresample   0. 16.100 /  0. 16.100\n  libpostproc    52.
 1.100 / 52.  1.100\n[mpegts @ 0x302f260] max_analyze_duration 5000000
reached at 5015467\nInput #0, mpegts, from
'/home/parallels/encodes/hls/131375031/131375031_500_640x360.ts':\n
 Duration: 00:05:45.34, start: 1.389089, bitrate: 658 kb/s\n  Program 1 \n
   Metadata:\n      service_name    : Service01\n      service_provider:
FFmpeg\n    Stream #0:0[0x100]: Video: h264 (Constrained Baseline)
([27][0][0][0] / 0x001B), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 24 fps, 24
tbr, 90k tbn, 48 tbc\n    Stream #0:1[0x101](und): Audio: mp2 ([3][0][0][0]
/ 0x0003), 44100 Hz, stereo, s16, 128 kb/s\nOutput #0, segment, to
'131375031_500_640x360_%03d.ts':\n  Metadata:\n    encoder         :
Lavf54.33.100\n    Stream #0:0: Video: h264 ([27][0][0][0] / 0x001B),
yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=2-31, 24 fps, 90k tbn, 24 tbc\n
 Stream #0:1(und): Audio: mp2 ([3][0][0][0] / 0x0003), 44100 Hz, stereo,
128 kb/s\nStream mapping:\n  Stream #0:0 -> #0:0 (copy)\n  Stream #0:1 ->
#0:1 (copy)\nPress [q] to stop, [?] for help\nframe= 8289 fps=0.0 q=-1.0
Lsize=       0kB time=00:05:45.41 bitrate=   0.0kbits/s
 \r\nvideo:19380kB audio:5397kB subtitle:0 global headers:0kB muxing
overhead -100.000000%\n")
Finish UTC time: 1355287042.41

Segments then generate nicely aligned m3u8 however there is still something
a little odd with the rounding on the fragment sizes which don't appear to
line up with the actual fragment sizes.

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOWCACHE:1
#EXTINF:6.034289,
131375031_3500_1280x720_000.ts
#EXTINF:6.005422,
131375031_3500_1280x720_001.ts
#EXTINF:6.013578,
131375031_3500_1280x720_002.ts
#EXTINF:6.021744,
131375031_3500_1280x720_003.ts
#EXTINF:6.003789,
131375031_3500_1280x720_004.ts
#EXTINF:6.011944,
131375031_3500_1280x720_005.ts
#EXTINF:6.020111,
131375031_3500_1280x720_006.ts
#EXTINF:6.002156,
131375031_3500_1280x720_007.ts
#EXTINF:6.010322,
131375031_3500_1280x720_008.ts
#EXTINF:6.018478,
131375031_3500_1280x720_009.ts
#EXTINF:6.000522,
131375031_3500_1280x720_010.ts
#EXTINF:6.008689,
131375031_3500_1280x720_011.ts
#EXTINF:6.016844,
131375031_3500_1280x720_012.ts
#EXTINF:6.025011,
131375031_3500_1280x720_013.ts
#EXTINF:6.007056,
131375031_3500_1280x720_014.ts
#EXTINF:6.015211,
131375031_3500_1280x720_015.ts
#EXTINF:6.023378,
131375031_3500_1280x720_016.ts
#EXTINF:6.005422,
131375031_3500_1280x720_017.ts
#EXTINF:6.013578,
131375031_3500_1280x720_018.ts
#EXTINF:6.021744,
131375031_3500_1280x720_019.ts
#EXTINF:6.003789,
131375031_3500_1280x720_020.ts
#EXTINF:6.011944,
131375031_3500_1280x720_021.ts
#EXTINF:6.020111,
131375031_3500_1280x720_022.ts
#EXTINF:6.002156,
131375031_3500_1280x720_023.ts
#EXTINF:6.010322,
131375031_3500_1280x720_024.ts
#EXTINF:6.018478,
131375031_3500_1280x720_025.ts
#EXTINF:6.000522,
131375031_3500_1280x720_026.ts
#EXTINF:6.008689,
131375031_3500_1280x720_027.ts
#EXTINF:6.016844,
131375031_3500_1280x720_028.ts
#EXTINF:6.025011,
131375031_3500_1280x720_029.ts
#EXTINF:6.007056,
131375031_3500_1280x720_030.ts
#EXTINF:6.015211,
131375031_3500_1280x720_031.ts
#EXTINF:6.023378,
131375031_3500_1280x720_032.ts
#EXTINF:6.005422,
131375031_3500_1280x720_033.ts
#EXTINF:6.013578,
131375031_3500_1280x720_034.ts
#EXTINF:6.021744,
131375031_3500_1280x720_035.ts
#EXTINF:6.003789,
131375031_3500_1280x720_036.ts
#EXTINF:6.011944,
131375031_3500_1280x720_037.ts
#EXTINF:6.020111,
131375031_3500_1280x720_038.ts
#EXTINF:6.002156,
131375031_3500_1280x720_039.ts
#EXTINF:6.010322,
131375031_3500_1280x720_040.ts
#EXTINF:6.018478,
131375031_3500_1280x720_041.ts
#EXTINF:6.000522,
131375031_3500_1280x720_042.ts
#EXTINF:6.008689,
131375031_3500_1280x720_043.ts
#EXTINF:6.016844,
131375031_3500_1280x720_044.ts
#EXTINF:6.025011,
131375031_3500_1280x720_045.ts
#EXTINF:6.007056,
131375031_3500_1280x720_046.ts
#EXTINF:6.015211,
131375031_3500_1280x720_047.ts
#EXTINF:6.023378,
131375031_3500_1280x720_048.ts
#EXTINF:6.005422,
131375031_3500_1280x720_049.ts
#EXTINF:6.013578,
131375031_3500_1280x720_050.ts
#EXTINF:6.021744,
131375031_3500_1280x720_051.ts
#EXTINF:6.003789,
131375031_3500_1280x720_052.ts
#EXTINF:6.011944,
131375031_3500_1280x720_053.ts
#EXTINF:6.020111,
131375031_3500_1280x720_054.ts
#EXTINF:6.002156,
131375031_3500_1280x720_055.ts
#EXTINF:6.010322,
131375031_3500_1280x720_056.ts
#EXTINF:3.406233,
131375031_3500_1280x720_057.ts
#EXT-X-TARGETDURATION:7
#EXT-X-ENDLIST

However if I check the actual fragments using ffprobe it reports a
different length to in the m3u8

ffprobe 131375031_3500_1280x720_000.ts
ffprobe version N-45739-g04bf2e7 Copyright (c) 2007-2012 the FFmpeg
developers
  built on Oct 20 2012 13:34:12 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --enable-gpl --enable-libfaac --enable-libfdk-aac
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx
--enable-x11grab --enable-libx264 --enable-nonfree --enable-version3
  libavutil      51. 76.100 / 51. 76.100
  libavcodec     54. 67.100 / 54. 67.100
  libavformat    54. 33.100 / 54. 33.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.103 /  3. 19.103
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
[mpegts @ 0x17e6c20] max_analyze_duration 5000000 reached at 5015467
Input #0, mpegts, from '131375031_3500_1280x720_000.ts':
  Duration: 00:00:06.00, start: 0.000000, bitrate: 3038 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] /
0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 90k tbn, 48
tbc
    Stream #0:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 44100 Hz,
stereo, s16, 128 kb/s

If anyone is still reading down here next step I will have a look at
segment.c where I believe this is getting done.


On 6 December 2012 20:08, Christian Ebert <blacktrash at gmx.net> wrote:

> * Christian Ebert on Wednesday, December 05, 2012 at 23:59:53 +0000
> > * Christian Ebert on Wednesday, December 05, 2012 at 23:53:52 +0000
> >> ffprobe -show_frames test.ts 2>/dev/null | fgrep -B 14 -A 7 pict_type=I
> | head -45
> >> [FRAME]
> >> media_type=video
> >> key_frame=1
> >> pkt_pts=126000
> >> pkt_pts_time=1.400000
> >> pkt_dts=126000
> >> pkt_dts_time=1.400000
> >> pkt_duration=3600
> >> pkt_duration_time=0.040000
> >> pkt_pos=564
> >> width=512
> >> height=384
> >> pix_fmt=yuv420p
> >> sample_aspect_ratio=1:1
> >> pict_type=I
> >> coded_picture_number=0
> >> display_picture_number=0
> >> interlaced_frame=0
> >> top_field_first=0
> >> repeat_pict=0
> >> reference=0
> >> [/FRAME]
> >> --
> >> [FRAME]
> >> media_type=video
> >> key_frame=1
> >> pkt_pts=1026000
> >> pkt_pts_time=11.400000
> >> pkt_dts=1026000
> >> pkt_dts_time=11.400000
> >> pkt_duration=3600
> >> pkt_duration_time=0.040000
> >> pkt_pos=161116
> >> width=512
> >> height=384
> >> pix_fmt=yuv420p
> >> sample_aspect_ratio=1:1
> >> pict_type=I
> >> coded_picture_number=250
> >> display_picture_number=0
> >> interlaced_frame=0
> >> top_field_first=0
> >> repeat_pict=0
> >> reference=0
> >> [/FRAME]
> >>
> >> But the above makes this entry:
> >>
> >> #EXTINF:10.030933,
> >> test-000.ts
> >>
> >> even less understandable.
> >
> > Add this to the mix (first 2 audio, second 2 video):
> >
> > ffprobe -show_streams test-000.ts 2>/dev/null | fgrep duration
> > duration_ts=896400
> > duration=9.960000
> > duration_ts=900695
> > duration=10.007722
>
> What looks correct is the coded_picture_number: 0 and 250. So I
> assume -force_key_frames does its job.
>
> The rest of the output of ffprobe or the generated m3u8 gives the
> impression of a sort of random precision.
>
> c
> --
> \black\trash movie         _SAME  TIME  SAME  PLACE_
>  --->> http://www.blacktrash.org/underdogma/stsp.php
> \black\trash audio   _ANOTHER  TIME  ANOTHER  PLACE_
> --->> http://www.blacktrash.org/underdogma/atap.html
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>


More information about the ffmpeg-user mailing list