summaryrefslogtreecommitdiff
path: root/libavformat/hlsenc.c
Commit message (Collapse)AuthorAge
* 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.
* avformat/hlsenc: simplify code to pass s directlyLimin Wang2020-07-02
| | | | | Suggested-by: Nicolas George <george@nsup.org> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hlsenc: fix av_bprint_finalize() usageLimin Wang2020-07-02
| | | | | | | Don't need to do double check by the description of the API. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hlsenc: use proper error codesLimin Wang2020-07-02
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hlsenc: Always treat numbers as decimalAndreas Rheinhardt2020-06-15
| | | | | | | | | | | c801ab43c36e8c4f88121aa09af26c77bcbd671b caused a regression: The stream number is now parsed with strtoll without a fixed basis; as a consequence, the "010" in a variant stream mapping like "a:010" is now treated as an octal number (i.e. as eight, not ten). This was not intended and may break some scripts, so this commit restores the old behaviour. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc, hlsplaylist: CosmeticsAndreas Rheinhardt2020-05-28
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc: Avoid duplicating strings when parsingAndreas Rheinhardt2020-05-28
| | | | | | | | | | | | | | | | | | | Up until now, the HLS muxer uses av_strtok() to split an input string controlling parameters of the VariantStreams and then duplicates parts of this string containing parameters such as the language or the name of the VariantStream. But these parts are proper zero-terminated strings of their own that are never modified lateron, so one can simply use the substring as-is without creating a copy. This commit implements this. The same also happened for the string controlling the closed caption groups. Furthermore, add const to indicate that the pointers to these substrings are not used to modify them and also to indicate that these strings are not allocated on their own. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc: Don't unnecessarily duplicate baseurl stringAndreas Rheinhardt2020-05-28
| | | | | | | | Up until now, the HLS muxer duplicated a string for every VariantStream, although neither the original nor the copies are ever modified. So use the original directly and stop copying. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc: Don't segfault on uncommon namesAndreas Rheinhardt2020-05-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The parsing process of the AVOpt-enabled string controlling the mapping of input streams to variant streams is roughly as follows: Space and tab separate variant stream group maps while the entries in each variant stream group map are separated by ','. The parsing process of each variant stream group proceeded as follows: At first the number of occurences of "a:", "v:" and "s:" in each variant stream group is calculated so that one can can allocate an array of streams with this number of entries. Then the string is split along ',' and each substring is parsed. If such a substring starts with "a:", "s:" or "v:" it is treated as stream specifier and (if there is a correct number after ':') a stream of the variant stream is mapped to one of the actual input streams. Nothing actually guarantees that the number of streams allocated initially equals the number of streams that are mapped to an actual input stream. These numbers can differ if e.g. the name, the sgroup, agroup or ccgroup of the variant stream contain "a:", "s:" or "v:". The problem hereby is that the rest of the code presumes these numbers to be equal and segfaults if it isn't (because the corresponding input stream is NULL). This commit fixes this by modifying the initial counting process to only count occurences of "a:", "s:" or "v:" that are at the beginning or that immediately follow a ','. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc: free options fix memleak in hls_write_trailerSteven Liu2020-05-12
| | | | Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* avformat/hlsenc: fix filename memleak in hls_write_packetSteven Liu2020-05-12
| | | | Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* avformat/hlsenc: move number out of hls_startSteven Liu2020-05-12
| | | | Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* avformat/hlsenc: Simplify setting base_output_dirnameAndreas Rheinhardt2020-05-10
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc: Simplify setting basename with av_asprintf()Andreas Rheinhardt2020-05-10
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc: Simplify setting subtitle basename with av_asprintfAndreas Rheinhardt2020-05-10
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hlsenc: Don't cast const awayAndreas Rheinhardt2020-05-10
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>