Video
Overview
MediaFire's remarkable video transcorder allows you to transcode video in real time from many types of formats. In the sections below, detailed information will be
given including supported formats for video transocidng, how to prepare a transcoding request, and how to make a transcoding request.
Note: This API is restricted. If you wish to enable this feature in your app, please contact customer service.
Supported Inputs
The following video types are supported in the MediaFire Multimedia API.
| Extension | Mimetype | Name |
|---|---|---|
| ogv | video/ogg | Ogg Video Profile |
| webm | video/webm | Open Web Media |
| flv | video/x-flv | Flash Video |
| wmv | video/x-ms-wmv | Windows Media Video |
| avi | video/x-msvideo | Audio Video Interleave |
| 3gp | video/3gpp | Third Generation Partnership Project Multimedia Container Format |
| 3gpp | video/3gpp | Third Generation Partnership Project Multimedia Container Format |
| 3g2 | video/3gpp2 | Third Generation Partnership Project 2 Multimedia Container Format |
| 3gpp2 | video/3gpp2 | Third Generation Partnership Project 2 Multimedia Container Format |
| mp4 | video/mp4 | Moving Pictures Expert Group Container Layer 4 |
| mpg4 | video/mp4 | Moving Pictures Expert Group Video Layer 4 |
| mpeg | video/mpeg | Moving Pictures Expert Group Video |
| mpg | video/mpeg | Moving Pictures Expert Group Video |
| mov | video/quicktime | QuickTime Video File Format |
| mkv | video/x-matroska | Matroska multimedia container format |
| mod | video/mpeg | JVC and Panasonic's tapeless mpeg video format | vob | video/mpeg | Video Object |
| m4v | video/x-m4v | Moving Pictures Expert Group Video Layer 4 |
Supported Outputs
The following video types are supported in the MediaFire Multimedia API.
| Container Type | Quality | Video Bitrate | Audio Bitrate |
|---|---|---|---|
| flv | 240p | 800 kbps | 128 kbps |
| flv | 480p | 2500 kpbs | 128 kbps |
| flv | 720p | 5000 kbps | 384 kbps |
| flv | 1080p | 8000 kbps | 384 kbps |
Note: Bitrates are only down-sampled when the input stream is of a greater bitrate.
Preparing the Transcoding Request
Follow these steps to prepare to make a transcoding request:
Step 1: Check the file object 'view' property. File objects are returned by several APIs. Examples of such APIs are folder/get_content, file/get_info, and folder/search. A value of '5' indicates the audio can be transcoded.
Step 2: Once you have confirmed that the file can be transcoded, use file/get_links API to obtain a default 'streaming' url.
Step 3: The default 'streaming' url query string parameters will need to be modified to suit your request.
https://www.mediafire.com/api/1.2/file/get_links.php?session_token=2b0b2f6b6d6374830f1654a4004d1cfe0a67d88ba9ab949f22aff9d49c87fe0e37ef7fb675ef504c481f2b6d07c1fe487437c4984760c90dd7b602ddce0e45e72fad1630b719dc6d&quick_key=172pwp7c8dyngpq&link_type=streaming
<response>
<action>file/get_links</action>
<links>
<link>
<quickkey>172pwp7c8dyngpq</quickkey>
<streaming>http://transcode1.mediafire.com/m22ztdtwu0rg/172pwp7c8dyngpq/e95a/Mario.avi</streaming>
</link>
</links>
<direct_download_free_bandwidth>8</direct_download_free_bandwidth>
<result>Success</result>
<current_api_version>1.2</current_api_version>
</response>
Making the Transcoding Request
Below are the required parameters, and other important information, to make your video transcoding request.
Required Parameters:
- container : Required in absence of other GET parameters. Allowed container type: 'flv'. Defaults to 'flv'. (Only 'flv' is supported at this time).
Optional Parameters:
- media_size : This parameter sets the video size. Acceptable values are '240p', '480p', '720p', & '1080p'. Defaults to '480p'.
- exists : The exists parameter can be used to inspect the transcoding state of an input file. There are three possible values: The first value is 'check' and it indicates if the file is loaded on the server. It will not load the file to the server if it is not present. The value 'create' indicates if the video is loaded on the server. If it is not, it will trigger the loading process. The third value is 'status' and it will provide detailed information about the transcoding process once the loading phase has been initiated. You can only get the status of a input file once the loading process has started. Calling it before then will result in an error.
Details about the exists parameter:
If a value of check is supplied to the 'exists' parameter, the following response will be returned immediately:
<state>true</state> // file exists in specified format
or
<state>false</state> // file does not exist in specified format
If a value of create is supplied to the 'exists' parameter, the following response will be returned immediately:
<state>true</state> // file already exists in specified format
or
<state>false</state> // file does not exist in specified format. Begin tftp transfer.
If a value of status is supplied to the 'exists' parameter a response will be returned immediately with the following properties:
<response>
<tftp_progress>0</tftp_progress>
<video_width>0</video_width>
<video_height>0</video_height>
<video_bitrate>0</video_bitrate>
<audio_bitrate>0</audio_bitrate>
<duration>0</duration>
<original_filesize>0</original_filesize>
<transcoded_filesize>0</transcoded_filesize>
<status>transferring</status>
<schema_version>2</schema_version>
</response>
Response properties are defined below:
- tftp_progress : Ranges between '0-100', and 'ready'. Describes the progress of the tftp transfer. The ready state has been deprecated as of schema_version 3 and will be removed in the future. New programs should be written to check the 'status' property to determine whether the file is ready to be streamed.
- video_width : The video width in pixels. This is 0 if the video width is not known yet.
- video_height : The video height in pixels. This is 0 if the video height is not known yet.
- video_bitrate : The video bitrate in bits per second. This is 0 is the video bitrate is not known yet.
- audio_bitrate : The audio bitrate in bits per second: This is 0 if the audio bitrate is not known yet.
- duration : The duration of the video in seconds. This is 0 if the video duration is not known yet.
- original_filesize : The size of the original file in bytes. This is 0 if the filesize is not known yet.
- transcoded_filesize : This is the size of the transcoded video file. This is 0 if the video has not be completely transcoded yet.
- status : The state of the transcode. Valid values are: 'transferring', 'converting', 'ready', & 'error'. Transferring indicates that the loading process is under way. Converting indicates that the loading process has completed. When the transcoding state of the file is 'converting' the stream will be served with the HTTP header 'transfer-encoding' set to 'chunked'. When the state of the file is set to 'ready' the stream will be served as a traditional payload supporting the Range-Request header.
- schema_version : This property indicates the schema version of this response. If any response related to the streaming APIs change, this number will increment.
Below are typical examples to request video:
1. http://transcode1.mediafire.com/m22ztdtwu0rg/172pwp7c8dyngpq/e95a/Mario.mp3?container=mp3&exists=create
2. If state is true, we can skip immediately to 5.
3. http://transcode1.mediafire.com/m22ztdtwu0rg/172pwp7c8dyngpq/e95a/Mario.mp3?container=mp3&exists=status
4. Keep calling 2 until status indicates "converting" or "ready"
5. http://transcode1.mediafire.com/m22ztdtwu0rg/172pwp7c8dyngpq/e95a/Mario.mp3?container=mp3