[FFmpeg-trac] #5811(avformat:reopened): live_start_index option doesn't work.
FFmpeg
trac at avcodec.org
Tue Aug 30 13:21:24 EEST 2016
#5811: live_start_index option doesn't work.
------------------------------------+------------------------------------
Reporter: smalukav | Owner:
Type: defect | Status: reopened
Priority: normal | Component: avformat
Version: git-master | Resolution:
Keywords: hls | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
------------------------------------+------------------------------------
Changes (by smalukav):
* status: closed => reopened
* resolution: worksforme =>
Comment:
Ok, just look what happens when you try to copy live hls stream.
Firstly, create live stream with option -re.
{{{
$ /opt/ffmpeg/bin/ffmpeg -re -i
http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_2160p_60fps_normal.mp4
-c copy -hls_time 10 -hls_list_size 0 hls_stream/stream.m3u8
ffmpeg version N-81495-g11a631d Copyright (c) 2000-2016 the FFmpeg
developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --extra-cflags=-I/opt/ffmpeg/include --extra-
ldflags=-L/opt/ffmpeg/lib --enable-rpath --prefix=/opt/ffmpeg
--toolchain=hardened --enable-shared --enable-gpl --enable-nonfree
--enable-openssl --enable-libass --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libx265 --enable-libebur128
libavutil 55. 29.100 / 55. 29.100
libavcodec 57. 54.101 / 57. 54.101
libavformat 57. 48.101 / 57. 48.101
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 58.100 / 6. 58.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
'http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_2160p_60fps_normal.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
creation_time : 2013-12-17T16:40:26.000000Z
title : Big Buck Bunny, Sunflower version
artist : Blender Foundation 2008, Janus Bager Kristensen 2013
comment : Creative Commons Attribution 3.0 -
http://bbb3d.renderfarming.net
genre : Animation
composer : Sacha Goedegebure
Duration: 00:10:34.53, start: 0.000000, bitrate: 8487 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
3840x2160 [SAR 1:1 DAR 16:9], 8002 kb/s, 60 fps, 60 tbr, 60k tbn, 120 tbc
(default)
Metadata:
creation_time : 2013-12-17T16:40:26.000000Z
handler_name : GPAC ISO Video Handler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo,
s16p, 160 kb/s (default)
Metadata:
creation_time : 2013-12-17T16:40:28.000000Z
handler_name : GPAC ISO Audio Handler
Stream #0:2(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side),
fltp, 320 kb/s (default)
Metadata:
creation_time : 2013-12-17T16:40:28.000000Z
handler_name : GPAC ISO Audio Handler
Side data:
audio service type: main
[hls @ 0xea7160] Using AVStream.codec to pass codec parameters to muxers
is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, hls, to 'hls_stream/stream.m3u8':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
composer : Sacha Goedegebure
title : Big Buck Bunny, Sunflower version
artist : Blender Foundation 2008, Janus Bager Kristensen 2013
comment : Creative Commons Attribution 3.0 -
http://bbb3d.renderfarming.net
genre : Animation
encoder : Lavf57.48.101
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 8002 kb/s, 60 fps, 60 tbr, 90k tbn,
120 tbc (default)
Metadata:
creation_time : 2013-12-17T16:40:26.000000Z
handler_name : GPAC ISO Video Handler
Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side),
320 kb/s (default)
Metadata:
creation_time : 2013-12-17T16:40:28.000000Z
handler_name : GPAC ISO Audio Handler
Side data:
audio service type: main
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:2 -> #0:1 (copy)
}}}
Stream created. Wait when ffmpeg transcribe to local live stream a lot of
segments.
{{{
$ cat hls_stream/stream.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:13
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:12.483333,
stream0.ts
#EXTINF:7.616667,
stream1.ts
#EXTINF:11.466667,
stream2.ts
#EXTINF:12.300000,
stream3.ts
#EXTINF:8.200000,
stream4.ts
#EXTINF:8.333333,
stream5.ts
#EXTINF:11.916667,
stream6.ts
#EXTINF:11.750000,
stream7.ts
#EXTINF:8.333333,
stream8.ts
#EXTINF:11.700000,
stream9.ts
#EXTINF:8.333333,
stream10.ts
#EXTINF:8.750000,
stream11.ts
#EXTINF:10.050000,
stream12.ts
#EXTINF:12.500000,
stream13.ts
#EXTINF:7.000000,
stream14.ts
#EXTINF:9.633333,
stream15.ts
#EXTINF:10.216667,
stream16.ts
#EXTINF:9.900000,
stream17.ts
#EXTINF:9.833333,
stream18.ts
#EXTINF:10.966667,
stream19.ts
#EXTINF:9.000000,
stream20.ts
#EXTINF:12.033333,
stream21.ts
}}}
And now try to copy local stream to new video starting from the first
segment.
{{{
$ /opt/ffmpeg/bin/ffmpeg -i hls_stream/stream.m3u8 -c copy
-live_start_index 0 -v 45 new_video.mp4
ffmpeg version N-81495-g11a631d Copyright (c) 2000-2016 the FFmpeg
developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --extra-cflags=-I/opt/ffmpeg/include --extra-
ldflags=-L/opt/ffmpeg/lib --enable-rpath --prefix=/opt/ffmpeg
--toolchain=hardened --enable-shared --enable-gpl --enable-nonfree
--enable-openssl --enable-libass --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libx265 --enable-libebur128
libavutil 55. 29.100 / 55. 29.100
libavcodec 57. 54.101 / 57. 54.101
libavformat 57. 48.101 / 57. 48.101
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 58.100 / 6. 58.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Splitting the commandline.
Reading option '-i' ... matched as input file with argument
'hls_stream/stream.m3u8'.
Reading option '-c' ... matched as option 'c' (codec name) with argument
'copy'.
Reading option '-live_start_index' ... matched as AVOption
'live_start_index' with argument '0'.
Reading option '-v' ... matched as option 'v' (set logging level) with
argument '99'.
Reading option 'new_video.mp4' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 99.
Successfully parsed a group of options.
Parsing a group of options: input file hls_stream/stream.m3u8.
Successfully parsed a group of options.
Opening an input file: hls_stream/stream.m3u8.
[hls,applehttp @ 0x1f92820] HLS request for url 'hls_stream/stream19.ts',
offset 0, playlist 0
[h264 @ 0x1fb59a0] Reinit context to 3840x2160, pix_fmt: yuv420p
Input #0, hls,applehttp, from 'hls_stream/stream.m3u8':
Duration: N/A, start: 191.736000, bitrate: N/A
Program 0
Metadata:
variant_bitrate : 0
Stream #0:0: Video: h264 (High), 1 reference frame ([27][0][0][0] /
0x001B), yuv420p, 3840x2160 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 90k tbn,
120 tbc
Metadata:
variant_bitrate : 0
Stream #0:1: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz,
5.1(side), fltp, 320 kb/s
Metadata:
variant_bitrate : 0
[mp4 @ 0x1fa62a0] Using AVStream.codec to pass codec parameters to muxers
is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
[mp4 @ 0x1fa62a0] track 1: codec frame size is not set
Output #0, mp4, to 'new_video.mp4':
Metadata:
encoder : Lavf57.48.101
Stream #0:0: Video: h264 (High), 1 reference frame ([33][0][0][0] /
0x0021), yuv420p, 3840x2160 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 60 fps, 60
tbr, 90k tbn, 90k tbc
Metadata:
variant_bitrate : 0
Stream #0:1: Audio: ac3 ([165][0][0][0] / 0x00A5), 48000 Hz,
5.1(side), 320 kb/s
Metadata:
variant_bitrate : 0
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[hls,applehttp @ 0x1f92820] HLS request for url 'hls_stream/stream20.ts',
offset 0, playlist 0
[hls,applehttp @ 0x1f92820] HLS request for url 'hls_stream/stream21.ts',
offset 0, playlist 0
[hls,applehttp @ 0x1f92820] HLS request for url 'hls_stream/stream22.ts',
offset 0, playlist 0
[hls,applehttp @ 0x1f92820] HLS request for url 'hls_stream/stream23.ts',
offset 0, playlist 0
[hls,applehttp @ 0x1f92820] HLS request for url 'hls_stream/stream24.ts',
offset 0, playlist 0
[hls,applehttp @ 0x1f92820] HLS request for url 'hls_stream/stream25.ts',
offset 0, playlist 0
[hls,applehttp @ 0x1f92820] HLS request for url 'hls_stream/stream26.ts',
offset 0, playlist 0
[hls,applehttp @ 0x1f92820] HLS request for url 'hls_stream/stream27.ts',
offset 0, playlist 0
}}}
Despite -live_start_index option, ffmpeg start reading only from segment
19, not the first segment.
And if you change in source code the default option value to 0 (start from
the first segment) and recompile ffmpeg, these commands will work as
expected.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/5811#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list