| 1 |
/* Copyright (C) 2008, 2009 Vincent Penquerc'h. |
| 2 |
This file is part of the Kate codec library. |
| 3 |
Written by Vincent Penquerc'h. |
| 4 |
|
| 5 |
Use, distribution and reproduction of this library is governed |
| 6 |
by a BSD style source license included with this source in the |
| 7 |
file 'COPYING'. Please read these terms before distributing. */ |
| 8 |
|
| 9 |
|
| 10 |
/** |
| 11 |
|
| 12 |
\page HOWTO |
| 13 |
|
| 14 |
|
| 15 |
\section HOWTO-text-subtitles Text movie subtitles |
| 16 |
|
| 17 |
Kate streams can carry Unicode text (that is, text that can represent |
| 18 |
pretty much any existing language/script). If several Kate streams are |
| 19 |
multiplexed along with a video, subtitles in various languages can be |
| 20 |
made for that movie. |
| 21 |
|
| 22 |
An easy way to create such subtitles is to use ffmpeg2theora, which |
| 23 |
can create Kate streams from SubRip (.srt) format files, a simple but |
| 24 |
common text subtitles format. ffmpeg2theora 0.21 or later is needed. |
| 25 |
|
| 26 |
At its simplest: |
| 27 |
|
| 28 |
\verbatim |
| 29 |
ffmpeg2theora -o video-with-subtitles.ogg --subtitles subtitles.srt |
| 30 |
video-without-subtitles.avi |
| 31 |
\endverbatim |
| 32 |
|
| 33 |
Several languages may be created and tagged with their language code |
| 34 |
for easy selection in a media player: |
| 35 |
|
| 36 |
\verbatim |
| 37 |
ffmpeg2theora -o video-with-subtitles.ogg video-without-subtitles.avi |
| 38 |
--subtitles japanese-subtitles.srt --subtitles-language ja |
| 39 |
--subtitles welsh-subtitles.srt --subtitles-language cy |
| 40 |
--subtitles english-subtitles.srt --subtitles-language en_GB |
| 41 |
\endverbatim |
| 42 |
|
| 43 |
Alternatively, kateenc (which comes with the libkate distribution) can |
| 44 |
create Kate streams from SubRip files as well. These can then be merged |
| 45 |
with a video with oggz-tools: |
| 46 |
|
| 47 |
\verbatim |
| 48 |
kateenc -t srt -c SUB -l it -o subtitles.ogg italian-subtitles.srt |
| 49 |
|
| 50 |
oggz merge -o movie-with-subtitles.ogg movie-without-subtitles.ogg subtitles.ogg |
| 51 |
\endverbatim |
| 52 |
|
| 53 |
This second method can also be used to add subtitles to a video which |
| 54 |
is already encoded to Theora, as it will not transcode the video again. |
| 55 |
|
| 56 |
|
| 57 |
\section HOWTO-DVD-subtitles DVD subtitles |
| 58 |
|
| 59 |
DVD subtitles are not text, but images. Thoggen, a DVD ripper program, |
| 60 |
can convert these subtitles to Kate streams (at the time of writing, |
| 61 |
Thoggen and GStreamer have not applied the necessary patches for this |
| 62 |
to be possible out of the box, so patching them will be required). |
| 63 |
|
| 64 |
When configuring how to rip DVD tracks, any subtitles will be detected |
| 65 |
by Thoggen, and selecting them in the GUI will cause them to be saved as |
| 66 |
Kate tracks along with the movie. |
| 67 |
|
| 68 |
|
| 69 |
\section HOWTO-lyrics Song lyrics |
| 70 |
|
| 71 |
Kate streams carrying song lyrics can be embedded in an Ogg file. The |
| 72 |
oggenc Vorbis encoding tool from the Xiph.Org Vorbis tools allows lyrics |
| 73 |
to be loaded from a LRC or SRT text file and converted to a Kate stream |
| 74 |
multiplexed with the resulting Vorbis audio. At the time of writing, |
| 75 |
the patch to oggenc was not applied yet, so it will have to be patched |
| 76 |
manually with the patch found in the diffs directory. |
| 77 |
|
| 78 |
\verbatim |
| 79 |
oggenc -o song-with-lyrics.ogg --lyrics lyrics.lrc --lyrics-language en_US song.wav |
| 80 |
\endverbatim |
| 81 |
|
| 82 |
So called 'enhanced LRC' files (containing extra karaoke timing information) |
| 83 |
are supported, and a simple karaoke color change scheme will be saved |
| 84 |
out for these files. For more complex karaoke effects (such as more |
| 85 |
complex style changes, or sprite animation), kateenc should be used with |
| 86 |
a Kate description file to create a separate Kate stream, which can then |
| 87 |
be merged with a Vorbis only song with oggz-tools: |
| 88 |
|
| 89 |
\verbatim |
| 90 |
oggenc -o song.ogg song.wav |
| 91 |
|
| 92 |
kateenc -t kate -c LRC -l en_US -o lyrics.ogg lyrics-with-karaoke.kate |
| 93 |
|
| 94 |
oggz merge -o song-with-karaoke.ogg lyrics-with-karaoke.ogg song.ogg |
| 95 |
\endverbatim |
| 96 |
|
| 97 |
This latter method may also be used if you already have an encoded Vorbis song |
| 98 |
with no lyrics, and just want to add the lyrics without reencoding. |
| 99 |
|
| 100 |
|
| 101 |
\section HOWTO-remuxing Changing a Kate stream embedded in an Ogg stream |
| 102 |
|
| 103 |
If you need to change a Kate stream already embedded in an Ogg stream |
| 104 |
(eg, you have a movie with subtitles, and you want to fix a spelling |
| 105 |
mistake, or want to bring one of the subtitles forward in time, etc), |
| 106 |
you can do this easily with KateDJ, a tool that will extract Kate streams, |
| 107 |
decode them to a temporary location, and rebuild the original stream |
| 108 |
after you've made whatever changes you want. |
| 109 |
|
| 110 |
KateDJ (included with the libkate distribution) is a GUI program using |
| 111 |
wxPython, a Python module for the wxWidgets GUI library, and the oggz |
| 112 |
tools (both needing installing separately if they are not already). |
| 113 |
|
| 114 |
The procedure consists of: |
| 115 |
- Run KateDJ |
| 116 |
- Click 'Load Ogg stream' and select the file to load |
| 117 |
- Click 'Demux file' to decode Kate streams in a temporary location |
| 118 |
- Edit the Kate streams - you can also double click on the language you want to change |
| 119 |
- When done, click 'Remux file from parts' |
| 120 |
- If any errors are reported, continue editing until the remux step succeeds |
| 121 |
|
| 122 |
|
| 123 |
\section HOWTO-metadata Adding metadata |
| 124 |
|
| 125 |
Metadata can be attached to events, or to styles, bitmaps, regions, etc. |
| 126 |
Metadata are free form tag/value pairs, and can be used to enrich their |
| 127 |
attached data with extra information. However, how this information is |
| 128 |
interpreted is up to the application layer. |
| 129 |
|
| 130 |
It is worth noting that an event may not have attached text, so it is |
| 131 |
possible to create an empty timed event with attached metadata. |
| 132 |
|
| 133 |
For instance, let's say we have a documentary, with footage from various |
| 134 |
places, as well as short interviews, and we want two things: |
| 135 |
- tag footage with metadata about the location and date that footage was shot |
| 136 |
- subtitle the interviews and tag those subtitles with information about the speaker |
| 137 |
|
| 138 |
You can then create an empty Kate event for each footage part, synchronized |
| 139 |
with the footage, and attach a new metadata item called GEO_LOCATION, filled |
| 140 |
with latitude and longitude of the place the footage was shot at. |
| 141 |
Similarly, for each subtitle event, a metadata item called SPEAKER can be |
| 142 |
attached. |
| 143 |
|
| 144 |
An empty event to tag a long 4:20 footage shot in Tokyo on 2011/08/12, and |
| 145 |
inserted at 18:30 in the documentary could look like: |
| 146 |
|
| 147 |
event { |
| 148 |
00:18:30,000 --> 00:22:50,000 |
| 149 |
meta "GEO_LOCATION" = "35.42; 139.42" |
| 150 |
meta "DATE" = "2011-08-12" |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
Here's a example for a line spoken by Dr Joe Bloggs at 18:30 into the documentary: |
| 155 |
|
| 156 |
event { |
| 157 |
00:18:30,000 --> 00:18:32,000 |
| 158 |
"Notice how the subtitles for my words have metadata attached to them" |
| 159 |
meta "SPEAKER" = "Dr Joe Bloggs" |
| 160 |
meta "URL" = "http://www.example.com/biography?name=Joe+Bloggs" |
| 161 |
} |
| 162 |
|
| 163 |
Notice how another metadata item, URL, is also present. The application |
| 164 |
will have to be aware of those metadata in order to do something with it |
| 165 |
though. Since those are free form, it is up to you to think of what |
| 166 |
metadata you want, and make use of it. |
| 167 |
|
| 168 |
Note that metadata may be attached to other objects, such as regions. |
| 169 |
This way, you can for example create a region tagged with a name, and |
| 170 |
track a person's movements with that region. Or you can tag a bitmap |
| 171 |
with a copyright and a URL to a larger version of the image. |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
*/ |