Similarly to the omit_tfhd_offset flag added in e7bf085b, this
avoids writing absolute byte positions to the file, making them
more easily streamable.
This is a new feature from 14496-12:2012, so application support
isn't necessarily too widespread yet (support for it in libav was
added in 20f95f21f in July 2014).
Signed-off-by: Martin Storsjö <martin@martin.st>
... | ... |
@@ -340,6 +340,13 @@ cause failures when the file is reprocessed with certain tagging programs. |
340 | 340 |
@item -movflags omit_tfhd_offset |
341 | 341 |
Do not write any absolute base_data_offset in tfhd atoms. This avoids |
342 | 342 |
tying fragments to absolute byte positions in the file/streams. |
343 |
+@item -movflags default_base_moof |
|
344 |
+Similarly to the omit_tfhd_offset, this flag avoids writing the |
|
345 |
+absolute base_data_offset field in tfhd atoms, but does so by using |
|
346 |
+the new default-base-is-moof flag instead. This flag is new from |
|
347 |
+14496-12:2012. This may make the fragments easier to parse in certain |
|
348 |
+circumstances (avoiding basing track fragment location calculations |
|
349 |
+on the implicit end of the previous track fragment). |
|
343 | 350 |
@end table |
344 | 351 |
|
345 | 352 |
Smooth Streaming content can be pushed in real time to a publishing |
... | ... |
@@ -58,6 +58,7 @@ static const AVOption options[] = { |
58 | 58 |
{ "faststart", "Run a second pass to put the index (moov atom) at the beginning of the file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FASTSTART}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, |
59 | 59 |
{ "omit_tfhd_offset", "Omit the base data offset in tfhd atoms", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_OMIT_TFHD_OFFSET}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, |
60 | 60 |
{ "disable_chpl", "Disable Nero chapter atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DISABLE_CHPL}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, |
61 |
+ { "default_base_moof", "Set the default-base-is-moof flag in tfhd atoms", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DEFAULT_BASE_MOOF}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, |
|
61 | 62 |
FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags), |
62 | 63 |
{ "skip_iods", "Skip writing iods atom.", offsetof(MOVMuxContext, iods_skip), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM}, |
63 | 64 |
{ "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}, |
... | ... |
@@ -2386,6 +2387,10 @@ static int mov_write_tfhd_tag(AVIOContext *pb, MOVMuxContext *mov, |
2386 | 2386 |
} |
2387 | 2387 |
if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET) |
2388 | 2388 |
flags &= ~MOV_TFHD_BASE_DATA_OFFSET; |
2389 |
+ if (mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF) { |
|
2390 |
+ flags &= ~MOV_TFHD_BASE_DATA_OFFSET; |
|
2391 |
+ flags |= MOV_TFHD_DEFAULT_BASE_IS_MOOF; |
|
2392 |
+ } |
|
2389 | 2393 |
|
2390 | 2394 |
/* Don't set a default sample size, the silverlight player refuses |
2391 | 2395 |
* to play files with that set. Don't set a default sample duration, |
... | ... |
@@ -2457,7 +2462,7 @@ static int mov_write_trun_tag(AVIOContext *pb, MOVMuxContext *mov, |
2457 | 2457 |
|
2458 | 2458 |
avio_wb32(pb, track->entry); /* sample count */ |
2459 | 2459 |
if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET && |
2460 |
- !(mov->flags & FF_MOV_FLAG_SEPARATE_MOOF) && |
|
2460 |
+ !(mov->flags & (FF_MOV_FLAG_SEPARATE_MOOF | FF_MOV_FLAG_DEFAULT_BASE_MOOF)) && |
|
2461 | 2461 |
!mov->first_trun) |
2462 | 2462 |
avio_wb32(pb, 0); /* Later tracks follow immediately after the previous one */ |
2463 | 2463 |
else |
... | ... |
@@ -2717,6 +2722,8 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) |
2717 | 2717 |
minor = has_h264 ? 0x20000 : 0x10000; |
2718 | 2718 |
} else if (mov->mode == MODE_PSP) |
2719 | 2719 |
ffio_wfourcc(pb, "MSNV"); |
2720 |
+ else if (mov->mode == MODE_MP4 && mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF) |
|
2721 |
+ ffio_wfourcc(pb, "iso5"); // Required when using default-base-is-moof |
|
2720 | 2722 |
else if (mov->mode == MODE_MP4) |
2721 | 2723 |
ffio_wfourcc(pb, "isom"); |
2722 | 2724 |
else if (mov->mode == MODE_IPOD) |
... | ... |
@@ -2734,8 +2741,9 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) |
2734 | 2734 |
ffio_wfourcc(pb, "qt "); |
2735 | 2735 |
else if (mov->mode == MODE_ISM) { |
2736 | 2736 |
ffio_wfourcc(pb, "piff"); |
2737 |
- ffio_wfourcc(pb, "iso2"); |
|
2738 |
- } else { |
|
2737 |
+ if (!(mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)) |
|
2738 |
+ ffio_wfourcc(pb, "iso2"); |
|
2739 |
+ } else if (!(mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)) { |
|
2739 | 2740 |
ffio_wfourcc(pb, "isom"); |
2740 | 2741 |
ffio_wfourcc(pb, "iso2"); |
2741 | 2742 |
if (has_h264) |
... | ... |
@@ -178,6 +178,7 @@ typedef struct MOVMuxContext { |
178 | 178 |
#define FF_MOV_FLAG_FASTSTART 128 |
179 | 179 |
#define FF_MOV_FLAG_OMIT_TFHD_OFFSET 256 |
180 | 180 |
#define FF_MOV_FLAG_DISABLE_CHPL 512 |
181 |
+#define FF_MOV_FLAG_DEFAULT_BASE_MOOF 1024 |
|
181 | 182 |
|
182 | 183 |
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt); |
183 | 184 |
|
... | ... |
@@ -31,7 +31,7 @@ |
31 | 31 |
|
32 | 32 |
#define LIBAVFORMAT_VERSION_MAJOR 56 |
33 | 33 |
#define LIBAVFORMAT_VERSION_MINOR 6 |
34 |
-#define LIBAVFORMAT_VERSION_MICRO 1 |
|
34 |
+#define LIBAVFORMAT_VERSION_MICRO 2 |
|
35 | 35 |
|
36 | 36 |
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
37 | 37 |
LIBAVFORMAT_VERSION_MINOR, \ |