Commit Graph

326 Commits

Author SHA1 Message Date
Steven Liu
55affd95bd avformat/hlsenc: fix ticket id 5988 for DISCONTINUITY
add EXT-X-DISCONTINUITY tag at the position of the append point.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2016-12-05 17:55:33 +08:00
Robert Nagy
c0dc9df2cc increment initial_prog_date_time when removing old segments
Fixes https://trac.ffmpeg.org/ticket/5940#ticket

Reviewed-by: Michael Niedermayer <<michael@niedermayer.cc>>
Signed-off-by: Robert Nagy <ronag89@gmail.com>
Signed-off-by: Steven Liu <lingjiujianke@gmail.com>
2016-11-12 17:15:28 +08:00
Michael Niedermayer
2b09a3ad19 Revert "img2 encoder: allow %t in filename, based on patch from Yuval Adam"
breaks API

Found-by: jamrial
This reverts commit 1a956c64c8.
2016-11-01 23:03:24 +01:00
rogerdpack
1a956c64c8 img2 encoder: allow %t in filename, based on patch from Yuval Adam
Signed-off-by: rogerdpack <rogerpack2005@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-11-01 22:29:23 +01:00
Moritz Barsnick
468c596a31 lavf: fix typos
Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-09 20:09:00 +02:00
Steven Liu
be1d32492e avformat/hlsenc: support multi level path in m3u8 with filename
before patch:

localhost:osx liuqi$ tree 20160926/
20160926/
└── file-20160909
    └── 26
        └── 16
            └── 15
                ├── 46
                │   ├── 13.ts
                │   ├── 25.ts
                │   ├── 36.ts
                │   ├── 45.ts
                │   └── 54.ts
                └── 47
                    ├── 04.ts
                    ├── 14.ts
                    ├── 24.ts
                    └── 35.ts

6 directories, 9 files
localhost:osx liuqi$ cat out.m3u8
 #EXTM3U
 #EXT-X-VERSION:3
 #EXT-X-TARGETDURATION:12
 #EXT-X-MEDIA-SEQUENCE:0
 #EXTINF:11.360000,
 13.ts
 #EXTINF:10.800000,
 25.ts
 #EXTINF:9.120000,
 36.ts
 #EXTINF:8.760000,
 45.ts
 #EXTINF:10.200000,
 54.ts
 #EXTINF:10.720000,
 04.ts
 #EXTINF:9.600000,
 14.ts
 #EXTINF:10.600000,
 24.ts
 #EXTINF:8.760000,
 35.ts
 #EXT-X-ENDLIST

after patch:

localhost:osx liuqi$ tree 20160926/
20160926/
└── file-20160909
    └── 26
        └── 16
            └── 15
                ├── 46
                │   ├── 13.ts
                │   ├── 25.ts
                │   ├── 36.ts
                │   ├── 45.ts
                │   └── 54.ts
                └── 47
                    ├── 04.ts
                    ├── 14.ts
                    ├── 24.ts
                    └── 35.ts

6 directories, 9 files
localhost:osx liuqi$ cat out.m3u8
 #EXTM3U
 #EXT-X-VERSION:3
 #EXT-X-TARGETDURATION:12
 #EXT-X-MEDIA-SEQUENCE:0
 #EXTINF:11.360000,
 20160926/file-20160909/26/16/15/46/13.ts
 #EXTINF:10.800000,
 20160926/file-20160909/26/16/15/46/25.ts
 #EXTINF:9.120000,
 20160926/file-20160909/26/16/15/46/36.ts
 #EXTINF:8.760000,
 20160926/file-20160909/26/16/15/46/45.ts
 #EXTINF:10.200000,
 20160926/file-20160909/26/16/15/46/54.ts
 #EXTINF:10.720000,
 20160926/file-20160909/26/16/15/47/04.ts
 #EXTINF:9.600000,
 20160926/file-20160909/26/16/15/47/14.ts
 #EXTINF:10.600000,
 20160926/file-20160909/26/16/15/47/24.ts
 #EXTINF:8.760000,
 20160926/file-20160909/26/16/15/47/35.ts
 #EXT-X-ENDLIST

Signed-off-by: Steven Liu <lingjiujianke@gmail.com>
2016-10-04 06:41:53 +08:00
Steven Liu
0d2dd5d96d avformat/hlsenc: support mkdir_p for use_localtime_mkdir
when use use_localtime_mkdir to create multi level dir,
ffmpeg give error message:
ffmpeg -re -i ~/Movies/objectC/facebook.mp4 -c copy -use_localtime 1
 -use_localtime_mkdir 1 -hls_segment_filename '%Y%m%d/file-%Y%m%d/%s.ts'
out.m3u8
error message:
Could not create directory 20160926/file-20160926 with use_localtime_mkdir
add mkdir_p for support the multi level dir

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Tested-by: Zuo Genyu <1515161258@qq.com> (Windows)
Signed-off-by: Steven Liu <lingjiujianke@gmail.com>
2016-10-01 05:37:19 +08:00
Steven Liu
1212e3468e avformat/hlsenc: refine EXT-X-BYTERANGE support for segments
refine EXT-X-BYTERANGE tag,
the spec link:
https://tools.ietf.org/html/draft-pantos-http-live-streaming-19#section-4.3.2.2
the apple doc:
https://developer.apple.com/library/ios/technotes/tn2288/_index.html#
//apple_ref/doc/uid/DTS40012238-CH1-BYTE_RANGE_SUPPORT_FOR_SEGMENTS

command line:
./ffmpeg -i ~/Movies/objectC/a.mp4 -c copy -f hls -hls_time 7
 -hls_list_size 0 -hls_segment_size 2500000 -t 40 output-test.m3u8
output:
localhost:ffmpeg liuqi$ ll *.ts ;cat output-test.m3u8
 -rw-r--r--  1 liuqi  staff  2792176  9 12 14:44 output-test0.ts
 -rw-r--r--  1 liuqi  staff  3112528  9 12 14:44 output-test3.ts
 -rw-r--r--  1 liuqi  staff  3377420  9 12 14:44 output-test6.ts
 -rw-r--r--  1 liuqi  staff  1228016  9 12 14:44 output-test7.ts
 #EXTM3U
 #EXT-X-VERSION:4
 #EXT-X-TARGETDURATION:10
 #EXT-X-MEDIA-SEQUENCE:0
 #EXTINF:9.021000,
 #EXT-X-BYTERANGE:1334988@0
 output-test0.ts
 #EXTINF:3.000000,
 #EXT-X-BYTERANGE:721356@1334988
 output-test0.ts
 #EXTINF:3.000000,
 #EXT-X-BYTERANGE:735832@2056344
 output-test0.ts
 #EXTINF:6.000000,
 #EXT-X-BYTERANGE:1645940@0
 output-test3.ts
 #EXTINF:3.000000,
 #EXT-X-BYTERANGE:715152@1645940
 output-test3.ts
 #EXTINF:3.000000,
 #EXT-X-BYTERANGE:751436@2361092
 output-test3.ts
 #EXTINF:9.000000,
 #EXT-X-BYTERANGE:3377420@0
 output-test6.ts
 #EXTINF:3.960000,
 #EXT-X-BYTERANGE:1228016@0
 output-test7.ts
 #EXT-X-ENDLIST
 localhost:ffmpeg liuqi$

 ticket-id: #5839

Signed-off-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-24 04:28:02 +02:00
Michael Niedermayer
6f062eb8d0 avformat/hlsenc: Emulate strftime("%z") using other functions if it does not work
This should fix the code on windows

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-15 02:31:42 +02:00
Michael Niedermayer
9f18a970b2 avformat/hlsenc: Assume UTC if "%z" is unsupported in strftime()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-13 23:44:35 +02:00
Michael Niedermayer
22ba9a3cb8 avformat/hlsenc: Avoid "%T" "%F" in strftime() to improve compatibility
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-13 23:44:35 +02:00
Michael Niedermayer
2793ebd6cb avformat/hlsenc: implement program_date_time
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-08 02:22:21 +02:00
Franklin Phillips
cefce6e2c1 avformat/hlsenc: fix incomplete write of subtitle HLS playlist
This patch is a fix for the bug with ticket number 5812
(https://trac.ffmpeg.org/ticket/5812).

Basically, the bug is that the last segment and the "#EXT-X-ENDLIST"
tag are not being written to the subtitle playlist file when
converting a file with subtitles to the HLS format. The reason for
this seem to be that the filename for the subtitle file is being freed
too early. This solution is simply to free that memory after it's last
use in the "hls_window" function.

Signed-off-by: Franklin Phillips <franklinphillips9p8@inbox.lv>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-05 08:52:28 +02:00
Steven Liu
3aab6fa6ba avformat/hlsenc: add warning for append_list and hls_init_time option
When use append_list mode, the hls_init_time set nouse,
Because the append_list only support append at the old m3u8 end
cannot set init segments durations at the middle of the list.
That's invalid. and show a warning message for user.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-31 02:48:39 +02:00
Steven Liu
557ad3a474 avformat/hlsenc: add option hls_init_time to set init hls window segment duration
recover segments duration time by hls_time after init hls window.
This is reuqested by Ibrahim Tachijian

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-29 14:54:27 +02:00
Steven Liu
445c30ba07 lavf/hlsenc: add append_list flag into hlsenc
When ffmpeg exit by exception, start a new ffmpeg will
cover the old segment list, add this flag can continue
append the new segments into old hls segment list

Signed-off-by: LiuQi <liuqi@gosun.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-21 14:55:27 +02:00
Michael Niedermayer
dd96a58473 avformat/hlsenc: Use AV_FRAME_FILENAME_FLAGS_MULTIPLE, support tee:
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-04 23:22:54 +02:00
Steven Liu
b45a976ed4 add split_by_time flag for support splite mpegts segment at non-keyframe
support split hls segment at duration set by hls_time

Signed-off-by: LiuQi <liuqi@gosun.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-11 12:20:40 +02:00
Derek Buitenhuis
6f69f7a8bf Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
  lavf: replace AVStream.codec with AVStream.codecpar

This has been a HUGE effort from:
    - Derek Buitenhuis <derek.buitenhuis@gmail.com>
    - Hendrik Leppkes <h.leppkes@gmail.com>
    - wm4 <nfxjfg@googlemail.com>
    - Clément Bœsch <clement@stupeflix.com>
    - James Almer <jamrial@gmail.com>
    - Michael Niedermayer <michael@niedermayer.cc>
    - Rostislav Pehlivanov <atomnuker@gmail.com>

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-10 20:59:55 +01:00
Adam Kent
77e355ffb1 avformat/hlsenc: Add support for HLS PLAYLIST types EVENT and VOD
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-12 22:22:08 +01:00
Michael Niedermayer
b2ab3398f5 avformat/hlsenc: Fix passing options, regression since bc9a5965c8
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-11 00:45:28 +01:00
Anton Khirnov
9200514ad8 lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.

In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.

There are multiple important problems with this approach:
    - the fields in AVCodecContext are in general one of
        * stream parameters
        * codec options
        * codec state
      However, it's not clear which ones are which. It is consequently
      unclear which fields are a demuxer allowed to set or a muxer allowed to
      read. This leads to erratic behaviour depending on whether decoding or
      encoding is being performed or not (and whether it uses the AVStream
      embedded codec context).
    - various synchronization issues arising from the fact that the same
      context is used by several different APIs (muxers/demuxers,
      parsers, bitstream filters and encoders/decoders) simultaneously, with
      there being no clear rules for who can modify what and the different
      processes being typically delayed with respect to each other.
    - avformat_find_stream_info() making it necessary to support opening
      and closing a single codec context multiple times, thus
      complicating the semantics of freeing various allocated objects in the
      codec context.

Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2016-02-23 17:01:58 +01:00
Johan Ström
6c31c99289 hlsenc: add use_localtime_mkdir option to automatically create time-based directory
Use with -use_localtime, and set -hls_segment_filename to a path which
contains a subdirectory i.e. /some/path/%Y%m%d/%Y%m%dT%H%M%S-%s.ts
This will mkdir the %Y%m%d-part of the path if it does not already
exist.
In addition, each filename in the playlist output will be prefixed with
this subdirectory (if playlist and segment shares the same base path).

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-17 16:17:58 +01:00
Michael Niedermayer
a73b23e3df avformat/hlsenc: Fix filename and options
Regression since bc9a5965c8

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-10 19:14:53 +01:00
Derek Buitenhuis
bc9a5965c8 Merge commit '9f61abc8111c7c43f49ca012e957a108b9cc7610'
This also deprecates our old duplicated callbacks.

* commit '9f61abc8111c7c43f49ca012e957a108b9cc7610':
  lavf: allow custom IO for all files

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-10 14:42:41 +00:00
Michael Niedermayer
fe3fed0b14 Update demuxers and protocols for protocol whitelist support
Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-02 04:16:50 +01:00
Anton Khirnov
9f61abc811 lavf: allow custom IO for all files
Some (de)muxers open additional files beyond the main IO context.
Currently, they call avio_open() directly, which prevents the caller
from using custom IO for such streams.

This commit adds callbacks to AVFormatContext that default to
avio_open2()/avio_close(), but can be overridden by the caller. All
muxers and demuxers using AVIO are switched to using those callbacks
instead of calling avio_open()/avio_close() directly.

(de)muxers that use the URLProtocol layer directly instead of AVIO
remain unconverted for now. This should be fixed in later commits.
2016-01-24 16:45:32 +01:00
Ganesh Ajjanagadde
18bc3dc768 lavf/hlsenc: replace round by lrint
Mainly cosmetic here.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-19 09:33:49 -08:00
Michael Niedermayer
c62d1780ff avformat/hlsenc: Check the return code of avformat_write_header()
Fixes: segfault
Fixes: Ticket5067

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-13 02:28:13 +01:00
Clément Bœsch
43ecec0f03 avformat: use AV_OPT_TYPE_BOOL in a bunch of places 2015-12-04 15:43:33 +01:00
Derek Buitenhuis
9ae73d0644 hlsenc: Only write PAT/PMT once per segment
This saves a lot of muxing overhead, especially on lower bitrate
segments.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2015-11-02 14:35:28 +00:00
DHE
76e3f8242d libavformat/hlsenc: Use of uninitialized memory unlinking old files
Fixes ticket#4900

Signed-off-by: DHE <git@dehacked.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-03 23:52:19 +02:00
Michael Niedermayer
8b47e10651 avformat/hlsenc: Fix the method command line parameter
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-14 21:07:37 +02:00
Michael Niedermayer
4cad4bd4ca avformat/hlsenc: Fix memleak of path
Fixes: CID1322343
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-03 11:28:29 +02:00
Michael Niedermayer
e3d8504fd0 avformat/hlsenc: Initialize vtt_oc to help static analyzers
This is also more robust in case it ever is used

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-03 11:28:29 +02:00
LiuQi
a4055d3e5d avformat/hlsenc: add a use_localtime option to expand the segment filename with localtime
test examples:

./ffmpeg -re -i ~/Movies/objectC/facebook.mp4 -v verbose -c copy -f hls -hls_segment_filename test-%s.ts -use_localtime 1 -bsf:v h264_mp4toannexb aaa.m3u8

[StevenLiu@localhost ffmpeg]$ cat aaa.m3u8;ll test-*.ts
test-1441052221.ts
test-1441052231.ts
test-1441052235.ts
test-1441052243.ts
test-1441052249.ts
-rw-r--r--  1 StevenLiu  staff  1310736  9  1 04:15 test-1441052131.ts
-rw-r--r--  1 StevenLiu  staff   495192  9  1 04:15 test-1441052141.ts
-rw-r--r--  1 StevenLiu  staff  1310736  9  1 04:17 test-1441052212.ts
-rw-r--r--  1 StevenLiu  staff  1067840  9  1 04:17 test-1441052221.ts
-rw-r--r--  1 StevenLiu  staff   235564  9  1 04:17 test-1441052231.ts
-rw-r--r--  1 StevenLiu  staff  1187220  9  1 04:17 test-1441052235.ts
-rw-r--r--  1 StevenLiu  staff   694848  9  1 04:17 test-1441052243.ts
-rw-r--r--  1 StevenLiu  staff   526588  9  1 04:17 test-1441052249.ts
[StevenLiu@localhost ffmpeg]$

./ffmpeg -re -i ~/Movies/objectC/facebook.mp4 -v verbose -c copy -f hls -hls_segment_filename test-%s.ts -use_localtime 1 -bsf:v h264_mp4toannexb aaa.m3u8

[StevenLiu@localhost ffmpeg]$ cat aaa.m3u8;ll aaa-*.ts
aaa-1441052417.ts
aaa-1441052427.ts
aaa-1441052437.ts
aaa-1441052440.ts
aaa-1441052449.ts
-rw-r--r--  1 StevenLiu  staff  1310736  9  1 04:19 aaa-1441052382.ts
-rw-r--r--  1 StevenLiu  staff   277300  9  1 04:19 aaa-1441052392.ts
-rw-r--r--  1 StevenLiu  staff  1310736  9  1 04:20 aaa-1441052417.ts
-rw-r--r--  1 StevenLiu  staff  1067840  9  1 04:20 aaa-1441052427.ts
-rw-r--r--  1 StevenLiu  staff   235564  9  1 04:20 aaa-1441052437.ts
-rw-r--r--  1 StevenLiu  staff  1187220  9  1 04:20 aaa-1441052440.ts
-rw-r--r--  1 StevenLiu  staff   338776  9  1 04:20 aaa-1441052449.ts
[StevenLiu@localhost ffmpeg]$

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-02 04:31:32 +02:00
Luca Barbato
2157df425b hlsenc: Support outputting specific versions
Right now only version 2 and version 3 are supported.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-08-25 19:43:58 +02:00
Luca Barbato
72839fce64 hlsenc: Use AV_TIME_BASE units for all the computations
Do not risk mixing different timebases.

CC: libav-stable@libav.org

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2015-08-16 19:02:16 +02:00
Michael Niedermayer
29a43bd588 avformat/hlsenc: Fix wording in comment
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-26 22:06:19 +02:00
Anshul Maheshwari
379ddc6af4 avformat/hlsenc: Add WebVtt support in hls
Signed-off-by: Anshul Maheshwari <er.anshul.maheshwari@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-26 05:59:43 +02:00
Christian Suloway
7e871d6999 avformat/hlsenc: removed empty/unused print_encryption_tag function
Signed-off-by: Christian Suloway <csuloway@globaleagleent.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-16 16:52:38 +02:00
Christian Suloway
907ac20aa2 avformat/hlsenc: added HLS encryption
Added HLS encryption with -hls_key_info_file <key_info_file> option. The
first line of key_info_file specifies the key URI written to the
playlist. The key URL is used to access the encryption key during
playback. The second line specifies the path to the key file used to
obtain the key during the encryption process. The key file is read as a
single packed array of 16 octets in binary format. The optional third
line specifies the initialization vector (IV) as a hexadecimal string to
be used instead of the segment sequence number (default) for encryption.
Changes to key_info_file will result in segment encryption with the new
key/IV and an entry in the playlist for the new key URI/IV.

Key info file format:
<key URI>
<key file path>
<IV> (optional)

Example key URIs:
http://server/file.key
/path/to/file.key
file.key

Example key file paths:
file.key
/path/to/file.key

Example IV:
0123456789ABCDEF0123456789ABCDEF

Example:
ffmpeg -f lavfi -i testsrc -c:v h264 -hls_key_info_file file.keyinfo
foo.m3u8

file.keyinfo:
http://server/file.key
/path/to/file.key
0123456789ABCDEF0123456789ABCDEF

Example shell script:
BASE_URL=${1:-'.'}
openssl rand 16 > file.key
echo $BASE_URL/file.key > file.keyinfo
echo file.key >> file.keyinfo
echo $(openssl rand -hex 16) >> file.keyinfo
ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags delete_segments \
  -hls_key_info_file file.keyinfo out.m3u8
--

Signed-off-by: Christian Suloway <csuloway@globaleagleent.com>
Signed-off-by: Dan Dennedy <dan@dennedy.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-16 03:25:31 +02:00
MrBoogs
4f2fcac290 avformat/hlsenc: do not append an endlist tag when the stream ends
Reviewed-by: Thomas Volkert <silvo@gmx.net>
2015-05-17 17:15:03 +02:00
MrBoogs
572a8292cb avformat/hlsenc: Add hls flag for starting a playlist with a discontinuity on startup
Reviewed-by: Thomas Volkert <silvo@gmx.net>
2015-05-17 17:14:00 +02:00
MrBoogs
8fd01b4a79 avformat/hlsenc: Add hls flag for rounding m3u8 durations to whole numbers, problems with floats on some devices
Reviewed-by: Thomas Volkert <silvo@gmx.net>
2015-05-17 17:11:44 +02:00
Michael Niedermayer
6c9537b807 avformat/hlsenc: Warn if a non file protocol is used
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-23 16:53:36 +01:00
Michael Niedermayer
e78a729163 avformat/hlsenc: Use ff_rename() only for local files
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-21 01:50:26 +01:00
Hendrik Leppkes
da97e4c64a hlsenc: write playlist into a temp file and replace the original atomically
Reviewed-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-21 01:50:06 +01:00
Hendrik Leppkes
3fe26bb608 hlsenc: write playlist into a temp file and replace the original atomically
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-20 23:55:28 +02:00
Hendrik Leppkes
ff48ae94f9 hlsenc: remove the AVIOContext for the playlist from the muxer context
Its only used in one function, having it in the context serves no purpose.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-20 23:55:27 +02:00
Hendrik Leppkes
28bf05e7b5 hlsenc: remove the AVIOContext for the playlist from the muxer context
Its only used in one function, having it in the context serves no purpose.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-20 13:13:19 +01:00
Michael Niedermayer
aa6545e1f3 avformat/hlsenc: more robust error tests
errors are negative throughout ffmpeg

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-11 05:17:44 +01:00
Michael Niedermayer
bf3126db6a avformat/hlsenc: Use avio_closep() to avoid leaving stale pointers in memory
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-08 14:51:04 +01:00
Michael Niedermayer
b8eb8b0310 avformat/hlsenc: Use av_freep() to avoid leaving stale pointers in memory
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-16 15:37:04 +01:00
Christian Suloway
92a596f13b avformat/hlsenc: fix hls_write_trailer() on hls_start() failure
Close segment I/O context and append segment in hls_write_trailer() only
when segment I/O context is allocated.

Signed-off-by: Christian Suloway <csuloway@globaleagleent.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-16 03:57:58 +01:00
Christian Suloway
97b65f6126 avformat/hlsenc: added segment file deletion
This option flag deletes segment files removed from the playlist after a
period of time equal to the duration of the segment plus the duration of
the playlist.

Signed-off-by: Christian Suloway <csuloway@globaleagleent.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-10 23:49:25 +01:00
Christian Suloway
1c639fa6e0 avformat/hlsenc: added segment filename option
This option allows segment filenames to be specified. Unless -hls_flags
single_file is set the filename is used as a string format with the
segment number.

Example:
ffmpeg -f lavfi -i testsrc -c:v h264 -map 0 -hls_segment_filename
bar%03d.ts foo.m3u8

Signed-off-by: Christian Suloway <csuloway@globaleagleent.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-06 02:28:23 +01:00
Michael Niedermayer
530eb6acf8 avformat/hlsenc: Free context after hls_append_segment
Fixes reading uninitialized memory

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-16 04:32:54 +01:00
Mika Raento
75c8d7c2b4 hlsenc.c, segment.c: propagate defaults to mpegts
This fixes the abnormally high ts overhead in the files produced by the
HLS and segments muxers. See https://trac.ffmpeg.org/ticket/2857 . For
example makes it much more likely that it can produces streams that fit
under the 64kb App store limit.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-17 21:31:25 +02:00
Michael Niedermayer
3726d07a2a Merge commit '28816050e47b6dba430a52e429d21a864cffda8e'
* commit '28816050e47b6dba430a52e429d21a864cffda8e':
  lavf: Set the stream time base hint properly for chained muxers

Conflicts:
	libavformat/segment.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-07 02:51:08 +02:00
Martin Storsjö
28816050e4 lavf: Set the stream time base hint properly for chained muxers
This avoids warnings about using the codec time base as time
base hint.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-06 23:30:52 +03:00
Michael Niedermayer
883bc7d2e7 Merge commit '55f03d872640175a00bfa262da4652b7312b905f'
* commit '55f03d872640175a00bfa262da4652b7312b905f':
  hlsenc: Add parameter -hls_allow_cache

Conflicts:
	doc/muxers.texi
	libavformat/hlsenc.c
	libavformat/version.h

See: 3edb9aaea6
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-03 21:46:40 +02:00
Joakim Roubert
55f03d8726 hlsenc: Add parameter -hls_allow_cache
The -hls_allow_cache parameter enables explicitly setting the
EXT-X-ALLOW-CACHE tag in the manifest file. That tag indicates
whether the client MAY or MUST NOT cache downloaded media
segments for later replay.

Valid values are 1 (=YES) or 0 (=NO) and the EXT-X-ALLOW-CACHE
will not show in the manifest for other values (or if
-hls_allow_cache is not used.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-10-03 20:20:28 +03:00
Michael Niedermayer
3f5095f213 avformat/hlsenc: fix outter typo
Found-by: beastd
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-29 00:19:43 +02:00
Michael Niedermayer
b1a0fccd02 avformat/hlsenc: export inner muxer timebase
Fixes "Non-monotonous DTS in output stream 0:0"
Fies Ticket 3797

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-28 22:27:33 +02:00
Joakim Roubert
3edb9aaea6 avformat/hlsenc: Added parameter -hls_allow_cache
The -hls_allow_cache parameter enables explicitly setting the
EXT-X-ALLOW-CACHE tag in the manifest file. That tag indicates
whether the client MAY or MUST NOT cache downloaded media
segments for later replay.

Valid values are 1 (=YES) or 0 (=NO) and the EXT-X-ALLOW-CACHE
will not show in the manifest for other values (or if
-hls_allow_cache is not used.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-28 03:09:05 +02:00
Steven Liu
2c21e8b1a4 lavf/hls: add hls_ts_option
Same as COMMITID 4f5493fe23.

Signed-off-by: Stefano Sabatini <stefasab@gmail.com>
2014-09-16 16:30:03 +02:00
Mika Raento
f685f7d7a8 hlsenc: single_file, support HLS ver 4 byteranges
This adds a new option -hls_flags single_file that creates one .ts file
for HLS and adds byteranges to the .m3u8 file, instead of creating one
.ts file for each segment.

This is helpful at least for storing large number of videos, as the
number of files per video is drastically reduced and copying and storing
those files takes less requests and inodes.

This is based on work by Nicolas Martyanoff, discussed on ffmpeg-devel
in July 2014. That patch seems abandoned by the author, and contained
unrelated changes. This patch tries to add the minimum amount of code to
support the byterange playlists.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-15 22:16:44 +02:00
Nicolas Martyanoff
467e9d6186 avformat/hlsenc: add some empty lines to make the code easier to read
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-31 00:33:49 +02:00
Nicolas Martyanoff
706fcffce1 avformat/hlsenc: rename some identifers to make the code easier to read
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-31 00:31:49 +02:00
Nicolas Martyanoff
53f10e0368 avformat/hlsenc: Add some comments to make the code easier to read
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-31 00:04:05 +02:00
Nicolas Martyanoff
0c889da8cb avformat/hlsenc: fix cleanup after avformat_write_header()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-29 16:24:11 +02:00
Michael Niedermayer
351b22caae avformat/mux: support re-interleaving packets in ff_write_chained()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-24 22:39:22 +02:00
Nicolas Martyanoff
6cc1fec412 avformat/hlsenc: correctly compute target duration
With HLS, the duration of all segments must be lower or equal to the target
duration. Therefore floor(duration + 0.5) yields incorrect results.

For example, for duration = 1.35, floor(duration + 0.5) yields 1.0, but the
correct result is 2.0.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
2014-07-10 01:31:04 +03:00
Michael Niedermayer
be8f96e5eb Merge commit '34e2ce5dde073244ccb2b62f930e96fe612690f7'
* commit '34e2ce5dde073244ccb2b62f930e96fe612690f7':
  hlsenc: Set the default codecs to AAC and H264

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-17 03:13:05 +02:00
Martin Storsjö
34e2ce5dde hlsenc: Set the default codecs to AAC and H264
Most HLS implementation only support these codecs.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-05-17 01:34:16 +03:00
Michael Niedermayer
554a1ecab7 Merge commit '7266e24f176389d2e81bfc7c829934f7c8ae361c'
* commit '7266e24f176389d2e81bfc7c829934f7c8ae361c':
  hls: Sync the file number with the start sequence

Conflicts:
	libavformat/hlsenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-30 21:29:04 +02:00
Michael Niedermayer
5b4c8aac97 Merge commit 'a16431034d9bd44182bf844d6bbde2c98bc4e6b5'
* commit 'a16431034d9bd44182bf844d6bbde2c98bc4e6b5':
  hls: Factor the sequence computation

Conflicts:
	libavformat/hlsenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-30 21:14:56 +02:00
Michael Niedermayer
8522dd380b Merge commit 'c7603b3c243331057300337a61464e6ac4a605cb'
* commit 'c7603b3c243331057300337a61464e6ac4a605cb':
  hls: Print start_number as first sequence value

Conflicts:
	libavformat/hlsenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-30 20:52:58 +02:00
Michael Niedermayer
f21f969a3f Merge commit '344f7b5a7e0d50573dec402dfe6228676f3889d9'
* commit '344f7b5a7e0d50573dec402dfe6228676f3889d9':
  hls: Report the current media sequence

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-30 20:03:06 +02:00
Luca Barbato
7266e24f17 hls: Sync the file number with the start sequence 2014-04-30 17:52:49 +02:00
Luca Barbato
a16431034d hls: Factor the sequence computation 2014-04-30 17:52:33 +02:00
Luca Barbato
c7603b3c24 hls: Print start_number as first sequence value
The option now behaves as expected.
2014-04-30 17:52:17 +02:00
Luca Barbato
344f7b5a7e hls: Report the current media sequence
Useful for debugging mostly.
2014-04-30 17:51:50 +02:00
Michael Niedermayer
217f6c53e5 Merge commit '5a70a783f04919514efec7751d710b64d8975fd7'
* commit '5a70a783f04919514efec7751d710b64d8975fd7':
  hls: Add an option to prepend a baseurl to the playlist entries

Conflicts:
	doc/muxers.texi
	libavformat/hlsenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-29 16:37:22 +02:00
Luca Barbato
5a70a783f0 hls: Add an option to prepend a baseurl to the playlist entries
Useful to generate playlists with absolute paths.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2014-04-29 12:14:11 +02:00
Michael Niedermayer
f359bac27c avformat/hlsenc: remove unneeded l prefix from %lf
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-03 00:27:53 +02:00
Senthilnathan M
96b8e7a9cd hlsenc: added floating point time support.
Necessary for HLS version 3 and above.  Fixes ticket #3505.

Signed-off-by: Senthilnathan M <senthil.codr@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-02 23:06:21 +02:00
Senthilnathan M
561bfce203 HLS: Handle the case when hls_list_size=0. Playlist file should contain all the segments. Fixes bug #3376.
Signed-off-by: Senthilnathan M <senthil.codr@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-01 15:13:23 +01:00
Michael Niedermayer
d780fdb904 avformat/hlsenc: copy metadata
Fixes Ticket2296

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-12 18:41:39 +01:00
Michael Niedermayer
ccdfa3e271 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  Add missing #includes for *INT64_MAX and *INT64_C

Conflicts:
	ffmpeg.c
	ffmpeg_filter.c
	ffplay.c
	libavformat/assdec.c
	libavformat/avidec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-24 05:21:19 +01:00
Diego Biurrun
8f8bc92365 Add missing #includes for *INT64_MAX and *INT64_C 2013-11-23 21:55:52 +01:00
Michael Niedermayer
50c0837801 Merge commit '09c93b1b957f2049ea5fd8fb0e6f4d82680172f2'
* commit '09c93b1b957f2049ea5fd8fb0e6f4d82680172f2':
  hlsenc: Append the last incomplete segment when closing the output

Conflicts:
	libavformat/hlsenc.c

See: 4630dfd1eb
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-16 14:03:44 +02:00
Carl Eugen Hoyos
9d86bfc259 hlsenc: Don't reset the number variable when wrapping
The counter itself shouldn't be wrapped, since it is used for
determining end_pts for the next segment - only wrap the number
used for the segment file name.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-08-15 22:41:19 +03:00
Stefano Sabatini
09c93b1b95 hlsenc: Append the last incomplete segment when closing the output
Also avoid comparing NOPTS values.

Bug-id: 551
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-08-15 22:41:18 +03:00
Carl Eugen Hoyos
75b9fb27f5 lavf/hlsenc: fix bogus hls segment index rewrapping logic
The counter should not be reset since it detects the
hls segment increasing timeframe.

Fixes ticket #2643.

Reviewed-by: Stefano Sabatini
2013-06-06 12:09:38 +02:00
Michael Niedermayer
54056c1493 Merge commit 'cf679b9476727a237c8006c685ace18acba149ab'
* commit 'cf679b9476727a237c8006c685ace18acba149ab':
  hls, segment: fix splitting for audio-only streams.

Conflicts:
	libavformat/hlsenc.c
	libavformat/segment.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-28 11:48:40 +02:00
Anton Khirnov
cf679b9476 hls, segment: fix splitting for audio-only streams.
CC:libav-stable@libav.org
2013-04-27 10:19:04 +02:00
Stefano Sabatini
4630dfd1eb lavf/hlsenc: append last incomplete segment when closing the output
Also introduce missing check on PTS value in case of NOPTS value.
2013-01-21 19:21:21 +01:00
Michael Niedermayer
aed58f6aae Merge commit '92e354b655613b88c3c202a7e19e7037daed37eb'
* commit '92e354b655613b88c3c202a7e19e7037daed37eb':
  rtpdec_vp8: Set the timestamp when returning a deferred packet
  hlsenc: Make the start_number option set the right variable

Conflicts:
	libavformat/hlsenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-09 11:26:31 +01:00
Kanglin
ba8cb33273 hlsenc: Make the start_number option set the right variable
Signed-off-by: Martin Storsjö <martin@martin.st>
2013-01-08 17:33:56 +02:00
Michael Niedermayer
384dd9804d Merge commit '30a76487304e7250294c9c0e9fa179bf07fd822a'
* commit '30a76487304e7250294c9c0e9fa179bf07fd822a':
  hlsenc: make segment number unsigned
  hlsenc: make EXT-X-MEDIA-SEQUENCE always increase

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-30 14:21:55 +01:00
Michael Niedermayer
56c71cd599 Merge commit '9b1370aced385698bc783747917544ab69ecb373'
* commit '9b1370aced385698bc783747917544ab69ecb373':
  hlsenc: do not add timestamps in different timebases
  hlsenc: use the correct AV_TIME_BASE macro

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-30 14:11:17 +01:00
Michael Niedermayer
19e1c8e4f2 Merge commit '0448f26c97c5ab4858d31e456a4f1738ae783242'
* commit '0448f26c97c5ab4858d31e456a4f1738ae783242':
  hlsenc: keep the playlist to the correct number of items
  hlsenc: use the segment filename in the playlist entry

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-30 14:02:19 +01:00
Michael Niedermayer
2ce43b37fc Merge commit '6dd93ee6f1b050ad7c4b247899e83efa293ee405'
* commit '6dd93ee6f1b050ad7c4b247899e83efa293ee405':
  hlsenc: check append_entry return value
  hlsenc: use the basename to generate the list entries
  avstring: add av_basename and av_dirname

Conflicts:
	Changelog
	doc/APIchanges
	libavutil/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-30 13:54:50 +01:00
Luca Barbato
30a7648730 hlsenc: make segment number unsigned
It will overflow if somebody keeps streaming for a time long enough.
2012-12-29 17:26:30 +01:00
Luca Barbato
9b1370aced hlsenc: do not add timestamps in different timebases
start_time is in stream timebase units while end_time is
in AV_TIME_BASE ones.
2012-12-29 17:26:30 +01:00
Luca Barbato
0448f26c97 hlsenc: keep the playlist to the correct number of items
Consider the corner case with a list size larger than the wrap
number.
2012-12-29 17:26:30 +01:00
Kanglin
27a15e0af6 hlsenc: make EXT-X-MEDIA-SEQUENCE always increase 2012-12-29 17:26:30 +01:00
Kanglin
0d8cc7a3b2 hlsenc: use the correct AV_TIME_BASE macro
recording_time is in AV_TIME_BASE units.
2012-12-29 17:26:30 +01:00
Luca Barbato
6dd93ee6f1 hlsenc: check append_entry return value 2012-12-29 17:26:29 +01:00
Luca Barbato
ae85d6c9c0 hlsenc: use the segment filename in the playlist entry
Avoid calling av_get_frame_filename twice, once to generate the
segment filename and once to generate the playlist.
2012-12-29 17:26:29 +01:00
Luca Barbato
66f7b4862f hlsenc: use the basename to generate the list entries
The segment path is desumed from the playlist path, recording a
relative path in the playlist while serving the file could lead
to misleading results.
2012-12-29 17:26:29 +01:00
Michael Niedermayer
c6664242e0 Merge commit 'f5f1cf52240759208b42477e2157a7b4409ade10'
* commit 'f5f1cf52240759208b42477e2157a7b4409ade10':
  oggdec: K&R cosmetic formatting
  hlsenc: correctly report target duration

Conflicts:
	libavformat/oggdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-24 14:43:03 +01:00
Martin Storsjö
4a9f7d2bf9 hlsenc: Don't duplicate a string constant
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-12-24 00:02:48 +02:00
Stefano Sabatini
3193b13aa1 hlsenc: Allocate enough space for the pattern string
If s->filename doesn't contain any period/filename extension to strip
away, the buffer will be too small to fit both strings. This isn't
any buffer overflow since the concatenation uses av_strlcat with
the right buffer size.

Signed-off-by: Martin Storsjö <martin@martin.st>
2012-12-24 00:02:45 +02:00
Luca Barbato
7e98956e72 hlsenc: correctly report target duration 2012-12-23 12:13:41 +01:00
Stefano Sabatini
60c801c679 lavf/hlsenc: reuse pattern string, rather than redefining it
Improve robustness.
2012-12-22 22:02:06 +01:00
Stefano Sabatini
005b360b9c lavf/hlsenc: fix basename size computation off-by-one bug 2012-12-22 22:02:06 +01:00
Stefano Sabatini
340b7caf54 lavf/hlsenc: provide some feedback in case of invalid basename 2012-12-21 00:07:21 +01:00
Stefano Sabatini
28b96efab5 lavf/hlsenc: fix minor grammar inconsistencies in the option help messages 2012-12-21 00:07:13 +01:00
Michael Niedermayer
5de1f7a7bd Merge commit '18e6f087c4a50bede8449ee164778945480be50c'
* commit '18e6f087c4a50bede8449ee164778945480be50c':
  img2: document the options available
  hls: improve options description
  hls: use a meaningful long name
  hls: add start_number option
  h264: check for invalid zeros_left before writing

Conflicts:
	doc/demuxers.texi
	doc/muxers.texi

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-09 13:35:49 +01:00
Luca Barbato
adbe03077d hls: use a meaningful long name 2012-12-08 17:04:22 +01:00
Luca Barbato
5fbceb2c63 hls: add start_number option 2012-12-08 17:04:22 +01:00
Michael Niedermayer
e13d5e9a4b Merge commit '5e9c6ef8f3beb9ed7b271654a82349ac90fe43f2'
* commit '5e9c6ef8f3beb9ed7b271654a82349ac90fe43f2':
  x86: h264_weight_10bit: port to cpuflags
  libtheoraenc: add missing pixdesc.h header
  avcodec: remove ff_is_hwaccel_pix_fmt
  pixdesc: add av_pix_fmt_get_chroma_sub_sample
  hlsenc: stand alone hls segmenter

Conflicts:
	doc/muxers.texi
	libavcodec/ffv1enc.c
	libavcodec/imgconvert.c
	libavcodec/mpegvideo_enc.c
	libavcodec/tiffenc.c
	libavformat/Makefile
	libavformat/allformats.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-14 11:59:20 +01:00
Luca Barbato
22a0827dff hlsenc: stand alone hls segmenter
Simplifies usage but has higher latency.
2012-11-13 01:37:05 +01:00