diff mbox

[FFmpeg-devel,1/2] Add option -movflags write_track_title which will write track title metadata. This is useful in conjunction with the metadata flag to specify track title, especially for workflows that are including multiple audio tracks in the same fil

Message ID 20180317022637.24032-1-cidstrom@telltalegames.com
State New
Headers show

Commit Message

Courtland Idstrom March 17, 2018, 2:26 a.m. UTC
Example:
  ffmpeg -i in.mov -movflags write_track_title -metadata:s:a:0 title="Eng-FullMix"
---
 libavformat/movenc.c | 3 ++-
 libavformat/movenc.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Carl Eugen Hoyos March 17, 2018, 1:23 p.m. UTC | #1
2018-03-17 3:26 GMT+01:00, Courtland Idstrom <cidstrom@telltalegames.com>:
> Example:
>   ffmpeg -i in.mov -movflags write_track_title -metadata:s:a:0
> title="Eng-FullMix"

Is this defined by the QuickTime specification?

The commit message should be split so the first line
is <80 chars.

Carl Eugen
Courtland Idstrom March 17, 2018, 6:57 p.m. UTC | #2
Hi -

Thanks for the feedback here. I'll fix that commit message. I believe this
is the most relevant reference material regarding the userdata ('udta') tag
for Quicktime:

https://developer.apple.com/library/content/documentation/QuickTime/Reference/QTRef_AtomsResources/Content/QTRef_AtomsResources4.html#//apple_ref/doc/uid/TP40004285-DontLinkChapterID_1--udta-
https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-63839

From my reading of this, the 'udta' atom can appear as a child of a 'trak'
atom, and can have an optional child 'name', which is how this title is
being encoded. I've also verified that this is the method by which
Quicktime will encode titles if you set them per track using their user
interface.

Thanks,
-Courtland


On Sat, Mar 17, 2018 at 6:23 AM, Carl Eugen Hoyos <ceffmpeg@gmail.com>
wrote:

> 2018-03-17 3:26 GMT+01:00, Courtland Idstrom <cidstrom@telltalegames.com>:
> > Example:
> >   ffmpeg -i in.mov -movflags write_track_title -metadata:s:a:0
> > title="Eng-FullMix"
>
> Is this defined by the QuickTime specification?
>
> The commit message should be split so the first line
> is <80 chars.
>
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Carl Eugen Hoyos March 17, 2018, 6:59 p.m. UTC | #3
2018-03-17 19:57 GMT+01:00, Courtland Idstrom <cidstrom@telltalegames.com>:
> Hi -
>
> Thanks for the feedback here. I'll fix that commit message. I believe this
> is the most relevant reference material regarding the userdata ('udta') tag
> for Quicktime:
>
> https://developer.apple.com/library/content/documentation/QuickTime/Reference/QTRef_AtomsResources/Content/QTRef_AtomsResources4.html#//apple_ref/doc/uid/TP40004285-DontLinkChapterID_1--udta-
> https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-63839
>
> From my reading of this, the 'udta' atom can appear as a child of a 'trak'
> atom, and can have an optional child 'name', which is how this title is
> being encoded. I've also verified that this is the method by which
> Quicktime will encode titles if you set them per track using their user
> interface.

Then why is it optional?

Please do not top-post here, Carl Eugen
Courtland Idstrom March 17, 2018, 7:30 p.m. UTC | #4
>
> > From my reading of this, the 'udta' atom can appear as a child of a
> 'trak'
> > atom, and can have an optional child 'name',
>
> Then why is it optional?
>

I've made this an optional movflag in attempt to be extra careful. I'm new
to this code-base and am err-ing on the side of caution. I'd be more than
happy to make it non-optional (perhaps by adding mode & MODE_MOV to the
conditional), but I felt more comfortable suggesting this patch as
functionality that would only take effect if you opted into it. Please
advise.


> Please do not top-post here, Carl Eugen


Apologies! Hopefully this reply is better (using gmail).

Thanks for the feedback!

-Courtland
diff mbox

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 5b1e66c897..3b1a734a0a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -79,6 +79,7 @@  static const AVOption options[] = {
     { "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" },
     { "negative_cts_offsets", "Use negative CTS offsets (reducing the need for edit lists)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+    { "write_track_title", "Include track title metadata, even for MOV containers", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_TRACK_TITLE}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
     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},
     { "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},
@@ -3027,7 +3028,7 @@  static int mov_write_track_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
     if (ret < 0)
         return ret;
 
-    if (mov->mode & MODE_MP4)
+    if (mov->mode & MODE_MP4 || mov->flags & FF_MOV_FLAG_TRACK_TITLE)
         mov_write_track_metadata(pb_buf, st, "name", "title");
 
     if ((size = avio_close_dyn_buf(pb_buf, &buf)) > 0) {
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index ca2a9c9722..72dd7a958b 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -246,6 +246,7 @@  typedef struct MOVMuxContext {
 #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)
+#define FF_MOV_FLAG_TRACK_TITLE           (1 << 21)
 
 int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);