1 | # media_conv |
---|
2 | A Pyramid web service that converts audio data from WAV to M4A. |
---|
3 | |
---|
4 | ## Dependencies |
---|
5 | * Python version 3.3+ with libraries: |
---|
6 | * pyramid |
---|
7 | * pyramid_debugtoolbar |
---|
8 | * waitress |
---|
9 | |
---|
10 | ## Usage |
---|
11 | The web service has one entry point `media_conv` that responds to HTTP `GET` and `POST` requests. |
---|
12 | |
---|
13 | ###`media_conv` |
---|
14 | |
---|
15 | #### Parameters |
---|
16 | 1. `input_mime_type`: MIME type of input media data at `input_media_url`. |
---|
17 | 2. `jwplayer_file_url_hack`: whether to apply a hack to let JWplayer use media_conv successfully. `jwplayer_file_url_hack` can be `0` (enable) or `1` (disable). |
---|
18 | 3. `input_media_url`: HTTP URL where the input media data can be retrieved from. |
---|
19 | |
---|
20 | #### Response |
---|
21 | A HTTP response with the audio data received after issuing a HTTP `GET` request based on the URL `input_media_url`. |
---|
22 | |
---|
23 | #### Notes |
---|
24 | The version of JW Player used by Annex requires a hack to accept a global identifier URI wherein media_conv is called to return `audio/mp4` audio. |
---|
25 | |
---|
26 | 1. The HTTP request method is `GET`. |
---|
27 | 2. `jwplayer_file_url_hack=1`. |
---|
28 | 3. `input_media_url`... parameter and value combination has (fictional, extra) suffix of `.m4a`. |
---|
29 | 4. The call URI ends with the `input_media_url` parameter and value combination and therefore ends with the `.m4a` string. |
---|
30 | 5. The file `crossdomain.xml` to allow Flash cross-domain scripting is at the document root of the web site where the, if Annex runs from a different FQDN. |
---|
31 | |
---|
32 | #### Example usages (on Unix, with `curl`) |
---|
33 | Advised usage: |
---|
34 | |
---|
35 | curl -v -X POST \ |
---|
36 | 'http://infra.clarin.eu/app/media_conv?input_mime_type=audio/x-wav&jwplayer_file_url_hack=0&output_mime_type=audio/mp4&input_media_url=http://infra.clarin.eu/tmp/maus-pipeline/g001acn1_000_AAJ_1.wav' \ |
---|
37 | > /tmp/g001acn1_000_AAJ_1.m4a ; |
---|
38 | |
---|
39 | As used by Annex/JW Player, and on the server where the web application runs (localhost): |
---|
40 | |
---|
41 | curl -v -X GET \ |
---|
42 | 'http://127.0.0.1:6543/media_conv?input_mime_type=audio/x-wav&jwplayer_file_url_hack=1&output_mime_type=audio/mp4&input_media_url=http://infra.clarin.eu/tmp/maus-pipeline/g001acn1_000_AAJ_1.wav.m4a' \ |
---|
43 | > /tmp/g001acn1_000_AAJ_1.m4a ; |
---|
44 | |
---|
45 | ## Future work |
---|
46 | |
---|
47 | === Goals === |
---|
48 | 1. Make more robust: currently the conversion process creates a temporary file for each request that isn't being cleaned up. Move to a performant and stable database/key-value store. |
---|
49 | 2. Handle more types of media. |
---|