summaryrefslogtreecommitdiff
path: root/libavformat/movenc.c
Commit message (Collapse)AuthorAge
* movenc: add movie_timescale option instead of hardcoding 1000Justin Ruggles2021-05-04
| | | | | | | | | | | | There are cases where using 1000 as the MP4 timescale is not accurate enough, for example when one needs sample-accurate audio handling. This adds a new AVOption to the MOV/MP4 muxer to override the movie timescale, but it still defaults to 1000 to maintain current default behavior. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
* 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: remove deprecated AVStream.codecJames Almer2021-04-27
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/buffer: Switch AVBuffer API to size_tAndreas Rheinhardt2021-04-27
| | | | | | | Announced in 14040a1d913794d9a3fd6406a6d8c2f0e37e0062. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mov, movenc: Stop exporting rotation via metadataAndreas Rheinhardt2021-04-27
| | | | | | | | | | | Deprecated in ddef3d902f0e4cbd6be6b3e5df7ec158ce51488b. (The reference file of the mov-zombie test needed to be updated, because a rotate metadata tag is no longer exported; the side-data is of course still present.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: fix writing dOps atomsJames Almer2021-04-16
| | | | | | | | | | | | Don't blindly copy all bytes in extradata past ChannelMappingFamily. Instead check if ChannelMappingFamily is not 0 and then only write the correct amount of bytes from ChannelMappingTable, as defined in the spec[1]. Fixes part of ticket #9190. [1] https://opus-codec.org/docs/opus_in_isobmff.html#4.3.2 Signed-off-by: James Almer <jamrial@gmail.com>
* lavf/movenc: use framerate correctly in mov_write_tmcd_tagAnton Khirnov2021-04-08
| | | | Current code uses its inverse.
* Avoid intermediate bitcount for number of bytes in PutBitContextAndreas Rheinhardt2021-03-30
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: Avoid loosing cluster array on failureMichael Niedermayer2021-03-26
| | | | | | | | Fixes: crash Fixes: check_pkt.mp4 Found-by: Rafael Dutra <rafael.dutra@cispa.de> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/movenc: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: use the buffer_size_t typedef where requiredJames Almer2021-03-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* Remove double ';'Andreas Rheinhardt2021-03-01
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: Only check for timecodes if they are usedAndreas Rheinhardt2021-02-28
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: Don't check for disabled muxersAndreas Rheinhardt2021-02-28
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: Remove always true checkAndreas Rheinhardt2021-02-28
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: Deduplicate codec tags listsAndreas Rheinhardt2021-02-23
| | | | | | Also saves relocations. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mux: return a pointer to the packet in ff_interleaved_peek()James Almer2021-02-13
| | | | | | | And make it const, so the caller doesn't attempt to change it. ff_get_muxer_ts_offset() should be used to get the muxer timestamp offset. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: remove unnecessary HDR metadata log messagesJan Ekström2021-02-10
| | | | | | | | | | | | | | These made sense before 3ebf449766d4b69a7774c4990fb24fe71c848a3e when the creation of these boxes was specifically requested by the user, but now they have become unnecessary as they are just like many other boxes: If the input has the information required, they are written, otherwise they are not. They were moved to verbose verbosity level (which happens to be the last level still relatively usable), and now appear either once (normal MP4 muxing), or thrice (with the faststart flag set) in any normal MP4 usage, without giving much useful information. Thus, remove them in their current form.
* movenc: Present durations in mvhd/tkhd/mdhd as they are after editsMartin Storsjö2021-01-15
| | | | | | | | | | | | | | | | | | | | | If the edit lists remove parts of the output timeline, or add a delay to it, this should be included in the mvhd/tkhd/mdhd durations, which should correspond to the edit lists. For tracks starting with pts < 0, the edit list trims out the segment before pts=0. For tracks starting with pts > 0, a delay element is added in the edit list, delaying the start of the track data. In both cases, the practical effect is that the post-edit output is as if the track had started with pts = 0. Thus calculate the range from pts=0 to end_pts, for the purposes of mvhd/tkhd/mdhd, unless edit lists explicitly are disabled. mov_write_edts_tag needs to operate on the actual pts duration of the track samples, not the duration that already takes the edit list effect into account. Signed-off-by: Martin Storsjö <martin@martin.st>
* avformat/movenc: allow Apple Lossless inside mp4Leo Izen2020-11-22
| | | | | | The 'alac' identifier has been registered to ISO and thus towards ISOBMFF at the MP4 registration authority. The existing non-MOV mux mode matches the official ALAC-in-MP4 specification.
* avformat/movenc: Avoid allocation for timecode trackAndreas Rheinhardt2020-10-05
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: Don't forget to free fragment buffersAndreas Rheinhardt2020-10-05
| | | | | | | | | | The buffers used when fragmented output is enabled have up until now not been freed in the deinit function; they leak e.g. if one errors out of mov_write_trailer() before one reaches the point where they are normally written out and freed. This can e.g. happen if allocating new vos_data fails at the beginning of mov_write_trailer(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: Free old vos_data before overwriting itAndreas Rheinhardt2020-10-05
| | | | | | | | Otherwise the old data leaks whenever extradata needs to be rewritten (e.g. when encoding FLAC with our encoder that sends an updated extradata packet at the end). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: Don't free AVCodecParameters manuallyAndreas Rheinhardt2020-10-05
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: Make some AVCodecTag tables staticAndreas Rheinhardt2020-10-04
| | | | | | They are not used anywhere else. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: Fix segfault when remuxing rtp hint streamAndreas Rheinhardt2020-10-04
| | | | | | | | | | | | | | | | When remuxing an rtp hint stream (or any stream with the tag "rtp "), the mov muxer treats this as one of the rtp hint tracks it creates internally when ordered to do so; yet this track lacks the AVFormatContext for the hinting rtp muxer, leading to segfaults in mov_write_udta_sdp() if a "trak" atom is written for this stream; if not, the stream's codecpar is freed by mov_free() as if the mov muxer owned it (it does for the internally created "rtp " tracks), but without resetting st->codecpar, leading to double-frees lateron. This commit therefore ignores said tag which makes rtp hint streams unremuxable. This fixes tickets #8181 and #8186. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: handle tracks w/o AVStreams in calculate_mpeg4_bit_ratesJan Ekström2020-10-02
| | | | | | | The generated text streams for chapters lack an AVStream since they are but an internal concept within movenc. Fixes #8910
* avformat/movenc: Fix stack overflow when remuxing timecode tracksAndreas Rheinhardt2020-10-01
| | | | | | | | | | | | | | | | | | | | | | | There are two possible kinds of timecode tracks (with tag "tmcd") in the mov muxer: Tracks created internally by the muxer and timecode tracks sent by the user. If any of the latter exists, the former are deactivated. The former all belong to another track, the source track; the latter don't have a source track set, but the index of the source track is initially zeroed by av_mallocz_array(). This is a problem since 3d894db700cc1e360a7a75ab9ac8bf67ac6670a3: Said commit added a function that calculates the duration of tracks and the duration of timecode tracks is calculated by rescaling the duration (calculated by the very same function) of the source track. This gives an infinite recursion if the first track (the one that will be treated as source track for all timecode tracks) is a timecode track itself, leading to a stack overflow. This commit fixes this by not using the nonexistent source track when calculating the duration of timecode tracks not created internally by the mov muxer. Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: Fix segfault upon allocation errorAndreas Rheinhardt2020-09-28
| | | | | Reviewed-by: Jan Ekström <jeebjp@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: simplify ISML manifest bit rate logicJan Ekström2020-09-22
| | | | | The newly calculated average bit rate value is pretty much what is being done here.
* avformat/movenc: use more fall-back values for average bit rate fieldsJan Ekström2020-09-22
| | | | | | | | | If the average bit rate cannot be calculated, such as in the case of streamed fragmented mp4, utilize various available parameters in priority order. Tests are updated where the esds or btrt or ISML manifest boxes' output changes.
* avformat/movenc: implement writing of the btrt boxJan Ekström2020-09-22
| | | | | | | | | | | This is utilized by various media ingests to figure out the bit rate of the content you are pushing towards it, so write it for video, audio and subtitle tracks in case at least one nonzero value is available. It is only mentioned for timed metadata sample descriptions in QTFF, so limit it only to ISOBMFF (MODE_MP4) mode. Updates the FATE tests which have their results changed due to the 20 extra bytes being written per track.
* avformat/movenc: utilize bit rate helper function in ISML writingJan Ekström2020-09-21
| | | | | This way we have a single location in movenc which utilizes the CPB properties.
* avformat/movenc: split MPEG-4 bit rate value calculationJan Ekström2020-09-21
| | | | This can now be re-utilized in other places.
* avformat/movenc: write the colr atom by defaultMichael Bradshaw2020-08-21
| | | | | | | | | | | | | | | | | The write_colr flag has been marked as experimental for over 5 years. It should be safe to enable its behavior by default as follows: - Write the colr atom by default for mp4/mov if any of the following: - The primaries/trc/matrix are all specified, OR - There is an ICC profile, OR - The user specified +write_colr - Keep the write_colr flag for situations where the user wants to write the colr atom even if the color info is unspecified (e.g., http://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259334.html) This fixes https://trac.ffmpeg.org/ticket/7961 Signed-off-by: Michael Bradshaw <mjbshaw@google.com>
* lavf/movenc: Use a dynamic buffer when writing the mfra boxDerek Buitenhuis2020-06-28
| | | | | | | | | | | When doing streamed output, with e.g. +dash, if the mfra box ended up being larger than the AVIOContext write buffer, the (unchecked) seeking back to update the box size would silently fail and produce an invalid mfra box. This is similar to how other boxes are written in fragmented mode. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avcodec, avformat: Remove unnecessary initializations of side data sizeAndreas Rheinhardt2020-06-22
| | | | | Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/movenc: Write 'av01' as a compatible brand when muxing AV1Derek Buitenhuis2020-06-17
| | | | | | | | | This is a requirement of the AV1-ISOBMFF spec. Section 2.1. General Requirements & Brands states: * It SHALL have the av01 brand among the compatible brands array of the FileTypeBox Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avformat/movenc: fix remuxing eia-608 into mov from other containersPaul B Mahol2020-06-15
|
* movenc: Fix accidental leftover duplication from 1aec1fbcc595Martin Storsjö2020-05-22
| | | | Signed-off-by: Martin Storsjö <martin@martin.st>
* movenc: Fix conversion of the first frame for extradata-less H264/HEVCMartin Storsjö2020-05-22
| | | | | | | | | | | | | | | | | | | Move the copying of the frame to vos_data further up in the function, so that when writing the actual frame data for the first frame, it's clear that the stream really is in annex b format, for the cases where we create extradata from the first frame. Alternatively - we could invert the checks for bitstream format. If extradata is missing, we can't pretend that the bitstream is in mp4 form, because we can't even know the NAL unit length prefix size in that case. Also avoid creating extradata for AVC intra. If the track tag is an AVC intra tag, don't copy the frame into vos_data - this matches other existing cases of how vos_data and TAG_IS_AVCI interact in other places. Signed-off-by: Martin Storsjö <martin@martin.st>
* movenc: Use first H264/HEVC frame as extradata, if it is missingMartin Storsjö2020-05-20
| | | | | | | | | | | | | | | | | Sticking a full frame in the extradata works, as the code for writing the avcC/hvcC extracts the relevant parameter set NAL units - provided that they actually exist in the frame. Some encoders don't provide split out extradata directly on init (or at all). In particular, the MediaFoundation encoder wrapper doesn't always (depending on the actual encoder device) - this is the case for Qualcomm's HEVC encoder on SD835, and also on some QSV H264 encoders). This only works for cases where the moov hasn't already been written (e.g. when not writing fragmented mp4 with empty_moov, unless using the delay_moov option). Signed-off-by: Martin Storsjö <martin@martin.st>
* avformat/movenc: cosmeticsLimin Wang2020-04-26
| | | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/movenc: enable dvcC/dvvC box support from DOVI sidedataJun Zhao2020-04-23
| | | | | | enable dvcC/dvvC box support from DOVI sidedata. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/movenc: cosmeticsLimin Wang2020-04-20
| | | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Josh de Kock <josh@itanimul.li>
* avformat/movenc: remove call to av_copy_packet_side_data() when ↵James Almer2020-04-15
| | | | | | | | | | | | concatenating eac3 syncframes This generates a potential memory leak, and mixes side data from the last packet with other properties from the first. Keep all the properties from the first packet only in the output packet instead. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: write the mdcv atom by defaultMichael Bradshaw2020-04-13
| | | | | | | | | | The mdcv atom isn't in ISO/IEC 14496-12:2015 but it is expected to be added soon. See: http://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/259529.html The mdcv atom is already parsed in FFmpeg in mov.c. Signed-off-by: Michael Bradshaw <mjbshaw@google.com>
* avformat/movenc: remove the write_clli mov flagMichael Bradshaw2020-04-13
| | | | | | | | | The clli atom is expected to be standardized soon. See http://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/259529.html We now write the clli atom by default. Signed-off-by: Michael Bradshaw <mjbshaw@google.com>
* avformat/movenc: stop guessing colr atom valuesMichael Bradshaw2020-04-13
|
* avformat/movenc: use enum values directly for colr atomMichael Bradshaw2020-04-13
| | | | | | | | | | | | | | | | | | | | | | | The switch cases were missing: - Primaries: bt470m, film, smpte428, and ebu3213. - TRCs: gamma22, gamma28, linear, log, log_sqrt, iec61966_2_4, bt1361, iec61966_2_1, bt2020_10bit, and bt2020_12bit. - Space: rgb, fcc, ycgco, bt2020_cl, smpte2085, chroma-derived-nc, chroma-derived-c, and ictcp. They also annoyingly remapped the following (which are functionally equivalent but can be treated differently by clients): - smpte240m primaries to smpte170m. - smpte170m TRC to bt709. - bt470bg color space to smpte170m. The enum values in FFmpeg are the same values as ITU-T H.273 and ISO/IEC 23001-8 so we can just use them directly, which is both simpler and preserves the user intent. Signed-off-by: Michael Bradshaw <mjbshaw@google.com>