Dumps all metadata to a text file for easy manual editing.
Originally committed as revision 26101 to svn://svn.ffmpeg.org/ffmpeg/trunk
... | ... |
@@ -116,7 +116,7 @@ documentation: $(addprefix doc/, developer.html faq.html general.html libavfilte |
116 | 116 |
|
117 | 117 |
$(HTMLPAGES) $(PODPAGES): doc/fftools-common-opts.texi |
118 | 118 |
|
119 |
-doc/ffmpeg.pod doc/ffmpeg.html: doc/bitstream_filters.texi doc/eval.texi doc/indevs.texi doc/filters.texi doc/outdevs.texi doc/protocols.texi |
|
119 |
+doc/ffmpeg.pod doc/ffmpeg.html: doc/bitstream_filters.texi doc/eval.texi doc/indevs.texi doc/filters.texi doc/outdevs.texi doc/protocols.texi doc/metadata.texi |
|
120 | 120 |
doc/ffplay.pod doc/ffplay.html: doc/eval.texi doc/indevs.texi doc/filters.texi doc/outdevs.texi doc/protocols.texi |
121 | 121 |
doc/ffprobe.pod doc/ffprobe.html: doc/indevs.texi doc/protocols.texi |
122 | 122 |
doc/libavfilter.html: doc/filters.texi |
... | ... |
@@ -118,6 +118,8 @@ library: |
118 | 118 |
@tab VR native stream format, used by Leitch/Harris' video servers. |
119 | 119 |
@item Matroska @tab X @tab X |
120 | 120 |
@item Matroska audio @tab X @tab |
121 |
+@item FFmpeg metadata @tab X @tab |
|
122 |
+ @tab Metadata in text format. |
|
121 | 123 |
@item MAXIS XA @tab @tab X |
122 | 124 |
@tab Used in Sim City 3000; file extension .xa. |
123 | 125 |
@item MD Studio @tab @tab X |
124 | 126 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,68 @@ |
0 |
+@chapter Metadata |
|
1 |
+@c man begin METADATA |
|
2 |
+ |
|
3 |
+FFmpeg is able to dump metadata from media files into a simple UTF-8-encoded |
|
4 |
+INI-like text file and then load it back using the metadata muxer/demuxer. |
|
5 |
+ |
|
6 |
+The file format is as follows: |
|
7 |
+@enumerate |
|
8 |
+ |
|
9 |
+@item |
|
10 |
+A file consists of a header and a number of metadata tags divided into sections, |
|
11 |
+each on its own line. |
|
12 |
+ |
|
13 |
+@item |
|
14 |
+The header is a ';FFMETADATA' string, followed by a version number (now 1). |
|
15 |
+ |
|
16 |
+@item |
|
17 |
+Metadata tags are of the form 'key=value' |
|
18 |
+ |
|
19 |
+@item |
|
20 |
+Immediately after header follows global metadata |
|
21 |
+ |
|
22 |
+@item |
|
23 |
+After global metadata there may be sections with per-stream/per-chapter |
|
24 |
+metadata. |
|
25 |
+ |
|
26 |
+@item |
|
27 |
+A section starts with the section name in uppercase (i.e. STREAM or CHAPTER) in |
|
28 |
+brackets ('[', ']') and ends with next section or end of file. |
|
29 |
+ |
|
30 |
+@item |
|
31 |
+At the beginning of a chapter section there may be an optional timebase to be |
|
32 |
+used for start/end values. It must be in form 'TIMEBASE=num/den', where num and |
|
33 |
+den are integers. If the timebase is missing then start/end times are assumed to |
|
34 |
+be in milliseconds. |
|
35 |
+Next a chapter section must contain chapter start and end times in form |
|
36 |
+'START=num', 'END=num', where num is a positive integer. |
|
37 |
+ |
|
38 |
+@item |
|
39 |
+Empty lines and lines starting with ';' or '#' are ignored. |
|
40 |
+ |
|
41 |
+@item |
|
42 |
+Metadata keys or values containing special characters ('=', ';', '#', '\' and a |
|
43 |
+newline) must be escaped with a backslash '\'. |
|
44 |
+ |
|
45 |
+@item |
|
46 |
+Note that whitespace in metadata (e.g. foo = bar) is considered to be a part of |
|
47 |
+the tag (in the example above key is 'foo ', value is ' bar'). |
|
48 |
+@end enumerate |
|
49 |
+ |
|
50 |
+A ffmetadata file might look like this: |
|
51 |
+@example |
|
52 |
+;FFMETADATA1 |
|
53 |
+title=bike\\shed |
|
54 |
+;this is a comment |
|
55 |
+artist=FFmpeg troll team |
|
56 |
+ |
|
57 |
+[CHAPTER] |
|
58 |
+TIMEBASE=1/1000 |
|
59 |
+START=0 |
|
60 |
+#chapter ends at 0:01:00 |
|
61 |
+END=60000 |
|
62 |
+title=chapter \#1 |
|
63 |
+[STREAM] |
|
64 |
+title=multi\ |
|
65 |
+line |
|
66 |
+@end example |
|
67 |
+@c man end METADATA |
... | ... |
@@ -71,6 +71,7 @@ OBJS-$(CONFIG_EAC3_DEMUXER) += ac3dec.o rawdec.o |
71 | 71 |
OBJS-$(CONFIG_EAC3_MUXER) += rawenc.o |
72 | 72 |
OBJS-$(CONFIG_FFM_DEMUXER) += ffmdec.o |
73 | 73 |
OBJS-$(CONFIG_FFM_MUXER) += ffmenc.o |
74 |
+OBJS-$(CONFIG_FFMETADATA_MUXER) += metaenc.o |
|
74 | 75 |
OBJS-$(CONFIG_FILMSTRIP_DEMUXER) += filmstripdec.o |
75 | 76 |
OBJS-$(CONFIG_FILMSTRIP_MUXER) += filmstripenc.o |
76 | 77 |
OBJS-$(CONFIG_FLAC_DEMUXER) += flacdec.o rawdec.o \ |
... | ... |
@@ -85,6 +85,7 @@ void av_register_all(void) |
85 | 85 |
REGISTER_DEMUXER (EA_CDATA, ea_cdata); |
86 | 86 |
REGISTER_MUXDEMUX (EAC3, eac3); |
87 | 87 |
REGISTER_MUXDEMUX (FFM, ffm); |
88 |
+ REGISTER_MUXER (FFMETADATA, ffmetadata); |
|
88 | 89 |
REGISTER_MUXDEMUX (FILMSTRIP, filmstrip); |
89 | 90 |
REGISTER_MUXDEMUX (FLAC, flac); |
90 | 91 |
REGISTER_DEMUXER (FLIC, flic); |
91 | 92 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,29 @@ |
0 |
+/* |
|
1 |
+ * Common data for metadata muxer/demuxer |
|
2 |
+ * Copyright (c) 2010 Anton Khirnov |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#ifndef AVFORMAT_META_H |
|
22 |
+#define AVFORMAT_META_H |
|
23 |
+ |
|
24 |
+#define ID_STRING ";FFMETADATA" |
|
25 |
+#define ID_CHAPTER "[CHAPTER]" |
|
26 |
+#define ID_STREAM "[STREAM]" |
|
27 |
+ |
|
28 |
+#endif /* AVFORMAT_META_H */ |
0 | 29 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,100 @@ |
0 |
+/* |
|
1 |
+ * Metadata muxer |
|
2 |
+ * Copyright (c) 2010 Anton Khirnov |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#include "avformat.h" |
|
22 |
+#include "meta.h" |
|
23 |
+ |
|
24 |
+ |
|
25 |
+static void write_escape_str(ByteIOContext *s, const uint8_t *str) |
|
26 |
+{ |
|
27 |
+ const uint8_t *p = str; |
|
28 |
+ |
|
29 |
+ while (*p) { |
|
30 |
+ if (*p == '#' || *p == ';' || *p == '=' || *p == '\\' || *p == '\n') |
|
31 |
+ put_byte(s, '\\'); |
|
32 |
+ put_byte(s, *p); |
|
33 |
+ p++; |
|
34 |
+ } |
|
35 |
+} |
|
36 |
+ |
|
37 |
+static void write_tags(ByteIOContext *s, AVMetadata *m) |
|
38 |
+{ |
|
39 |
+ AVMetadataTag *t = NULL; |
|
40 |
+ while ((t = av_metadata_get(m, "", t, AV_METADATA_IGNORE_SUFFIX))) { |
|
41 |
+ write_escape_str(s, t->key); |
|
42 |
+ put_byte(s, '='); |
|
43 |
+ write_escape_str(s, t->value); |
|
44 |
+ put_byte(s, '\n'); |
|
45 |
+ } |
|
46 |
+} |
|
47 |
+ |
|
48 |
+static int write_header(AVFormatContext *s) |
|
49 |
+{ |
|
50 |
+ put_tag(s->pb, ID_STRING); |
|
51 |
+ put_byte(s->pb, '1'); // version |
|
52 |
+ put_byte(s->pb, '\n'); |
|
53 |
+ put_flush_packet(s->pb); |
|
54 |
+ return 0; |
|
55 |
+} |
|
56 |
+ |
|
57 |
+static int write_trailer(AVFormatContext *s) |
|
58 |
+{ |
|
59 |
+ int i; |
|
60 |
+ |
|
61 |
+ write_tags(s->pb, s->metadata); |
|
62 |
+ |
|
63 |
+ for (i = 0; i < s->nb_streams; i++) { |
|
64 |
+ put_tag(s->pb, ID_STREAM); |
|
65 |
+ put_byte(s->pb, '\n'); |
|
66 |
+ write_tags(s->pb, s->streams[i]->metadata); |
|
67 |
+ } |
|
68 |
+ |
|
69 |
+ for (i = 0; i < s->nb_chapters; i++) { |
|
70 |
+ AVChapter *ch = s->chapters[i]; |
|
71 |
+ put_tag(s->pb, ID_CHAPTER); |
|
72 |
+ put_byte(s->pb, '\n'); |
|
73 |
+ url_fprintf(s->pb, "TIMEBASE=%d/%d\n", ch->time_base.num, ch->time_base.den); |
|
74 |
+ url_fprintf(s->pb, "START=%lld\n", ch->start); |
|
75 |
+ url_fprintf(s->pb, "END=%lld\n", ch->end); |
|
76 |
+ write_tags(s->pb, ch->metadata); |
|
77 |
+ } |
|
78 |
+ |
|
79 |
+ put_flush_packet(s->pb); |
|
80 |
+ |
|
81 |
+ return 0; |
|
82 |
+} |
|
83 |
+ |
|
84 |
+static int write_packet(AVFormatContext *s, AVPacket *pkt) |
|
85 |
+{ |
|
86 |
+ return 0; |
|
87 |
+} |
|
88 |
+ |
|
89 |
+AVOutputFormat ffmetadata_muxer = { |
|
90 |
+ .name = "ffmetadata", |
|
91 |
+ .long_name = NULL_IF_CONFIG_SMALL("FFmpeg metadata in text format"), |
|
92 |
+ .extensions = "ffmeta", |
|
93 |
+ .video_codec = CODEC_ID_NONE, |
|
94 |
+ .audio_codec = CODEC_ID_NONE, |
|
95 |
+ .write_header = write_header, |
|
96 |
+ .write_packet = write_packet, |
|
97 |
+ .write_trailer = write_trailer, |
|
98 |
+ .flags = AVFMT_NOTIMESTAMPS | AVFMT_NOSTREAMS, |
|
99 |
+}; |