You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
Merge commit '448c8cfe4c53e9e806effd8505b46d57fa707061'
* commit '448c8cfe4c53e9e806effd8505b46d57fa707061': movenc: Support setting fragment_index before the moov atom is written Conflicts: libavformat/movenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -79,7 +79,7 @@ static const AVOption options[] = {
|
|||||||
{ "video_track_timescale", "set timescale of all video tracks", offsetof(MOVMuxContext, video_track_timescale), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
|
{ "video_track_timescale", "set timescale of all video tracks", offsetof(MOVMuxContext, video_track_timescale), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
|
||||||
{ "brand", "Override major brand", offsetof(MOVMuxContext, major_brand), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = AV_OPT_FLAG_ENCODING_PARAM },
|
{ "brand", "Override major brand", offsetof(MOVMuxContext, major_brand), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = AV_OPT_FLAG_ENCODING_PARAM },
|
||||||
{ "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM},
|
{ "use_editlist", "use edit list", offsetof(MOVMuxContext, use_editlist), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, AV_OPT_FLAG_ENCODING_PARAM},
|
||||||
{ "fragment_index", "Fragment number of the next fragment", offsetof(MOVMuxContext, fragments), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
|
{ "fragment_index", "Fragment number of the next fragment", offsetof(MOVMuxContext, fragments), AV_OPT_TYPE_INT, {.i64 = 1}, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
|
||||||
{ "mov_gamma", "gamma value for gama atom", offsetof(MOVMuxContext, gamma), AV_OPT_TYPE_FLOAT, {.dbl = 0.0 }, 0.0, 10, AV_OPT_FLAG_ENCODING_PARAM},
|
{ "mov_gamma", "gamma value for gama atom", offsetof(MOVMuxContext, gamma), AV_OPT_TYPE_FLOAT, {.dbl = 0.0 }, 0.0, 10, AV_OPT_FLAG_ENCODING_PARAM},
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
@@ -4058,7 +4058,7 @@ static int mov_flush_fragment(AVFormatContext *s)
|
|||||||
if (!(mov->flags & FF_MOV_FLAG_FRAGMENT))
|
if (!(mov->flags & FF_MOV_FLAG_FRAGMENT))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (mov->fragments == 0) {
|
if (!mov->moov_written) {
|
||||||
int64_t pos = avio_tell(s->pb);
|
int64_t pos = avio_tell(s->pb);
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
int buf_size, moov_size;
|
int buf_size, moov_size;
|
||||||
@@ -4083,7 +4083,7 @@ static int mov_flush_fragment(AVFormatContext *s)
|
|||||||
if (mov->flags & FF_MOV_FLAG_FASTSTART)
|
if (mov->flags & FF_MOV_FLAG_FASTSTART)
|
||||||
mov->reserved_moov_pos = avio_tell(s->pb);
|
mov->reserved_moov_pos = avio_tell(s->pb);
|
||||||
avio_flush(s->pb);
|
avio_flush(s->pb);
|
||||||
mov->fragments++;
|
mov->moov_written = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4094,7 +4094,7 @@ static int mov_flush_fragment(AVFormatContext *s)
|
|||||||
avio_write(s->pb, buf, buf_size);
|
avio_write(s->pb, buf, buf_size);
|
||||||
av_free(buf);
|
av_free(buf);
|
||||||
|
|
||||||
mov->fragments++;
|
mov->moov_written = 1;
|
||||||
mov->mdat_size = 0;
|
mov->mdat_size = 0;
|
||||||
for (i = 0; i < mov->nb_streams; i++) {
|
for (i = 0; i < mov->nb_streams; i++) {
|
||||||
if (mov->tracks[i].entry)
|
if (mov->tracks[i].entry)
|
||||||
@@ -4172,12 +4172,13 @@ static int mov_flush_fragment(AVFormatContext *s)
|
|||||||
static int mov_auto_flush_fragment(AVFormatContext *s)
|
static int mov_auto_flush_fragment(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
MOVMuxContext *mov = s->priv_data;
|
MOVMuxContext *mov = s->priv_data;
|
||||||
|
int had_moov = mov->moov_written;
|
||||||
int ret = mov_flush_fragment(s);
|
int ret = mov_flush_fragment(s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
// If using delay_moov, the first flush only wrote the moov,
|
// If using delay_moov, the first flush only wrote the moov,
|
||||||
// not the actual moof+mdat pair, thus flush once again.
|
// not the actual moof+mdat pair, thus flush once again.
|
||||||
if (mov->fragments == 1 && mov->flags & FF_MOV_FLAG_DELAY_MOOV)
|
if (!had_moov && mov->flags & FF_MOV_FLAG_DELAY_MOOV)
|
||||||
ret = mov_flush_fragment(s);
|
ret = mov_flush_fragment(s);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -4209,7 +4210,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
}
|
}
|
||||||
if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
|
if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
|
||||||
int ret;
|
int ret;
|
||||||
if (mov->fragments > 0 || mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {
|
if (mov->moov_written || mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {
|
||||||
if (!trk->mdat_buf) {
|
if (!trk->mdat_buf) {
|
||||||
if ((ret = avio_open_dyn_buf(&trk->mdat_buf)) < 0)
|
if ((ret = avio_open_dyn_buf(&trk->mdat_buf)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@@ -4367,7 +4368,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
trk->frag_start = pkt->dts;
|
trk->frag_start = pkt->dts;
|
||||||
trk->start_dts = 0;
|
trk->start_dts = 0;
|
||||||
trk->frag_discont = 0;
|
trk->frag_discont = 0;
|
||||||
} else if (pkt->dts && mov->fragments >= 1)
|
} else if (pkt->dts && mov->moov_written)
|
||||||
av_log(s, AV_LOG_WARNING,
|
av_log(s, AV_LOG_WARNING,
|
||||||
"Track %d starts with a nonzero dts %"PRId64", while the moov "
|
"Track %d starts with a nonzero dts %"PRId64", while the moov "
|
||||||
"already has been written. Set the delay_moov flag to handle "
|
"already has been written. Set the delay_moov flag to handle "
|
||||||
@@ -5143,7 +5144,7 @@ static int mov_write_header(AVFormatContext *s)
|
|||||||
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
|
!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
|
||||||
if ((ret = mov_write_moov_tag(pb, mov, s)) < 0)
|
if ((ret = mov_write_moov_tag(pb, mov, s)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
mov->fragments++;
|
mov->moov_written = 1;
|
||||||
if (mov->flags & FF_MOV_FLAG_FASTSTART)
|
if (mov->flags & FF_MOV_FLAG_FASTSTART)
|
||||||
mov->reserved_moov_pos = avio_tell(pb);
|
mov->reserved_moov_pos = avio_tell(pb);
|
||||||
}
|
}
|
||||||
|
@@ -168,6 +168,7 @@ typedef struct MOVMuxContext {
|
|||||||
int iods_video_profile;
|
int iods_video_profile;
|
||||||
int iods_audio_profile;
|
int iods_audio_profile;
|
||||||
|
|
||||||
|
int moov_written;
|
||||||
int fragments;
|
int fragments;
|
||||||
int max_fragment_duration;
|
int max_fragment_duration;
|
||||||
int min_fragment_duration;
|
int min_fragment_duration;
|
||||||
|
Reference in New Issue
Block a user