
Firefogg
video encoding and uploading for Firefox
Use Firefogg on your site
To use Firefogg on your site, you have to use the Firefogg Javascript api.
There are two modes you can integrate Firefogg. one uploads data while the video is encoded.
The other encodes the video and starts a regular multipart HTTP POST after that.
- Example encoding and uploading at the same time
- Example sending a multipart POST request once encoding is done
Debug Firefogg on your site
to get more debug information from Firefogg go to about:config and set extensions.firefogg.debug to true
Firefogg API
the Firefogg object has these functions and properties:
| cancel() | abort encoding or upload |
| deleteVideo() | delete encoded video, use this to delete video after upload is done. |
| encode(options, callback, progress) |
options is a json string(see encoding options below) callback is a function that gets called once encoding is done, since Firefogg 2.8 this gets passed the encoded file as a File object as second parameter progress is a function that gets called to update progress |
| chunk_upload(url, data, callback, progress) |
url to post data to, has to return json with uploadUrl (more info on chunk upload) data is a json string(with additional form data to post to url) callback is a function that gets called once upload is done, first arguemnt is json string progress is a function that gets called on progress, first argument is json string |
| post(url, videoName, data, callback, progress) |
post can be used after encode is done, to upload while encoding use upload url POST url to post video + data to videoName form name of the video in the post request data is json string, form data to send to url, i.e. title |
callback is a function that gets called once upload is done, first arguemnt is json string
| previewUrl | after encoding is started, video is available through this url. |
| selectVideo() | select video to encode, returns true if video was selected |
| setInput(file) | set input to file object, i.e. from <input type=file> |
| bool setFormat(format) | set default format used only for saveVideoAs dialog, options: ogg, webm; actuall format depends on video codec used: theora results in ogg, vp8 will be webm |
| bool saveVideoAs() | opens a "save as..." dialog and sets output to selected target. has to be alled before encode/upload/render |
| sourceFilename | filename of the selected source, availabe only after calling selectVideo() |
| sourceInfo | json info about selected source video (example), availabe only after calling selectVideo() |
| version | returns Firefogg version |
Encoding Options
Example:
var options = JSON.stringify({'maxSize': 320, 'videoQuality': 6, 'noaudio': true});
ogg.encode(options);
| videoCodec | string | video codec, right now theora and vp8 are supported |
| width | int | resize to given width, if only width is given, height is calculated |
| height | int | resize to given height, if only height is given, widht is calculated |
| maxSize | int | limits the bigger widht/height to this, keeping aspect ratio |
| videoQuality | float | [0 to 10] encoding quality for video, use higher values for better quality (default: 5) |
| videoBitrate | int | [1 to 16778] encoding bitrate for video (kb/s) |
| twopass | boolean | Together with videoBitrate this option can be used to do two-pass encoding. |
| framerate | string | framerate can be fraction 25:2 or int 16 |
| aspect | string | aspect ratio can be fraction 4:3 or 16:9 |
| keyframeInterval | int | [1 to 65536] keyframe interval (default: 64) |
| bufferDelay | int | Buffer delay (in frames). Longer delays allow smoother rate adaptation and provide better overall quality, but require more client side buffering and add latency. The default value is the keyframe interval for one-pass encoding (or somewhat larger if --soft-target is used) and infinite for two-pass encoding. (only works in bitrate mode) |
| softTarget | boolean | Use a large reservoir and treat the rate as a soft target; rate control is less strict but resulting quality is usually higher/smoother overall. Soft target also allows an optional videoQuality setting to specify a minimum allowed quality. |
| denoise | boolean | denoise input video |
| deinterlace | boolean | manually enable deinterlacing if video |
| brightness | float | [-1.0 to 1.0] brightness correction (default: 0.0)
Note: lower values make the video darker. |
| contrast | float | [0.1 to 10.0] contrast correction (default: 1.0)
Note: lower values make the video darker. |
| gamma | float | [0.1 to 10.0] gamma correction (default: 1.0)
Note: lower values make the video darker. |
| saturation | float | [0.1 to 10.0] saturation correction (default: 1.0)
Note: lower values make the video grey. |
| cropTop | int | crop input at top |
| cropBottom | int | crop input at bottom |
| cropLeft | int | crop input at left |
| cropRight | int | crop input at right |
| starttime | float | only encode from time in seconds |
| endtime | float | only encode to time in seconds |
| noUpscaling | boolean | do not make video bigger, use higher framerate or more audio channels than input, default false |
| audioCodec | string | audio codec, right now only vorbis is supported. flac, speex, celt planned |
| audioQuality | float | [-1 to 10] encoding quality for audio use higher values for better quality (default: 1) |
| audioBitrate | int | [32 to 500] encoding bitrate for audio (kb/s) |
| samplerate | int | set output samplerate (in Hz) |
| channels | int | set number of channels, 1 for mono, 2 for stereo |
| noaudio | boolean | disable possible audio input |
| novideo | boolean | disable possible video input |
| title | string | Name of artist (director) |
| artist | string | Title |
| date | string | Date |
| location | string | Location |
| organization | string | Name of organization (studio) |
| copyright | string | Copyright |
| license | string | License |
| contact | string | Contact link |
| passthrough | boolean | if passthrough is true, selected file will not be encoded but uploaded directly, can be used to upload other large files or vidoes that are already ogg theora. it is recommended to use ogg.sourceFilename and ogg.sourceInfo to make a descission is that is wanted. |
Render API
Firefogg allows you to render DOM content into a video, more information on the render api documentation page.
Example Projects
Example Django Project using Firefogg to allow video uploadsbzr branch http://firefogg.org/dev/FirefoggDjangoExampleExample PHP Site using Firefogg to allow video uploads
bzr branch http://firefogg.org/dev/FirefoggPHPExample
Firefogg development
to get the latest source checkout our bzr branch and read the instructions in the README.
bzr branch http://firefogg.org/dev/Firefogg
Bugs
- Please report bugs on our bugtracker or send an email to contact@firefogg.org