Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v2 1/2] fate/mov: Add test for muxing chapters
@ 2022-03-04 13:44 Andreas Rheinhardt
  2022-03-04 13:45 ` [FFmpeg-devel] [PATCH v2 2/2] avformat/movenc: Simplify creating chapter track extradata Andreas Rheinhardt
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Rheinhardt @ 2022-03-04 13:44 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Resending because I forgot the ref file in v1. Thanks to James for
noticing.

The input audio stream has a title metadata tag that is written
in mov_write_track_udta_tag(); yet somehow the demuxer doesn't
pick it up.

 tests/fate/mov.mak              |  6 ++++
 tests/ref/fate/mov-mp4-chapters | 50 +++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
 create mode 100644 tests/ref/fate/mov-mp4-chapters

diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index e956380909..b54c009f05 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -126,6 +126,12 @@ fate-mov-mp4-with-mov-in24-ver: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entr
 
 fate-mov-mp4-extended-atom: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets -print_format compact -select_streams v $(TARGET_SAMPLES)/mov/extended_atom_size_probe
 
+FATE_MOV_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL OGG_DEMUXER            \
+                                       VORBIS_DECODER MP4_MUXER MOV_DEMUXER \
+                                       FRAMECRC_MUXER PIPE_PROTOCOL)        \
+                          += fate-mov-mp4-chapters
+fate-mov-mp4-chapters: CMD = transcode ogg $(TARGET_SAMPLES)/vorbis/vorbis_chapter_extension_demo.ogg mp4 "-c copy" "-c copy -t 0.1" "" "-show_chapters"
+
 FATE_MOV_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MOV_DEMUXER MJPEG_DECODER \
                                        SCALE_FILTER PNG_ENCODER PNG_DECODER    \
                                        MP4_MUXER FRAMECRC_MUXER PIPE_PROTOCOL) \
diff --git a/tests/ref/fate/mov-mp4-chapters b/tests/ref/fate/mov-mp4-chapters
new file mode 100644
index 0000000000..d072d76a83
--- /dev/null
+++ b/tests/ref/fate/mov-mp4-chapters
@@ -0,0 +1,50 @@
+1fd844c2f5bf77c3344e88e30ad994e1 *tests/data/fate/mov-mp4-chapters.mp4
+111248 tests/data/fate/mov-mp4-chapters.mp4
+#extradata 0:     3469, 0xc6769ddc
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: vorbis
+#sample_rate 0: 44100
+#channel_layout 0: 4
+#channel_layout_name 0: mono
+0,       -256,       -256,      256,       28, 0xefcf103e, F=0x5
+0,          0,          0,     1152,      198, 0xfbbe5eb5
+0,       1152,       1152,     2944,      198, 0xabd95c6c
+0,       4096,       4096,      256,       41, 0x954b12a5
+0,       4352,       4352,      256,       41, 0xbccd1463
+[CHAPTER]
+id=0
+time_base=1/1000
+start=0
+start_time=0.000000
+end=5000
+end_time=5.000000
+TAG:title=start
+[/CHAPTER]
+[CHAPTER]
+id=1
+time_base=1/1000
+start=5000
+start_time=5.000000
+end=10500
+end_time=10.500000
+TAG:title=Five Seconds
+[/CHAPTER]
+[CHAPTER]
+id=2
+time_base=1/1000
+start=10500
+start_time=10.500000
+end=15000
+end_time=15.000000
+TAG:title=Ten point 5 seconds
+[/CHAPTER]
+[CHAPTER]
+id=3
+time_base=1/1000
+start=15000
+start_time=15.000000
+end=19849
+end_time=19.849000
+TAG:title=15 sec - over soon
+[/CHAPTER]
-- 
2.32.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [FFmpeg-devel] [PATCH v2 2/2] avformat/movenc: Simplify creating chapter track extradata
  2022-03-04 13:44 [FFmpeg-devel] [PATCH v2 1/2] fate/mov: Add test for muxing chapters Andreas Rheinhardt
@ 2022-03-04 13:45 ` Andreas Rheinhardt
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Rheinhardt @ 2022-03-04 13:45 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/movenc.c | 79 +++++++++++++++-----------------------------
 1 file changed, 26 insertions(+), 53 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 4c868919ae..2a6cc1bc6a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6238,12 +6238,32 @@ fail:
 // as samples, and a tref pointing from the other tracks to the chapter one.
 static int mov_create_chapter_track(AVFormatContext *s, int tracknum)
 {
-    AVIOContext *pb;
-
+    static const uint8_t stub_header[] = {
+        // TextSampleEntry
+        0x00, 0x00, 0x00, 0x01, // displayFlags
+        0x00, 0x00,             // horizontal + vertical justification
+        0x00, 0x00, 0x00, 0x00, // bgColourRed/Green/Blue/Alpha
+        // BoxRecord
+        0x00, 0x00, 0x00, 0x00, // defTextBoxTop/Left
+        0x00, 0x00, 0x00, 0x00, // defTextBoxBottom/Right
+        // StyleRecord
+        0x00, 0x00, 0x00, 0x00, // startChar + endChar
+        0x00, 0x01,             // fontID
+        0x00, 0x00,             // fontStyleFlags + fontSize
+        0x00, 0x00, 0x00, 0x00, // fgColourRed/Green/Blue/Alpha
+        // FontTableBox
+        0x00, 0x00, 0x00, 0x0D, // box size
+        'f', 't', 'a', 'b',     // box atom name
+        0x00, 0x01,             // entry count
+        // FontRecord
+        0x00, 0x01,             // font ID
+        0x00,                   // font name length
+    };
     MOVMuxContext *mov = s->priv_data;
     MOVTrack *track = &mov->tracks[tracknum];
     AVPacket *pkt = mov->pkt;
     int i, len;
+    int ret;
 
     track->mode = mov->mode;
     track->tag = MKTAG('t','e','x','t');
@@ -6252,57 +6272,10 @@ static int mov_create_chapter_track(AVFormatContext *s, int tracknum)
     if (!track->par)
         return AVERROR(ENOMEM);
     track->par->codec_type = AVMEDIA_TYPE_SUBTITLE;
-#if 0
-    // These properties are required to make QT recognize the chapter track
-    uint8_t chapter_properties[43] = { 0, 0, 0, 0, 0, 0, 0, 1, };
-    if (ff_alloc_extradata(track->par, sizeof(chapter_properties)))
-        return AVERROR(ENOMEM);
-    memcpy(track->par->extradata, chapter_properties, sizeof(chapter_properties));
-#else
-    if (avio_open_dyn_buf(&pb) >= 0) {
-        int size;
-        uint8_t *buf;
-
-        /* Stub header (usually for Quicktime chapter track) */
-        // TextSampleEntry
-        avio_wb32(pb, 0x01); // displayFlags
-        avio_w8(pb, 0x00);   // horizontal justification
-        avio_w8(pb, 0x00);   // vertical justification
-        avio_w8(pb, 0x00);   // bgColourRed
-        avio_w8(pb, 0x00);   // bgColourGreen
-        avio_w8(pb, 0x00);   // bgColourBlue
-        avio_w8(pb, 0x00);   // bgColourAlpha
-        // BoxRecord
-        avio_wb16(pb, 0x00); // defTextBoxTop
-        avio_wb16(pb, 0x00); // defTextBoxLeft
-        avio_wb16(pb, 0x00); // defTextBoxBottom
-        avio_wb16(pb, 0x00); // defTextBoxRight
-        // StyleRecord
-        avio_wb16(pb, 0x00); // startChar
-        avio_wb16(pb, 0x00); // endChar
-        avio_wb16(pb, 0x01); // fontID
-        avio_w8(pb, 0x00);   // fontStyleFlags
-        avio_w8(pb, 0x00);   // fontSize
-        avio_w8(pb, 0x00);   // fgColourRed
-        avio_w8(pb, 0x00);   // fgColourGreen
-        avio_w8(pb, 0x00);   // fgColourBlue
-        avio_w8(pb, 0x00);   // fgColourAlpha
-        // FontTableBox
-        avio_wb32(pb, 0x0D); // box size
-        ffio_wfourcc(pb, "ftab"); // box atom name
-        avio_wb16(pb, 0x01); // entry count
-        // FontRecord
-        avio_wb16(pb, 0x01); // font ID
-        avio_w8(pb, 0x00);   // font name length
-
-        if ((size = avio_close_dyn_buf(pb, &buf)) > 0) {
-            track->par->extradata = buf;
-            track->par->extradata_size = size;
-        } else {
-            av_freep(&buf);
-        }
-    }
-#endif
+    ret = ff_alloc_extradata(track->par, sizeof(stub_header));
+    if (ret < 0)
+        return ret;
+    memcpy(track->par->extradata, stub_header, sizeof(stub_header));
 
     pkt->stream_index = tracknum;
     pkt->flags = AV_PKT_FLAG_KEY;
-- 
2.32.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-04 13:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-04 13:44 [FFmpeg-devel] [PATCH v2 1/2] fate/mov: Add test for muxing chapters Andreas Rheinhardt
2022-03-04 13:45 ` [FFmpeg-devel] [PATCH v2 2/2] avformat/movenc: Simplify creating chapter track extradata Andreas Rheinhardt

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git