mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
avformat/movenc: allow rewriting extradata
Signed-off-by: Umair Khan <omerjerk@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
9ffe44c5c7
commit
4f6f56114e
@ -4919,6 +4919,21 @@ static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
trk->start_cts = 0;
|
||||
}
|
||||
|
||||
if (trk->par->codec_id == AV_CODEC_ID_MP4ALS) {
|
||||
int side_size = 0;
|
||||
uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
|
||||
if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) {
|
||||
av_free(par->extradata);
|
||||
par->extradata = av_mallocz(side_size + AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!par->extradata) {
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
memcpy(par->extradata, side, side_size);
|
||||
par->extradata_size = side_size;
|
||||
mov->need_rewrite_extradata = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0; /* Discard 0 sized packets */
|
||||
}
|
||||
|
||||
@ -5921,6 +5936,22 @@ static int mov_write_trailer(AVFormatContext *s)
|
||||
int i;
|
||||
int64_t moov_pos;
|
||||
|
||||
if (mov->need_rewrite_extradata) {
|
||||
for (i = 0; i < s->nb_streams; i++) {
|
||||
MOVTrack *track = &mov->tracks[i];
|
||||
AVCodecParameters *par = track->par;
|
||||
|
||||
track->vos_len = par->extradata_size;
|
||||
track->vos_data = av_malloc(track->vos_len);
|
||||
if (!track->vos_data) {
|
||||
AVERROR(ENOMEM);
|
||||
goto error;
|
||||
}
|
||||
memcpy(track->vos_data, par->extradata, track->vos_len);
|
||||
}
|
||||
mov->need_rewrite_extradata = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Before actually writing the trailer, make sure that there are no
|
||||
* dangling subtitles, that need a terminating sample.
|
||||
|
@ -215,6 +215,8 @@ typedef struct MOVMuxContext {
|
||||
uint8_t *encryption_kid;
|
||||
int encryption_kid_len;
|
||||
|
||||
int need_rewrite_extradata;
|
||||
|
||||
} MOVMuxContext;
|
||||
|
||||
#define FF_MOV_FLAG_RTP_HINT (1 << 0)
|
||||
|
Loading…
Reference in New Issue
Block a user