summaryrefslogtreecommitdiff
path: root/libavformat/hlsenc.c
Commit message (Collapse)AuthorAge
* avcodec/defs: Add AV_PROFILE_* defines, deprecate FF_PROFILE_* definesAndreas Rheinhardt2023-09-07
| | | | | | | | | These defines are also used in other contexts than just AVCodecContext ones, e.g. in libavformat. Furthermore, given that these defines are public, the AV-prefix is the right one, so deprecate (and not just move) the FF-macros. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avformat: Avoid including codec.h, frame.hAndreas Rheinhardt2023-09-07
| | | | | | | | | | | | | | | | AVCodec is only ever used as an incomplete type (i.e. via a pointer to an AVCodec) in avformat.h and it is not really part of the core of avformat.h or libavformat; almost none of our internal users make use of it (and none make use of hwcontext.h, which is implicitly included). So switch to use struct AVCodec, but continue to include codec.h for external users for compatibility. Also, do the same for AVFrame and frame.h, which is implicitly included by codec.h (via lavu/hwcontext.h). Also, remove an unnecessary inclusion of <time.h>. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/hlsenc: use av_random_bytes() for generating AES128 keyMarton Balint2023-07-16
| | | | | | | | | av_random_bytes() can use OS provided strong random functions and does not depend soley on openssl/gcrypt external libraries. Fixes ticket #10441. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/hlsenc: fix CODECS attribute of H.264Zhao Zhili2023-06-12
| | | | | | | | 1. Add avcc extradata support. 2. Add non-standard annexb support with 0 0 1 as prefix for SPS. Reviewed-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avformat/hlsenc: hls_init_time should used in living stream modeSteven Liu2023-02-27
| | | | | | | When hls_init_time should available when hls_list_size > 0. Because the list will not refresh new top line segment when hls_list_size is 0 Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat: deprecate AVFormatContext io_close callbackMarton Balint2023-02-16
| | | | | | io_close2 should be used instead. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: remove FF_HLS_TS_OPTIONSJames Almer2023-02-09
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/avformat: Move AVOutputFormat internals out of public headerAndreas Rheinhardt2023-02-09
| | | | | | | | | | | | | | This commit does for AVOutputFormat what commit 20f972701806be20a77f808db332d9489343bb78 did for AVCodec: It adds a new type FFOutputFormat, moves all the internals of AVOutputFormat to it and adds a now reduced AVOutputFormat as first member. This does not affect/improve extensibility of both public or private fields for muxers (it is still a mess due to lavd). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Anton Khirnov <anton@khirnov.net>
* libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_fileBasel Sayeh2023-01-13
| | | | | | | | | | | Removed the unnecessary calls to ff_format_io_close this patch introduced in hls_delete_file. hls_delete_file functions open a new HTTP connection regardless of the http_persistent value, So change their behaviour to keep http connections open if http_persistent is set Signed-off-by: Basel Sayeh <basel.sayeh@hotmail.com>
* avformat/internal: Don't include avcodec.hAndreas Rheinhardt2022-09-26
| | | | | | | | | | | | | | | The general demuxing API uses parsers and decoders. Therefore FFStream contains pointers to AVCodecContexts and AVCodecParserContext and lavf/internal.h includes lavc/avcodec.h. Yet actually only a few files files really use these; and it is best when this number stays small. Therefore this commit uses opaque structs in lavf/internal.h for these contexts and stops including avcodec.h. This also avoids including lavc/codec_desc.h implicitly. All other headers are implicitly included as now (mostly through codec.h). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/hlsenc: Add resend_headers optionhuheng2022-06-29
| | | | | | | | | Add pat and pmt table at start of each segment in single_file mode enhanced compatibility of hls stream. Because some hls clients separate parsing segment of hls stream, the absence of pat/pmt will cause parsing to fail. Reviewed-by: Steven Liu <liuqi05@kuaishou.com> Signed-off-by: huheng <heng.hu.1989@gmail.com>
* avformat/hlsenc: Use HLS version 2 if rounded durations are enabledLucy2022-06-29
| | | | | | | | | | | | | | | | | This allows for wider compatibility with older devices, such as those running iOS 3. The only difference between HLS version 2 and version 3 is that version 3 supports non-integer EXTINF values, and as such, we can default to version 2 if we're using whole-integer EXTINFs anyways, when `-hls_flags round_durations` is set. As this code seems to otherwise consistently use the lowest compatible version, this seems to fit in properly with existing behavior. Testing confirms with that this patch, HLS output can work all the way back to iOS 3. Reviewed-by: Steven Liu <liuqi05@kuaishou.com> Signed-off-by: Lucy <lucy@absolucy.moe>
* avformat/hlsenc: check discont_program_date_time before use it in parse_playlistSteven Liu2022-05-12
| | | | | | | | | | Fix ticket: 9238 In parse_playlist, the discont_program_date_time should be used after EXT-X-PROGRAM-DATE-TIME tag parsed. Tested-by: pero Reviewed-by: Zhao Zhili <zhilizhao@tencent.com> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/internal: Move muxing-only functions to new mux.h headerAndreas Rheinhardt2022-05-10
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/hlsenc: remove unnecessary http/https shutdown status operateSteven Liu2022-05-07
| | | | | | | | | | Fix ticket: 9010 there have been get http/https shutdown status in ffurl_shutdown. so unnecessary http/https shutdown status operate. Tested-by: RytoEX Tested-by: ushadow Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-16
| | | | | | | | This avoids unnecessary rebuilds of most source files if only the list of enabled components has changed, but not the other properties of the build, set in config.h. Signed-off-by: Martin Storsjö <martin@martin.st>
* avformat/hlsenc: convey stream id to segment streamsGyan Doshi2022-01-09
|
* avformat/hlsenc: deprecate hls_ts_options optionSteven Liu2021-12-13
| | | | | | | Because the hls_ts_options will be misunderstand by user, and then user can use hls_segment_options instead of hls_ts_options. Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* avformat/hlsenc: add hls_segment_options correct the segment options nameSteven Liu2021-12-13
| | | | | | | Because the hls_ts_options will be misunderstand by user that only can be used in mpegts segments option. So add this option for segments. Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* avformat: introduce AVFormatContext io_close2 which returns an intMarton Balint2021-12-12
| | | | | | | | | | | | | | | | | Otherwise there is no way to detect an error returned by avio_close() because ff_format_io_close cannot get the return value. Checking the return value of the close function is important in order to check if all data was successfully written and the underlying close() operation was successful. It can also be useful even for read mode because it can return any pending AVIOContext error, so the user don't have to manually check AVIOContext->error. In order to still support if the user overrides io_close, the generic code only uses io_close2 if io_close is either NULL or the default io_close callback. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/utils: Make ff_data_to_hex() zero-terminate the stringAndreas Rheinhardt2021-12-08
| | | | | | Most callers want it that way anyway. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/hlsenc: Only write something if there is something to writeAndreas Rheinhardt2021-11-18
| | | | | | | | | | This is especially important in case avio_write() would be switched to an unsigned type like size_t, then a potential error from avio_read() (with negative return value) would no longer be handled gracefully by avio_write(). Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/hlsenc: Remove nonsense memsetAndreas Rheinhardt2021-11-18
| | | | | | | | | | | The memset here is both unnecessary (avio_read() ignores the previous content of the destination buffer) as well as nonsense (for a char buf[BUFSIZE] sizeof(buf) and sizeof(BUFSIZE) are not the same; the latter is sizeof(int)). Fixes Coverity issue #1465863. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/hlsenc: add const for filename argumentLimin Wang2021-09-29
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hlsenc: minus subtitle streams count when subtitle stream between ↵Steven Liu2021-08-19
| | | | | | | | | | | | | | | | | | video and audio streams because subtitles streams will be written to webvtt m3u8 list so the stream index should minus subtitles streams count when subtitle between audio and video streams. testcase: before patch: ffmpeg -i input -map 0:a:0 -map 0:s:0 -map 0:v:0 -f hls aaaa.m3u8 will EXC_BAD_ACCESS after patch: ffmpeg -i input -map 0:a:0 -map 0:s:0 -map 0:v:0 -f hls aaaa.m3u8 will ok Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* avformat/hlsenc: set http options before use delete http methodSteven Liu2021-08-19
| | | | | | | Fix ticket: 9338 Set options which set by user from parent options. Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* avformat/internal: Move ff_read_line_to_bprint_overwrite to avio_internal.hAndreas Rheinhardt2021-07-29
| | | | | | | | | | | | | It only uses an AVIOContext and an AVBPrint. When doing so, it turned out that several non-users of ff_read_line_to_bprint_overwrite() and ff_bprint_to_codecpar_extradata() relied on libavformat/internal.h to include bprint.h or avstring.h for them. In order to avoid a repeat of this and in order to reduce unnecessary dependencies, a forward declaration of struct AVBPrint is used instead of including bprint.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* libavformat/hlsenc: fix typos in commentsValerii Zapodovnikov2021-05-20
|
* Revert "avformat/hlsenc: compute video_keyframe_size after write keyframe"Steven Liu2021-05-15
| | | | | | | | | | | This reverts commit b5ca8f2c66954614d81579082025f580efc0cffc. This commit will make new problem about tickets: 9193,9205 It flush data into file with init file context together, and it can get keyframe size, maybe need more method to get keyframe size. Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* avformat/hlsenc: correct log text and supply packet detailsGyan Doshi2021-05-05
|
* avformat: Constify all muxer/demuxersAndreas Rheinhardt2021-04-27
| | | | | | | This is possible now that the next-API is gone. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/hlsenc: Remove deprecated localtime optionsAndreas Rheinhardt2021-04-27
| | | | | | | Deprecated in fbd8746efabe441469eb410d2ffa6af64987ca80. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/hlsenc: Remove deprecated wrap optionAndreas Rheinhardt2021-04-27
| | | | | | | Deprecated in d96ebc5ef88024869de06bcf92b2ad99b01d47e3. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: Constify the API wrt AV(In|Out)putFormatAndreas Rheinhardt2021-04-27
| | | | | | | Also constify AVProbeData. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/hlsenc: use AV_OPT_TYPE_DURATIONLimin Wang2021-02-02
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hlsenc: EXT-X-I-FRAMES-ONLY requires version 4 or higherZhao Zhili2021-01-24
|
* avformat/hlsenc: reindent the codeLimin Wang2021-01-16
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* hlsenc: expand hls_fmp4_init_filename with strftime()Nikola Pajkovsky2020-12-08
| | | | | | | | the init.mp4 can be expanded with strftime the same way as hls_segment_filename. Signed-off-by: Nikola Pajkovsky <nikola@pajkovsky.cz> Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
* avformat/hls: Fixes overwriting existing #EXT-X-PROGRAM-DATE-TIME value in ↵Vignesh Ravichandran2020-12-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | HLS playlist fix ticket: 8989 This is is due to the following behavior in the current code: 1. The initial_prog_date_time gets set to the current local time 2. The existing playlist (.m3u8) file gets parsed and the segments present are added to the variant stream 3. The new segment is created and added 4. The existing segments and the new segment are written to the playlist file. The initial_prog_date_time from point 1 is used for calculating "#EXT-X-PROGRAM-DATE-TIME" for the segments, which results in incorrect "#EXT-X-PROGRAM-DATE-TIME" values for existing segments The following approach fixes this bug: 1. Add a new variable "discont_program_date_time" of type double to HLSSegment struct 2. Store the "EXT-X-PROGRAM-DATE-TIME" value from the existing segments in this variable 3. When writing to playlist file if "discont_program_date_time" is set, then use that value for "EXT-X-PROGRAM-DATE-TIME" else use the value present in vs->initial_prog_date_time Signed-off-by: Vignesh Ravichandran <vignesh.ravichandran02@gmail.com> Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
* avformat/hlsenc: Fix check for SPSAndreas Rheinhardt2020-10-20
| | | | | | Check all the six bits, not only the two bits that are set for SPS. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc: Fix mixed declaration and codeAndreas Rheinhardt2020-10-20
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc: Don't use uninitialized buffer in av_stristr()Andreas Rheinhardt2020-10-20
| | | | | | Introduced in a2b1dd0ce301450a47c972745a6b33c4c273aa5d. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc: Fix extradata length checkAndreas Rheinhardt2020-10-20
| | | | | | | | | | | | | | | | | | | Commit a2b1dd0ce301450a47c972745a6b33c4c273aa5d added support for parsing annex B HEVC extradata to extract profile and level information. Yet it only checks for there to be enough data left for the startcode and the first byte of the NAL unit header and not for the full NAL unit header; it simply presumes the second byte of the NAL unit header to be present and skips it. Then the remaining size of the extradata is calculated which ends up negative if the second byte of the NAL unit header is not present. Yet when calling ff_nal_unit_extract_rbsp() it will be converted to an uint32_t and end up as UINT32_MAX which will cause mayhem. This is solved by making sure that there is always enough remaining extradata that could (pending 0x03 escapes) contain the data that we are interested in. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc: support CODECS Attribute in hevc EXT-X-STREAM-INFSteven Liu2020-10-20
| | | | | | | | | | | fix ticket: 8904 parse the SPS from extradata and get profile_tier_level write the profile_tier_level info into CODECS Attribute HLS CODECS Attribute reference to :https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices/hls_authoring_specification_for_apple_devices_appendixes Signed-off-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
* avformat/hlsenc: compute video_keyframe_size after write keyframeSteven Liu2020-10-20
| | | | | | | | | | | | | | fix ticket: 8636 When write keyframe and the keyframe is the frist packet of the segment, then compute the size of the keyframe which have been write into segment first packet. and set the start position of the segment, should not use avio_tell(vs->out) to get the keyframe position, because it can be set to 0 if close at above of the workflow, that maybe inaccurate, but the start_pos can be used here, because start_pos is set after write the previous packet. Signed-off-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
* avformat/hlsenc: process hls_time value too small senceSteven Liu2020-10-20
| | | | | | | | | | | | | | | | | The target duration will be a negative value when there are some b frames after prevous frame, the pts after current packet is large than the pts of current packet, so the target duration will compute as 0.040000 - 0.080000, then the value of the target duration will be -0.040000. so hls muxer should check the pts after current packet minus the pts of current packet, hls muxer can split the stream as a segment if the target duration is neither negative nor zero, hls muxer cannot split the stream as a segment if the target duration is either negative or zero then get the next packet until the target duration is not negative or zero. Signed-off-by: Steven Liu <lq@chinaffmpeg.org> Suggested-by: Zhili Zhao <quinkblack@foxmail.com> Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
* avformat/hlsenc: write temp file for append single file by encryption modeSteven Liu2020-08-10
| | | | | | | | | | | | fix ticket: 8783 Because in single file by encryption mode, it cannot get the last one block of the file, it need ff_format_io_close for get full file size, then hlsenc can get the total size of the encryption content, so write the content into temp file first, and get the temp file content append the temp file content into append to single file, then hlsenc can get the correct file/content size and offset. Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* avformat/hlsenc: increase initial program date time precisionMarton Balint2020-07-29
| | | | | | | | | Also query time only once, not for every variant stream, otherwise variant streams might get a slightly different initial program date time. And we can set this unconditionally because HLS_PROGRAM_DATE_TIME flag is checked elsewhere. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/hlsenc: check fragment size plus start_pos large than hls_segment_sizeSteven Liu2020-07-07
| | | | | | if vs->size + vs->start_pos > hls->max_seg_size, should split segment. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* libavformat/hlsenc: Remove duplicate close of the output stream.Andrey Semashev2020-07-06
| | | | | The result of the first close attempt is ignored and may be lost. By removing it we ensure the close result code is properly analyzed.