| 1 |
===================================== |
| 2 |
The `media4svg' LaTeX Package |
| 3 |
|
| 4 |
Version 0.13, 2022/10/12 |
| 5 |
|
| 6 |
https://gitlab.com/agrahn/media4svg |
| 7 |
|
| 8 |
(C) 2020--\today Alexander Grahn |
| 9 |
===================================== |
| 10 |
|
| 11 |
|
| 12 |
1. Introduction |
| 13 |
=============== |
| 14 |
|
| 15 |
This package implements an interface for embedding video and audio files and |
| 16 |
the YouTube player in SVG (Scalable Vector Graphics) output. SVG with embedded |
| 17 |
media is very portable, as it is supported by all modern Web browsers across a |
| 18 |
variety of operating systems and platforms, including portable devices. |
| 19 |
|
| 20 |
The most portable media formats are as follows: |
| 21 |
|
| 22 |
Video: |
| 23 |
|
| 24 |
| File extension | Codecs | MIME-type | |
| 25 |
|----------------|----------------------|------------| |
| 26 |
| mp4 | v: h264, a: AAC | video/mp4 | |
| 27 |
| webm | v: VP8, a: Vorbis | video/webm | |
| 28 |
| ogg | v: Theora, a: Vorbis | video/ogg | |
| 29 |
|
| 30 |
Audio: |
| 31 |
|
| 32 |
| File extension | MIME-type | |
| 33 |
|----------------|------------| |
| 34 |
| mp3 | audio/mpeg | |
| 35 |
| ogg | audio/ogg | |
| 36 |
| wav | audio/wav | |
| 37 |
|
| 38 |
In the world of TeX and LaTeX, SVG is produced by means of the `dvisvgm' |
| 39 |
(https://dvisvgm.de) backend by M. Gieseking, which is included in TeXLive |
| 40 |
and MiKTeX. |
| 41 |
|
| 42 |
Supported workflows are: |
| 43 |
|
| 44 |
* dvilualatex --> dvisvgm |
| 45 |
* [p|up]latex --> dvisvgm |
| 46 |
* xelatex --no-pdf --> dvisvgm |
| 47 |
|
| 48 |
All TeX engines that produce DVI/XDV output can be used, but `dvilualatex' is |
| 49 |
to be preferred. By default, media data are physically embedded into the SVG |
| 50 |
output. For this, they need to be Base64 encoded, which is done by the |
| 51 |
built-in Lua interpreter of LuaTeX. The other, non-LuaTeX-based engines call |
| 52 |
the Lua script for Base64-encoding as an external program via shell-escape, |
| 53 |
which is much slower. |
| 54 |
|
| 55 |
There are a number of `dvisvgm' commandline options that should be used in general: |
| 56 |
|
| 57 |
dvisvgm --zoom=-1 --exact --page=1,- --font-format=woff2 <DVI/XDV file> |
| 58 |
|
| 59 |
For exporting `beamer'-class documents to SVG, option `--box=papersize' |
| 60 |
should also be added. Refer to the manual page, `man dvisvgm', for additional |
| 61 |
information. |
| 62 |
|
| 63 |
|
| 64 |
2. Example |
| 65 |
========== |
| 66 |
|
| 67 |
An example presentation with an embedded local video file as well as with video |
| 68 |
streamed from a URL and a YouTube player can be found here: |
| 69 |
|
| 70 |
http://mirrors.ctan.org/macros/latex/contrib/media4svg/example/beamer-example-1.svg |
| 71 |
|
| 72 |
The source is: |
| 73 |
|
| 74 |
http://mirrors.ctan.org/macros/latex/contrib/media4svg/example/beamer-example.tex |
| 75 |
|
| 76 |
It also explains how to use the mouse and the keyboard for playback control. |
| 77 |
|
| 78 |
|
| 79 |
3. Usage |
| 80 |
======== |
| 81 |
|
| 82 |
Option `dvisvgm' must be set globally by passing it to the document class. |
| 83 |
|
| 84 |
\documentclass[dvisvgm]{...} |
| 85 |
|
| 86 |
The package itself is loaded with |
| 87 |
|
| 88 |
\usepackage[<options>]{media4svg} |
| 89 |
|
| 90 |
|
| 91 |
Package options are: `draft', `final', `autoplay', `loop', `controls', |
| 92 |
`mimetype', `width', `height', `totalheight', `keepaspectratio', `scale', |
| 93 |
`url', `youtube', `vimeo', `embed'. They have the same meaning as the command |
| 94 |
options explained below, but are applied globally. |
| 95 |
|
| 96 |
Note that `media4svg' is incompatible with package `media9'. |
| 97 |
|
| 98 |
The command for media inclusion is |
| 99 |
|
| 100 |
\includemedia[<options>[, url]]{<poster text>}{<media file or URL>} |
| 101 |
|
| 102 |
or |
| 103 |
|
| 104 |
\includemedia[<options>, youtube]{<poster text>}{<YT video ID>[,<YT video ID 2>[, ...]]} |
| 105 |
\includemedia[<options>, vimeo]{<poster text>}{<Vimeo video ID>} |
| 106 |
|
| 107 |
Command options: |
| 108 |
|
| 109 |
id=<label> |
| 110 |
|
| 111 |
The media is given an ID by which it can be referenced in JavaScript code, as |
| 112 |
in `$("myVid").play();', for example. |
| 113 |
|
| 114 |
draft |
| 115 |
final |
| 116 |
|
| 117 |
These have the usual meaning. If `draft' is set, a box is inserted into the |
| 118 |
document instead of the media display. |
| 119 |
|
| 120 |
autoplay |
| 121 |
|
| 122 |
Media playback is started after the page has been loaded in the web browser. |
| 123 |
Depending on their settings, browsers may refuse to autoplay multimedia with |
| 124 |
unmuted audio. Option `muted' may need to be set as well to allow playback to |
| 125 |
be started automatically. |
| 126 |
|
| 127 |
loop |
| 128 |
|
| 129 |
Media is played in a loop. |
| 130 |
|
| 131 |
muted |
| 132 |
|
| 133 |
The audio will be initially silenced. |
| 134 |
|
| 135 |
time=<time offset> |
| 136 |
|
| 137 |
Playback starts with an offset, specified in seconds. |
| 138 |
|
| 139 |
controls |
| 140 |
|
| 141 |
Player-specific controls are shown as an overlay in the media display. |
| 142 |
|
| 143 |
mimetype=<mime type> |
| 144 |
|
| 145 |
Although optional, it may be a good idea to give a hint to the web browser |
| 146 |
about the kind of media to be played, such as `audio/mpeg' or `video/mp4'. |
| 147 |
|
| 148 |
url |
| 149 |
|
| 150 |
The last argument of `\includemedia' is taken as a URL and media data will not |
| 151 |
be embedded in the SVG file. |
| 152 |
|
| 153 |
youtube |
| 154 |
|
| 155 |
Embeds a YouTube player. The last argument of `\includemedia' is a single or a |
| 156 |
comma-separated list of YouTube video IDs. |
| 157 |
|
| 158 |
vimeo |
| 159 |
|
| 160 |
Embeds a Vimeo player. The last argument of `\includemedia' is a Vimeo video |
| 161 |
ID. Only a single ID is allowed. |
| 162 |
|
| 163 |
embed=false |
| 164 |
|
| 165 |
By default, a local media file, given as the last argument of `\includemedia', |
| 166 |
is encoded and embedded as a data blob into the SVG output. Option `embed=false' |
| 167 |
suppresses embedding and the media file remains separate. |
| 168 |
|
| 169 |
width=<h-size> |
| 170 |
height=<v-size> | totalheight=<v-size> |
| 171 |
keepaspectratio |
| 172 |
|
| 173 |
Resize the media display or set its size if <poster text> is left empty. If |
| 174 |
provided, <poster text> is squeezed or stretched according to the given |
| 175 |
options. If only one of `width' or `[total]height' is given, the other |
| 176 |
dimension is scaled to maintain the aspect ratio of <poster text>. If both |
| 177 |
`width' and `[total]height' are given together with `keepaspectratio', |
| 178 |
<poster text> is resized to fit within <h-size> and <v-size> while |
| 179 |
maintaining its original aspect ratio. Any valid TeX dimension is acceptable |
| 180 |
for <h-size> and <v-size>. In addition, the length commands `\width', |
| 181 |
`\height', `\depth' and `\totalheight' can be used to refer to the original |
| 182 |
dimensions of <poster text>. |
| 183 |
|
| 184 |
scale=<factor> |
| 185 |
|
| 186 |
Scales the media display by <factor>. |
| 187 |
|
| 188 |
|
| 189 |
* * * |
| 190 |
|
| 191 |
|
| 192 |
This material is subject to the LaTeX Project Public License. See |
| 193 |
|
| 194 |
http://www.latex-project.org/lppl.txt |
| 195 |
|
| 196 |
for the details of that license. |