You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
Merge commit '4f7723cb3b913c577842a5bb088c804ddacac8df'
* commit '4f7723cb3b913c577842a5bb088c804ddacac8df': movenc: Add an option for skipping writing the mfra/tfra/mfro trailer Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
This commit is contained in:
@@ -72,6 +72,7 @@ static const AVOption options[] = {
|
|||||||
{ "write_colr", "Write colr atom (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
|
{ "write_colr", "Write colr atom (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
|
||||||
{ "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
|
{ "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
|
||||||
{ "use_metadata_tags", "Use mdta atom for metadata.", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_USE_MDTA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
|
{ "use_metadata_tags", "Use mdta atom for metadata.", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_USE_MDTA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
|
||||||
|
{ "skip_trailer", "Skip writing the mfra/tfra/mfro trailer for fragmented files", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_SKIP_TRAILER}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
|
||||||
FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags),
|
FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags),
|
||||||
{ "skip_iods", "Skip writing iods atom.", offsetof(MOVMuxContext, iods_skip), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
|
{ "skip_iods", "Skip writing iods atom.", offsetof(MOVMuxContext, iods_skip), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
|
||||||
{ "iods_audio_profile", "iods audio profile atom.", offsetof(MOVMuxContext, iods_audio_profile), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 255, AV_OPT_FLAG_ENCODING_PARAM},
|
{ "iods_audio_profile", "iods audio profile atom.", offsetof(MOVMuxContext, iods_audio_profile), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 255, AV_OPT_FLAG_ENCODING_PARAM},
|
||||||
@@ -3934,6 +3935,20 @@ static int mov_add_tfra_entries(AVIOContext *pb, MOVMuxContext *mov, int tracks,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mov_prune_frag_info(MOVMuxContext *mov, int tracks, int max)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < mov->nb_streams; i++) {
|
||||||
|
MOVTrack *track = &mov->tracks[i];
|
||||||
|
if ((tracks >= 0 && i != tracks) || !track->entry)
|
||||||
|
continue;
|
||||||
|
if (track->nb_frag_info > max) {
|
||||||
|
memmove(track->frag_info, track->frag_info + (track->nb_frag_info - max), max * sizeof(*track->frag_info));
|
||||||
|
track->nb_frag_info = max;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int mov_write_tfdt_tag(AVIOContext *pb, MOVTrack *track)
|
static int mov_write_tfdt_tag(AVIOContext *pb, MOVTrack *track)
|
||||||
{
|
{
|
||||||
int64_t pos = avio_tell(pb);
|
int64_t pos = avio_tell(pb);
|
||||||
@@ -4119,8 +4134,16 @@ static int mov_write_moof_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks,
|
|||||||
if (mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX))
|
if (mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX))
|
||||||
mov_write_sidx_tags(pb, mov, tracks, moof_size + 8 + mdat_size);
|
mov_write_sidx_tags(pb, mov, tracks, moof_size + 8 + mdat_size);
|
||||||
|
|
||||||
|
if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX ||
|
||||||
|
!(mov->flags & FF_MOV_FLAG_SKIP_TRAILER) ||
|
||||||
|
mov->ism_lookahead) {
|
||||||
if ((ret = mov_add_tfra_entries(pb, mov, tracks, moof_size + 8 + mdat_size)) < 0)
|
if ((ret = mov_add_tfra_entries(pb, mov, tracks, moof_size + 8 + mdat_size)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
if (!(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX) &&
|
||||||
|
mov->flags & FF_MOV_FLAG_SKIP_TRAILER) {
|
||||||
|
mov_prune_frag_info(mov, tracks, mov->ism_lookahead + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return mov_write_moof_tag_internal(pb, mov, tracks, moof_size);
|
return mov_write_moof_tag_internal(pb, mov, tracks, moof_size);
|
||||||
}
|
}
|
||||||
@@ -6150,7 +6173,7 @@ static int mov_write_trailer(AVFormatContext *s)
|
|||||||
avio_seek(pb, end, SEEK_SET);
|
avio_seek(pb, end, SEEK_SET);
|
||||||
avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_TRAILER);
|
avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_TRAILER);
|
||||||
mov_write_mfra_tag(pb, mov);
|
mov_write_mfra_tag(pb, mov);
|
||||||
} else {
|
} else if (!(mov->flags & FF_MOV_FLAG_SKIP_TRAILER)) {
|
||||||
avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_TRAILER);
|
avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_TRAILER);
|
||||||
mov_write_mfra_tag(pb, mov);
|
mov_write_mfra_tag(pb, mov);
|
||||||
}
|
}
|
||||||
|
@@ -240,6 +240,7 @@ typedef struct MOVMuxContext {
|
|||||||
#define FF_MOV_FLAG_WRITE_COLR (1 << 15)
|
#define FF_MOV_FLAG_WRITE_COLR (1 << 15)
|
||||||
#define FF_MOV_FLAG_WRITE_GAMA (1 << 16)
|
#define FF_MOV_FLAG_WRITE_GAMA (1 << 16)
|
||||||
#define FF_MOV_FLAG_USE_MDTA (1 << 17)
|
#define FF_MOV_FLAG_USE_MDTA (1 << 17)
|
||||||
|
#define FF_MOV_FLAG_SKIP_TRAILER (1 << 18)
|
||||||
|
|
||||||
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
|
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user