metadata.texi 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. @chapter Metadata
  2. @c man begin METADATA
  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. The file format is as follows:
  6. @enumerate
  7. @item
  8. A file consists of a header and a number of metadata tags divided into sections,
  9. each on its own line.
  10. @item
  11. The header is a @samp{;FFMETADATA} string, followed by a version number (now 1).
  12. @item
  13. Metadata tags are of the form @samp{key=value}
  14. @item
  15. Immediately after header follows global metadata
  16. @item
  17. After global metadata there may be sections with per-stream/per-chapter
  18. metadata.
  19. @item
  20. A section starts with the section name in uppercase (i.e. STREAM or CHAPTER) in
  21. brackets (@samp{[}, @samp{]}) and ends with next section or end of file.
  22. @item
  23. At the beginning of a chapter section there may be an optional timebase to be
  24. used for start/end values. It must be in form
  25. @samp{TIMEBASE=@var{num}/@var{den}}, where @var{num} and @var{den} are
  26. integers. If the timebase is missing then start/end times are assumed to
  27. be in nanoseconds.
  28. Next a chapter section must contain chapter start and end times in form
  29. @samp{START=@var{num}}, @samp{END=@var{num}}, where @var{num} is a positive
  30. integer.
  31. @item
  32. Empty lines and lines starting with @samp{;} or @samp{#} are ignored.
  33. @item
  34. Metadata keys or values containing special characters (@samp{=}, @samp{;},
  35. @samp{#}, @samp{\} and a newline) must be escaped with a backslash @samp{\}.
  36. @item
  37. Note that whitespace in metadata (e.g. @samp{foo = bar}) is considered to be
  38. a part of the tag (in the example above key is @samp{foo }, value is
  39. @samp{ bar}).
  40. @end enumerate
  41. A ffmetadata file might look like this:
  42. @example
  43. ;FFMETADATA1
  44. title=bike\\shed
  45. ;this is a comment
  46. artist=FFmpeg troll team
  47. [CHAPTER]
  48. TIMEBASE=1/1000
  49. START=0
  50. #chapter ends at 0:01:00
  51. END=60000
  52. title=chapter \#1
  53. [STREAM]
  54. title=multi\
  55. line
  56. @end example
  57. By using the ffmetadata muxer and demuxer it is possible to extract
  58. metadata from an input file to an ffmetadata file, and then transcode
  59. the file into an output file with the edited ffmetadata file.
  60. Extracting an ffmetadata file with @file{ffmpeg} goes as follows:
  61. @example
  62. ffmpeg -i INPUT -f ffmetadata FFMETADATAFILE
  63. @end example
  64. Reinserting edited metadata information from the FFMETADATAFILE file can
  65. be done as:
  66. @example
  67. ffmpeg -i INPUT -i FFMETADATAFILE -map_metadata 1 -codec copy OUTPUT
  68. @end example
  69. @c man end METADATA