summaryrefslogtreecommitdiff
path: root/libavformat/flvenc.c
Commit message (Collapse)AuthorAgeFilesLines
* avformat/flvenc: avoid an extra allocateZhao Zhili2023-04-151-17/+13
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avformat/flvenc: use local variable to shorten codeZhao Zhili2023-04-151-4/+4
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avformat/flvenc: use extract_extradata bsf when necessaryZhao Zhili2023-04-091-4/+6
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avformat/flvenc: fix EOS tagZhao Zhili2023-02-191-3/+6
| | | | | | | | | | FLV spec only has AVC end of sequence tag, and the EOS tag has a CodecID as other video data packet. MPEG4 doesn't conformance to the spec, but it's there for a decade. So only 'fix' the EOS tag rather than remove it completely. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avformat/avformat: Move AVOutputFormat internals out of public headerAndreas Rheinhardt2023-02-091-10/+10
| | | | | | | | | | | | | | 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>
* avformat/flvenc: use av_dict_iterateMarvin Scholz2022-12-011-2/+2
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/internal: Don't include avcodec.hAndreas Rheinhardt2022-09-261-0/+1
| | | | | | | | | | | | | | | 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/flvenc: fix shadowed variable tsZhao Zhili2022-08-031-6/+3
|
* avformat/flvenc: fix timestamp of key frame indexZhao Zhili2022-08-031-4/+1
| | | | | | | | | Firstly, the timestamps generated from framerate are inaccurate for variable framerate mode. Secondly, the timestamps always start from zero, while pts/dts can start from nonzero. FLV demuxer rejects such index with message: "Found invalid index entries, clearing the index".
* avformat/flvenc: Add deinit functionAndreas Rheinhardt2022-07-091-14/+16
| | | | | | | | Fixes memleaks when the trailer is never written or when shift_data() fails when writing the trailer. Reviewed-by: Steven Liu <lingjiujianke@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Move ff_stream_add_bitstream_filter to mux.cAndreas Rheinhardt2022-05-101-2/+1
| | | | | | | It is muxing-only; in fact, it should be considered part of the core muxing code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* flv: convert to new channel layout APIVittorio Giovara2022-03-151-5/+5
| | | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/mpeg4audio: Unavpriv and deduplicate mpeg4audio_sample_ratesAndreas Rheinhardt2022-01-041-2/+2
| | | | | | | | | | | | | | | | | | | | | avpriv_mpeg4audio_sample_rates has a size of 64B and it is currently avpriv; a clone of it exists in aacenctab.h and from there it is inlined in aacenc.c (which also uses the avpriv version) and in the FLV muxer. This means that despite it being avpriv both libavformat as well as libavcodec have copies already. This situation is clearly suboptimal. Given the overhead of exporting symbols (for x64 Elf/Linux/GNU: 2x2B version, 2x24B .dynsym, 24B .rela.dyn, 8B .got, 4B hash + twice the size of the name (here 31B)) the object is unavprived, i.e. duplicated into libavformat when creating a shared build; but the duplicates in the AAC encoder and FLV muxer are removed. This involves splitting of the sample rate table into a file of its own; this allowed to break some spurious dependencies (e.g. both the AAC encoder as well as the Matroska demuxer actually don't need the mpeg4audio_get_config stuff). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/flvenc: use ff_format_shift_data for data shiftingMarton Balint2022-01-031-53/+6
| | | | | | add_keyframe_index seems to generate a corrupted index even before this change. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/flvenc: avoid 24bit timestamp truncation for FLV metadataasilvestre2021-11-291-2/+2
| | | | | | | | | | | | | | | | | FLV AMF tags have a 24bit field for timestamps plus an 8bit for extended timestamps. All FLV AMF tags except when we write metadata handle this correctly using the put_timestamp function. Until now when writing metadata we were only using the first 24 bits and thus the timestamp value was wraping around 4 hours 40 minutes (16,800,000 ms, max 24 bit value 16,777,216) of playback. This commit fixes this applying this same function put_timestamp for the metadata FLV tag. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/avformat: Add AVStream parameter to check_bitstream() sigAndreas Rheinhardt2021-11-271-2/+2
| | | | | | | | | | For most check_bitstream() functions this just avoids having to dereference s->streams[pkt->stream_index] themselves; but for meta-muxers it will allow to forward the packet to stream with a different stream_index (belonging to a different AVFormatContext) without using a spare packet. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: Constify all muxer/demuxersAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | 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>
* avutil/buffer: Switch AVBuffer API to size_tAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | Announced in 14040a1d913794d9a3fd6406a6d8c2f0e37e0062. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: use the buffer_size_t typedef where requiredJames Almer2021-03-101-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec, avformat: Remove unnecessary initializations of side data sizeAndreas Rheinhardt2020-06-221-1/+1
| | | | | Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/flvenc: Avoid unnecessary seekAndreas Rheinhardt2020-01-171-5/+2
| | | | | | | | | | | | | | When shifting the already written data in order to write the keyframe index, the flv muxer would first store the pre-shift size, then calculate how big the index will be eventually, then perform some seeks to update some size fields, then seek back to the end of the file to get the new position, followed by a seek to the position where writing will really start. Seeking back to the (already known) end position (that is actually used to perform this seek) to get the end position is of course unnecessary. It has been removed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flvenc: Fix leak of oversized packetsAndreas Rheinhardt2019-12-261-1/+2
| | | | | | | Might happen for annex B H.264. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flvenc: Forward errors from allocating keyframe indexAndreas Rheinhardt2019-12-261-7/+9
| | | | | | | | | | | While the function adding a new element to the keyframe index checked the allocation, the caller didn't check the return value. This has been changed. To do so, the return value has been changed to an ordinary ret instead of pb->error. This doesn't pose a problem, as write_packet() in mux.c already checks for write errors (since 9ad1e0c1). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flvenc: Don't reimplement ff_alloc_extradataAndreas Rheinhardt2019-12-111-7/+3
| | | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flvenc: Check pts for mpeg4/h264 (which need the value)Michael Niedermayer2019-11-091-0/+6
| | | | | | Fixes: Ticket8152 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/flvenc: Cosmetics: fix indentationJun Zhao2019-11-081-4/+4
| | | | | | fix indentation Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* lavf/flvenc: add automatic bitstream filteringJun Zhao2019-06-251-3/+24
| | | | | | | | add automatic bitstream filtering when mux AAC Reported-by: Yabo Wei weiyabogeijing@gmail.com Reviewed-by: Steven Liu<lq@onvideo.cn> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/flvenc: Check audio packet sizeMichael Niedermayer2018-08-041-0/+5
| | | | | | | | Fixes: Assertion failure Fixes: assert_flvenc.c:941_1.swf Found-by: #CHEN HONGXU# <HCHEN017@e.ntu.edu.sg> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* flvenc: Fix sequence header update timestampsAlex Converse2018-05-291-4/+4
|
* flvenc: Factorize timestamp writingAlex Converse2018-05-291-6/+9
| | | | | The code is trivial but the semantics in the spec are ambiguous. This should help keep parts of the muxer interpreting them consistently.
* avformat: migrate to AVFormatContext->urlMarton Balint2018-01-281-2/+2
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/flvenc: flx flvflags no_metadata bugSteven Liu2017-03-141-12/+14
| | | | | | | When use flvflags no_metadata , the FLV header will be cover by write tailer This commit fix the bug Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/flvenc: refine the flvenc shift_data codeSteven Liu2017-01-241-5/+7
| | | | | | refine the flvenc shift_data move data option Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/flvenc: Check for extradata allocation failureMichael Niedermayer2017-01-031-0/+4
| | | | | | Fixes CID1396539 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flvenc: fix ticket 5976 and use old commitSteven Liu2016-11-261-4/+7
| | | | | | | | | mythtv have problem with non-seekable dont write duration and filesize and there have problem with some other server and player with 0 value duation and filesize. So add a flv flags to fix the ticket and make a choose for users. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/flvenc: add no_metadata to flvflagsSteven Liu2016-11-221-1/+7
| | | | | | | some flv have no metadata, ffmpeg will same with the source flv stream. Signed-off-by: Steven Liu <lingjiujianke@gmail.com>
* avformat/flvenc: add add_keyframe_index optionSteven Liu2016-11-101-10/+321
| | | | | | | | | | | | | | | | | | | | | Add keyframe index metadata Used to facilitate seeking; particularly for HTTP pseudo streaming. 1. read live streaming or file by sequence 2. if use add_keyframe_index option, add a mark flag at the position, use to insert new context at the last step. 3. add the keyframes *offset* and *timestamp* into a list 4. if use add_keyframe_index option, shift the metadata data from mark flag offset 5. insert the keyframes *offset* and *timestamp* from the list by sequence 6. free the list 7. end. Add FATE test case; Reviewed-by: Lou Logan <lou@lrcd.com> Signed-off-by: Steven Liu <liuqi@gosun.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flvenc: support mp3 audio with 48khzfuqiuping2016-11-061-0/+9
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flvenc: do not attempt to write duration and filesize when not seekableSteven Liu2016-10-201-21/+28
| | | | | | | Its impossible to update the filesize & duration values if seekback is not possible as with live streams Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flvenc: add no_sequence_end flags for flvflagsSteven Liu2016-09-141-7/+13
| | | | | | | | | | when split flv file by flv format at first, and cat flvs file into one flv file, the flv sequence end is be used, then the whole flv have many flv sequence end TAG. this flags can give user an option to ignore write sequence end TAG Signed-off-by: Steven Liu <lingjiujianke@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flvenc: Add () around &Michael Niedermayer2016-09-141-1/+1
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flvenc: add FLVFlags for flvflags optionsSteven Liu2016-09-141-2/+6
| | | | | | | add FLVFlags type, be used to add new FLVFlags options Signed-off-by: Steven Liu <lingjiujianke@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit '371df9ba71393a1c5429d5f40c76348b30e556c7'Matthieu Bouron2016-06-231-0/+4
|\ | | | | | | | | | | | | * commit '371df9ba71393a1c5429d5f40c76348b30e556c7': flvenc: Provide output bytestream markers Merged-by: Matthieu Bouron <matthieu.bouron@stupeflix.com>
| * flvenc: Provide output bytestream markersMartin Storsjö2016-05-181-0/+4
| | | | | | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* | libavformat/flvenc: support for codec configuration change mid streamIvan2016-06-111-0/+13
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | libavformat/flvenc: refactoring: extracted method for writing codec headersIvan2016-06-111-52/+64
| | | | | | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit '9200514ad8717c63f82101dc394f4378854325bf'Derek Buitenhuis2016-04-101-95/+95
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
| * lavf: replace AVStream.codec with AVStream.codecparAnton Khirnov2016-02-231-76/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | avformat: use ff_standardize_creation_time for formats writing all format ↵Marton Balint2016-03-031-0/+1
| | | | | | | | | | | | | | string metadata Reviewed-by: wm4 <nfxjfg@googlemail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* | avformat/flvenc: copyts in FLV muxerIvan2016-01-261-1/+1
| | | | | | | | | | | | | | | | | | The purpose of this patch is to preserve timestamps when using ffmpeg for publishing RTMP streams, e.g. ffmpeg -i rtmp://source/stream -f flv rtmp://target/stream. There is a setting "copyts" for that purpose. Unfortunately it doesn't work with FLV muxer because it has its own timestamp correction which makes global setting "copyts" ineffective. This patch removes timestamp correction in FLV muxer. This means FLV will rely on ffmpeg timestamp correction which makes it possible to use copyts. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>