diff mbox

[FFmpeg-devel,1/3] avformat/movenc: addition of flag to fragment at every frame

Message ID 1519019709-12387-1-git-send-email-vdixit@akamai.com
State Accepted
Commit a877d22d9a8af3cd9a7da500fe2db99bebd38dd5
Headers show

Commit Message

Dixit, Vishwanath Feb. 19, 2018, 5:55 a.m. UTC
From: Vishwanath Dixit <vdixit@akamai.com>

---
 libavformat/movenc.c | 10 +++++++---
 libavformat/movenc.h |  1 +
 2 files changed, 8 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer Feb. 20, 2018, 2:58 p.m. UTC | #1
On Mon, Feb 19, 2018 at 11:25:09AM +0530, vdixit@akamai.com wrote:
> From: Vishwanath Dixit <vdixit@akamai.com>
> 
> ---
>  libavformat/movenc.c | 10 +++++++---
>  libavformat/movenc.h |  1 +
>  2 files changed, 8 insertions(+), 3 deletions(-)

will apply

thx

[...]
Dixit, Vishwanath Feb. 21, 2018, 8:01 a.m. UTC | #2
>On 2/20/18, 8:28 PM, "Michael Niedermayer" <michael@niedermayer.cc> wrote:

>

>On Mon, Feb 19, 2018 at 11:25:09AM +0530, vdixit@akamai.com wrote:

>> From: Vishwanath Dixit <vdixit@akamai.com>

>> 

>> ---

>>  libavformat/movenc.c | 10 +++++++---

>>  libavformat/movenc.h |  1 +

>>  2 files changed, 8 insertions(+), 3 deletions(-)

>

>will apply

>

>thx

Thanks for applying the patch…
diff mbox

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index f433499..5b1e66c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -62,6 +62,7 @@  static const AVOption options[] = {
     { "moov_size", "maximum moov size so it can be placed at the begin", offsetof(MOVMuxContext, reserved_moov_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, 0 },
     { "empty_moov", "Make the initial moov atom empty", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_EMPTY_MOOV}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
     { "frag_keyframe", "Fragment at video keyframes", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_KEYFRAME}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+    { "frag_every_frame", "Fragment at every frame", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_EVERY_FRAME}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
     { "separate_moof", "Write separate moof/mdat atoms for each track", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_SEPARATE_MOOF}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
     { "frag_custom", "Flush fragments on caller requests", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_CUSTOM}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
     { "isml", "Create a live smooth streaming feed (for pushing to a publishing point)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_ISML}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
@@ -5432,7 +5433,8 @@  static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
              (mov->max_fragment_size && mov->mdat_size + size >= mov->max_fragment_size) ||
              (mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME &&
               par->codec_type == AVMEDIA_TYPE_VIDEO &&
-              trk->entry && pkt->flags & AV_PKT_FLAG_KEY)) {
+              trk->entry && pkt->flags & AV_PKT_FLAG_KEY) ||
+              (mov->flags & FF_MOV_FLAG_FRAG_EVERY_FRAME)) {
             if (frag_duration >= mov->min_fragment_duration) {
                 // Set the duration of this track to line up with the next
                 // sample in this track. This avoids relying on AVPacket
@@ -5874,7 +5876,8 @@  static int mov_init(AVFormatContext *s)
     if (mov->max_fragment_duration || mov->max_fragment_size ||
         mov->flags & (FF_MOV_FLAG_EMPTY_MOOV |
                       FF_MOV_FLAG_FRAG_KEYFRAME |
-                      FF_MOV_FLAG_FRAG_CUSTOM))
+                      FF_MOV_FLAG_FRAG_CUSTOM |
+                      FF_MOV_FLAG_FRAG_EVERY_FRAME))
         mov->flags |= FF_MOV_FLAG_FRAGMENT;
 
     /* Set other implicit flags immediately */
@@ -6238,7 +6241,8 @@  static int mov_write_header(AVFormatContext *s)
     if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
         /* If no fragmentation options have been set, set a default. */
         if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME |
-                            FF_MOV_FLAG_FRAG_CUSTOM)) &&
+                            FF_MOV_FLAG_FRAG_CUSTOM |
+                            FF_MOV_FLAG_FRAG_EVERY_FRAME)) &&
             !mov->max_fragment_duration && !mov->max_fragment_size)
             mov->flags |= FF_MOV_FLAG_FRAG_KEYFRAME;
     } else {
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index c4e966b..ca2a9c9 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -245,6 +245,7 @@  typedef struct MOVMuxContext {
 #define FF_MOV_FLAG_USE_MDTA              (1 << 17)
 #define FF_MOV_FLAG_SKIP_TRAILER          (1 << 18)
 #define FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS  (1 << 19)
+#define FF_MOV_FLAG_FRAG_EVERY_FRAME      (1 << 20)
 
 int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);