Increase Nginx upload limit to 100m, improve related docs [#5496].
[mediagoblin.git] / docs / source / siteadmin / media-types.rst
CommitLineData
473a4431
CAW
1.. MediaGoblin Documentation
2
8af91cea 3 Written in 2011, 2012, 2014, 2015 by MediaGoblin contributors
473a4431
CAW
4
5 To the extent possible under law, the author(s) have dedicated all
6 copyright and related and neighboring rights to this software to
7 the public domain worldwide. This software is distributed without
8 any warranty.
9
10 You should have received a copy of the CC0 Public Domain
11 Dedication along with this software. If not, see
12 <http://creativecommons.org/publicdomain/zero/1.0/>.
13
9bc2fc6c
CAW
14.. _media-types-chapter:
15
16====================
d34757dc 17Media Types
9bc2fc6c
CAW
18====================
19
20In the future, there will be all sorts of media types you can enable,
ffbf9c8b 21but in the meanwhile there are six additional media types: video, audio,
9650aa39 22raw image, ASCII art, STL/3D models, PDF and Document.
9bc2fc6c
CAW
23
24First, you should probably read ":doc:`configuration`" to make sure
9650aa39 25you know how to modify the MediaGoblin config file.
9bc2fc6c 26
d34757dc
JW
27Enabling Media Types
28====================
29
91bee92e
RE
30.. note::
31 Media types are now plugins
32
f5e48d9e 33Media types are enabled in your MediaGoblin configuration file.
d34757dc 34
3a1fb089
BS
35Most media types require **additional dependencies** that you will have to install. You
36will find descriptions on how to satisfy the requirements of each media type
37below.
d34757dc 38
91bee92e 39To enable a media type, add the the media type under the ``[plugins]`` section
f5e48d9e 40in you ``mediagoblin.ini``. For example, if your system supported image
91bee92e 41and video media types, then it would look like this::
d34757dc 42
91bee92e
RE
43 [plugins]
44 [[mediagoblin.media_types.image]]
45 [[mediagoblin.media_types.video]]
d34757dc 46
3a1fb089
BS
47Note that after enabling new media types, you must run dbupdate. If you have
48deployed MediaGoblin as an unprivileged user as described in
49":doc:`production-deployments`", you'll first need to switch to this account::
9d5cd0b9 50
3a1fb089
BS
51 sudo su mediagoblin --shell=/bin/bash
52 $ cd /srv/mediagoblin.example.org/mediagoblin
53
54Now run dbupdate::
55
56 $ ./bin/gmg dbupdate
9d5cd0b9
CAW
57
58If you are running an active site, depending on your server
59configuration, you may need to stop it first (and it's certainly a
60good idea to restart it after the update).
61
62
d34757dc
JW
63How does MediaGoblin decide which media type to use for a file?
64===============================================================
65
66MediaGoblin has two methods for finding the right media type for an uploaded
67file. One is based on the file extension of the uploaded file; every media type
68maintains a list of supported file extensions. The second is based on a sniffing
69handler, where every media type may inspect the uploaded file and tell if it
70will accept it.
71
72The file-extension-based approach is used before the sniffing-based approach,
73if the file-extension-based approach finds a match, the sniffing-based approach
74will be skipped as it uses far more processing power.
75
63b5959f
LD
76Configuring Media Types
77=======================
78
79Each media type has a ``config_spec.ini`` file with configurable
80options and comments explaining their intended side effect. For
81instance the ``video`` media type configuration can be found in
82``mediagoblin/media_types/video/config_spec.ini``.
83
d34757dc 84
3a1fb089 85Audio
9bc2fc6c
CAW
86=====
87
3a1fb089
BS
88To enable audio, install the GStreamer and python-gstreamer bindings (as well
89as whatever GStreamer plugins you want, good/bad/ugly):
9bc2fc6c 90
3a8b18f8
JW
91.. code-block:: bash
92
3a1fb089
BS
93 # Debian and co.
94 sudo apt install python3-gst-1.0 gstreamer1.0-plugins-{base,bad,good,ugly} \
95 gstreamer1.0-libav
5ef7ab08 96
3a1fb089
BS
97 # Fedora and co.
98 sudo dnf install gstreamer1-plugins-{base,bad-free,good,ugly-free}
3a8b18f8 99
3a1fb089
BS
100Add ``[[mediagoblin.media_types.audio]]`` under the ``[plugins]`` section in your
101``mediagoblin.ini`` and update MediaGoblin::
9bc2fc6c 102
3a1fb089 103 $ ./bin/gmg dbupdate
7798f911 104
3a1fb089
BS
105Restart MediaGoblin (and Celery if applicable). You should now be able to upload
106and listen to audio files!
efd69313 107
5224d700
BS
108On production deployments, you will need to increase Nginx's
109``client_max_body_size`` to allow larger files to be uploaded, or you'll get a
110"413 Request Entity Too Large" error. See ":ref:`webserver-config`".
111
112Production deployments will also need a separate process to transcode media in
113the background. See ":ref:`systemd-service-files`" and
114":ref:`separate-celery`" sections of this manual.
115
116.. note::
117
118 MediaGoblin previously generated spectrograms for uploaded audio. This
119 feature has been removed due to incompatibility with Python 3. We may
120 consider re-adding this feature in the future.
121
efd69313 122
3a1fb089 123Video
d34757dc
JW
124=====
125
3a1fb089
BS
126To enable video, first install GStreamer and the python-gstreamer
127bindings (as well as whatever GStreamer extensions you want,
128good/bad/ugly):
d34757dc 129
3a1fb089
BS
130.. code-block:: bash
131
132 # Debian and co.
133 sudo apt install python3-gi gstreamer1.0-tools gir1.2-gstreamer-1.0 \
134 gir1.2-gst-plugins-base-1.0 gstreamer1.0-plugins-{good,bad,ugly} \
135 gstreamer1.0-libav python3-gst-1.0
d34757dc 136
34a85313 137.. note::
97dcfe37 138
3a1fb089
BS
139 We unfortunately do not have working installation instructions for Fedora and
140 co. Some incomplete information is available on the `Hacking Howto wiki page <http://wiki.mediagoblin.org/HackingHowto#Fedora_.2F_RedHat.28.3F.29_.2F_CentOS>`_
141
142Add ``[[mediagoblin.media_types.video]]`` under the ``[plugins]`` section in
143your ``mediagoblin.ini`` and restart MediaGoblin.
5ef7ab08 144
3a1fb089 145Run::
3a8b18f8 146
3a1fb089
BS
147 $ ./bin/gmg dbupdate
148
149Restart MediaGoblin (and Celery if applicable). Now you should be able to submit
150videos, and MediaGoblin should transcode them.
3fe3b222 151
5224d700
BS
152On production deployments, you will need to increase Nginx's
153``client_max_body_size`` to allow larger files to be uploaded, or you'll get a
154"413 Request Entity Too Large" error. See ":ref:`webserver-config`".
5ef7ab08 155
5224d700
BS
156Production deployments will also need a separate process to transcode media in
157the background. To set that up, check out the ":doc:`deploying`" and
158":doc:`production-deployments`" sections of this manual.
d34757dc
JW
159
160
ffbf9c8b
OHO
161Raw image
162=========
163
3a1fb089 164To enable raw image you need to install pyexiv2::
ffbf9c8b 165
3a1fb089
BS
166 # Debian and co.
167 sudo apt install python3-pyexiv2
ffbf9c8b
OHO
168
169Add ``[[mediagoblin.media_types.raw_image]]`` under the ``[plugins]``
f5e48d9e 170section in your ``mediagoblin.ini`` and restart MediaGoblin.
ffbf9c8b 171
3a1fb089 172Run::
ffbf9c8b 173
3a1fb089 174 $ ./bin/gmg dbupdate
ffbf9c8b 175
3a1fb089
BS
176Restart MediaGoblin (and Celery if applicable). Now you should be able to submit
177raw images, and MediaGoblin should extract the JPEG preview from them.
ffbf9c8b
OHO
178
179
9650aa39 180ASCII art
efd69313
CAW
181=========
182
9650aa39 183To enable ASCII art support, first install the
efd69313 184`chardet <http://pypi.python.org/pypi/chardet>`_
3a1fb089 185library, which is necessary for creating thumbnails of ASCII art::
3a8b18f8 186
3a1fb089 187 $ ./bin/easy_install chardet
efd69313
CAW
188
189
f5e48d9e 190Next, modify your ``mediagoblin.ini``. In the ``[plugins]`` section, add
91bee92e 191``[[mediagoblin.media_types.ascii]]``.
efd69313 192
3a1fb089 193Run::
3fe3b222 194
3a1fb089 195 $ ./bin/gmg dbupdate
5ef7ab08 196
3a1fb089
BS
197Restart MediaGoblin (and Celery if applicable). Now any .txt file you uploaded
198will be processed as ASCII art!
5ef7ab08
CAW
199
200
9650aa39 201STL / 3D model support
5ef7ab08
CAW
202======================
203
9650aa39
BS
204To enable the "STL" 3D model support plugin, first make sure you have
205a recent `Blender <http://blender.org>`_ installed and available on
5ef7ab08
CAW
206your execution path. This feature has been tested with Blender 2.63.
207It may work on some earlier versions, but that is not guaranteed (and
208is surely not to work prior to Blender 2.5X).
209
91bee92e 210Add ``[[mediagoblin.media_types.stl]]`` under the ``[plugins]`` section in your
f5e48d9e 211``mediagoblin.ini`` and restart MediaGoblin.
5ef7ab08 212
3a1fb089 213Run::
3a8b18f8 214
3a1fb089 215 $ ./bin/gmg dbupdate
3fe3b222 216
3a1fb089
BS
217Restart MediaGoblin (and Celery if applicable). You should now be able to upload
218.obj and .stl files and MediaGoblin will be able to present them to your wide
219audience of admirers!
5ef7ab08 220
a80ebf3b
AL
221
222PDF and Document
223================
224
376dcbb4
AL
225To enable the "PDF and Document" support plugin, you need:
226
9650aa39 2271. pdftocairo and pdfinfo for PDF only support.
376dcbb4 228
9650aa39 2292. unoconv with headless support to support converting LibreOffice supported
376dcbb4
AL
230 documents as well, such as doc/ppt/xls/odf/odg/odp and more.
231 For the full list see mediagoblin/media_types/pdf/processing.py,
232 unoconv_supported.
233
234All executables must be on your execution path.
a80ebf3b 235
3a1fb089 236To install this on Fedora::
a80ebf3b 237
3a1fb089 238 sudo dnf install poppler-utils unoconv libreoffice-headless
a80ebf3b 239
9650aa39 240Note: You can leave out unoconv and libreoffice-headless if you want only PDF
376dcbb4
AL
241support. This will result in a much smaller list of dependencies.
242
3a1fb089 243pdf.js relies on git submodules, so be sure you have fetched them::
a80ebf3b 244
3a1fb089
BS
245 $ git submodule init
246 $ git submodule update
a80ebf3b
AL
247
248This feature has been tested on Fedora with:
249 poppler-utils-0.20.2-9.fc18.x86_64
250 unoconv-0.5-2.fc18.noarch
251 libreoffice-headless-3.6.5.2-8.fc18.x86_64
252
253It may work on some earlier versions, but that is not guaranteed.
254
91bee92e 255Add ``[[mediagoblin.media_types.pdf]]`` under the ``[plugins]`` section in your
f5e48d9e 256``mediagoblin.ini`` and restart MediaGoblin.
a80ebf3b 257
3a1fb089 258Run::
a80ebf3b 259
3a1fb089 260 $ ./bin/gmg dbupdate
a80ebf3b
AL
261
262
b7d854bf
CAW
263Blog (HIGHLY EXPERIMENTAL)
264==========================
265
266MediaGoblin has a blog media type, which you might notice by looking
267through the docs! However, it is *highly experimental*. We have not
268security reviewed this, and it acts in a way that is not like normal
9650aa39 269blogs (the blog posts are themselves media types!).
b7d854bf 270
2352f7c8
CAW
271So you can play with this, but it is not necessarily recommended yet
272for production use! :)