media-types.rst 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. .. MediaGoblin Documentation
  2. Written in 2011, 2012, 2014, 2015 by MediaGoblin contributors
  3. To the extent possible under law, the author(s) have dedicated all
  4. copyright and related and neighboring rights to this software to
  5. the public domain worldwide. This software is distributed without
  6. any warranty.
  7. You should have received a copy of the CC0 Public Domain
  8. Dedication along with this software. If not, see
  9. <http://creativecommons.org/publicdomain/zero/1.0/>.
  10. .. _media-types-chapter:
  11. ====================
  12. Media Types
  13. ====================
  14. In the future, there will be all sorts of media types you can enable,
  15. but in the meanwhile there are six additional media types: video, audio,
  16. raw image, ascii art, STL/3d models, PDF and Document.
  17. First, you should probably read ":doc:`configuration`" to make sure
  18. you know how to modify the mediagoblin config file.
  19. Enabling Media Types
  20. ====================
  21. .. note::
  22. Media types are now plugins
  23. Media types are enabled in your mediagoblin configuration file, typically it is
  24. created by copying ``mediagoblin.ini`` to ``mediagoblin_local.ini`` and then
  25. applying your changes to ``mediagoblin_local.ini``. If you don't already have a
  26. ``mediagoblin_local.ini``, create one in the way described.
  27. Most media types have additional dependencies that you will have to install.
  28. You will find descriptions on how to satisfy the requirements of each media type
  29. on this page.
  30. To enable a media type, add the the media type under the ``[plugins]`` section
  31. in you ``mediagoblin_local.ini``. For example, if your system supported image
  32. and video media types, then it would look like this::
  33. [plugins]
  34. [[mediagoblin.media_types.image]]
  35. [[mediagoblin.media_types.video]]
  36. Note that after enabling new media types, you must run dbupdate like so::
  37. ./bin/gmg dbupdate
  38. If you are running an active site, depending on your server
  39. configuration, you may need to stop it first (and it's certainly a
  40. good idea to restart it after the update).
  41. How does MediaGoblin decide which media type to use for a file?
  42. ===============================================================
  43. MediaGoblin has two methods for finding the right media type for an uploaded
  44. file. One is based on the file extension of the uploaded file; every media type
  45. maintains a list of supported file extensions. The second is based on a sniffing
  46. handler, where every media type may inspect the uploaded file and tell if it
  47. will accept it.
  48. The file-extension-based approach is used before the sniffing-based approach,
  49. if the file-extension-based approach finds a match, the sniffing-based approach
  50. will be skipped as it uses far more processing power.
  51. Configuring Media Types
  52. =======================
  53. Each media type has a ``config_spec.ini`` file with configurable
  54. options and comments explaining their intended side effect. For
  55. instance the ``video`` media type configuration can be found in
  56. ``mediagoblin/media_types/video/config_spec.ini``.
  57. Video
  58. =====
  59. To enable video, first install gstreamer and the python-gstreamer
  60. bindings (as well as whatever gstremaer extensions you want,
  61. good/bad/ugly). On Debianoid systems
  62. .. code-block:: bash
  63. sudo apt-get install python-gi python3-gi \
  64. gstreamer1.0-tools \
  65. gir1.2-gstreamer-1.0 \
  66. gir1.2-gst-plugins-base-1.0 \
  67. gstreamer1.0-plugins-good \
  68. gstreamer1.0-plugins-ugly \
  69. gstreamer1.0-plugins-bad \
  70. gstreamer1.0-libav \
  71. python-gst-1.0
  72. Add ``[[mediagoblin.media_types.video]]`` under the ``[plugins]`` section in
  73. your ``mediagoblin_local.ini`` and restart MediaGoblin.
  74. Run
  75. .. code-block:: bash
  76. ./bin/gmg dbupdate
  77. Now you should be able to submit videos, and mediagoblin should
  78. transcode them.
  79. .. note::
  80. You almost certainly want to separate Celery from the normal
  81. paste process or your users will probably find that their connections
  82. time out as the video transcodes. To set that up, check out the
  83. ":doc:`production-deployments`" section of this manual.
  84. Audio
  85. =====
  86. To enable audio, install the gstreamer and python-gstreamer bindings (as well
  87. as whatever gstreamer plugins you want, good/bad/ugly), scipy and numpy are
  88. also needed for the audio spectrograms.
  89. To install these on Debianoid systems, run::
  90. sudo apt-get install python-gst-1.0 gstreamer1.0-plugins-{base,bad,good,ugly} \
  91. gstreamer1.0-libav python-numpy python-scipy libsndfile1-dev libasound2-dev
  92. .. note::
  93. scikits.audiolab will display a warning every time it's imported if you do
  94. not compile it with alsa support. Alsa support is not necessary for the GNU
  95. MediaGoblin application.
  96. Then install ``scikits.audiolab`` for the spectrograms::
  97. ./bin/pip install scikits.audiolab
  98. Add ``[[mediagoblin.media_types.audio]]`` under the ``[plugins]`` section in your
  99. ``mediagoblin_local.ini`` and restart MediaGoblin.
  100. Run
  101. .. code-block:: bash
  102. ./bin/gmg dbupdate
  103. You should now be able to upload and listen to audio files!
  104. Raw image
  105. =========
  106. To enable raw image you need to install pyexiv2. On Debianoid systems
  107. .. code-block:: bash
  108. sudo apt-get install python-pyexiv2
  109. Add ``[[mediagoblin.media_types.raw_image]]`` under the ``[plugins]``
  110. section in your ``mediagoblin_local.ini`` and restart MediaGoblin.
  111. Run
  112. .. code-block:: bash
  113. ./bin/gmg dbupdate
  114. Now you should be able to submit raw images, and mediagoblin should
  115. extract the JPEG preview from them.
  116. Ascii art
  117. =========
  118. To enable ascii art support, first install the
  119. `chardet <http://pypi.python.org/pypi/chardet>`_
  120. library, which is necessary for creating thumbnails of ascii art
  121. .. code-block:: bash
  122. ./bin/easy_install chardet
  123. Next, modify (and possibly copy over from ``mediagoblin.ini``) your
  124. ``mediagoblin_local.ini``. In the ``[plugins]`` section, add
  125. ``[[mediagoblin.media_types.ascii]]``.
  126. Run
  127. .. code-block:: bash
  128. ./bin/gmg dbupdate
  129. Now any .txt file you uploaded will be processed as ascii art!
  130. STL / 3d model support
  131. ======================
  132. To enable the "STL" 3d model support plugin, first make sure you have
  133. a recentish `Blender <http://blender.org>`_ installed and available on
  134. your execution path. This feature has been tested with Blender 2.63.
  135. It may work on some earlier versions, but that is not guaranteed (and
  136. is surely not to work prior to Blender 2.5X).
  137. Add ``[[mediagoblin.media_types.stl]]`` under the ``[plugins]`` section in your
  138. ``mediagoblin_local.ini`` and restart MediaGoblin.
  139. Run
  140. .. code-block:: bash
  141. ./bin/gmg dbupdate
  142. You should now be able to upload .obj and .stl files and MediaGoblin
  143. will be able to present them to your wide audience of admirers!
  144. PDF and Document
  145. ================
  146. To enable the "PDF and Document" support plugin, you need:
  147. 1. pdftocairo and pdfinfo for pdf only support.
  148. 2. unoconv with headless support to support converting libreoffice supported
  149. documents as well, such as doc/ppt/xls/odf/odg/odp and more.
  150. For the full list see mediagoblin/media_types/pdf/processing.py,
  151. unoconv_supported.
  152. All executables must be on your execution path.
  153. To install this on Fedora:
  154. .. code-block:: bash
  155. sudo yum install -y poppler-utils unoconv libreoffice-headless
  156. Note: You can leave out unoconv and libreoffice-headless if you want only pdf
  157. support. This will result in a much smaller list of dependencies.
  158. pdf.js relies on git submodules, so be sure you have fetched them:
  159. .. code-block:: bash
  160. git submodule init
  161. git submodule update
  162. This feature has been tested on Fedora with:
  163. poppler-utils-0.20.2-9.fc18.x86_64
  164. unoconv-0.5-2.fc18.noarch
  165. libreoffice-headless-3.6.5.2-8.fc18.x86_64
  166. It may work on some earlier versions, but that is not guaranteed.
  167. Add ``[[mediagoblin.media_types.pdf]]`` under the ``[plugins]`` section in your
  168. ``mediagoblin_local.ini`` and restart MediaGoblin.
  169. Run
  170. .. code-block:: bash
  171. ./bin/gmg dbupdate
  172. Blog (HIGHLY EXPERIMENTAL)
  173. ==========================
  174. MediaGoblin has a blog media type, which you might notice by looking
  175. through the docs! However, it is *highly experimental*. We have not
  176. security reviewed this, and it acts in a way that is not like normal
  177. blogs (the blogposts are themselves media types!).
  178. So you can play with this, but it is not necessarily recommended yet
  179. for production use! :)