Configuring video download options

Standard video download options

In ApplicationSettings.properties make the following change

enable-video-conversions=true

This will show an extra Convert box when viewing the download page for a video.

The user may select from four popular video encoding formats:

The user may select the Video Quality from four default options (the higher the quality, the larger the subsequent video file):

When the user clicks into the Advanced Options, they will see some further options.

Start offset allows the user download a cropped version of the video where the cropped video will start at the number seconds specified in from the beginning of the original video.

Clip duration allows the user to download a cropped version of the video with the length of the video trimmed to be the number of seconds specified.

Start offset and clip duration may be combined to allow the user to download a cropped version of the video of any length starting from any point within the video.

They can choose the Frame Rate for the video:

They can select the Sample Rate for the accompanying audio in the video file:

User defined video download options

If you require further customisation of the download options the following section describes how you can do this. This section assumes some knowledge and experience running SQL statements on the database as well and should only be performed if you are comfortable with that. It is also beneficial to understand the command line parameters used by ffmpeg.

In ApplicationSettings.properties make the following change

enable-video-conversions=false

Example 1

Add 2 options - MP4 Low and MP4 High with 4:3 aspect ratio and the same default size (360x272):

INSERT INTO `VideoUserFrameSize` (`Id`, `Name`, `Width`, `Height`) VALUES (1, '4:3', 360, 272);
INSERT INTO `VideoUserOption` (`Id`, `Name`, `Description`, `FileFormatId`, `DefaultFrameSize`, `IsGlobal`) VALUES (1, 'MP4 Low 4:3', 'MP4 Low 4:3', 306, 1, 0), (2, 'MP4 High 4:3', 'MP4 High 4:3', 306, 1, 0);
INSERT INTO `VideoUserOptionCommand` (`VideoUserOptionId`, `VideoCommandOptionId`, `Value`, `IsReference`) VALUES (1, 7, '128000', 0),(1, 8, '15', 0), (2, 7, '256000', 0),(2, 8, '25', 0); 

This results in a conversion panel with the following options:

Example 2

Add 2 options - MP4 Low and MP4 High with 16:9 aspect ratio and the same default size (416x232):

INSERT INTO `VideoUserFrameSize` (`Id`, `Name`, `Width`, `Height`) VALUES (2, '16:9', 416, 232);
INSERT INTO `VideoUserOption` (`Id`, `Name`, `Description`, `FileFormatId`, `DefaultFrameSize`, `IsGlobal`) VALUES (3, 'MP4 Low 16:9', 'MP4 Low 16:9', 306, 2, 0), (4, 'MP4 High 16:9', 'MP4 High 16:9', 306, 2, 0);
INSERT INTO `VideoUserOptionCommand` (`VideoUserOptionId`, `VideoCommandOptionId`, `Value`, `IsReference`) VALUES (3, 7, '128000', 0),(3, 8, '15', 0), (4, 7, '256000', 0),(4, 8, '25', 0); 

This results in a conversion panel with the following options:

Example 3

This example builds on the previous examples by creating both 4:3 and 16:9 low and high options but also adds some global settings. These global settings are a way of defining encoding options which apply to all options.

INSERT INTO `VideoUserFrameSize` (`Id`, `Name`, `Width`, `Height`) VALUES
(1, '4:3', 360, 272), (2, '16:9', 416, 232);
INSERT INTO `VideoUserOption` (`Id`, `Name`, `Description`, `FileFormatId`, `DefaultFrameSize`, `IsGlobal`) VALUES
(1, 'GLOBAL', 'GLOBAL', NULL, NULL, 1),
(2, 'MP4 Low 4:3', 'MP4 Low 4:3', 306, 1, 0),
(3, 'MP4 High 4:3', 'MP4 High 4:3', 306, 1, 0),
(4, 'MP4 Low 16:9', 'MP4 Low 16:9', 306, 2, 0),
(5, 'MP4 High 16:9', 'MP4 High 16:9', 306, 2, 0);
INSERT INTO `VideoUserOptionCommand` (`VideoUserOptionId`, `VideoCommandOptionId`, `Value`, `IsReference`) VALUES
(1, 1, 'inputFilename', 1),(1, 2, 'defaultFrameSize', 1),
(1, 4, '48000', 0),(1, 5, '44100', 0),(1, 6, 'libx264', 0),
(1, 100, NULL, 0),(1, 101, NULL, 0),
(2, 7, '128000', 0),(2, 8, '15', 0),
(3, 7, '256000', 0),(3, 8, '25', 0),
(4, 7, '128000', 0),(4, 8, '15', 0),
(5, 7, '256000', 0),(5, 8, '25', 0);

The rows in the VideoUserOptionCommand reference the VideoCommandOption table.

A short summary of some of those options can be seen below:

2Set frame size. The format is wxh (ffserver default = 160x128). There is no default for input streams, for output streams it is set by default to the size of the source stream-s
3audio codec, Force audio codec to the given codec. Use the "copy" special value to specify that the raw codec data must be copied as is.-acodec
4Set the audio bitrate in bit/s (default = 64k).-ab
5Set the audio sampling frequency. there is no default for input streams, for output streams it is set by default to the frequency of the input stream.-ar
6Force video codec to the given codec. Use the \"copy\" special value to specify that the raw codec data must be copied as is.-vcodec
7Set the video bitrate in bit/s (default = 200 kb/s).-b
8Set frame rate (Hz value, fraction or abbreviation), (default = 25)-r
9The options specified in a preset file are applied to the currently selected video codec.-vpre
10Set the number of audio channels, 1 audio channel (mono) or 2 (stereo). (Default = 2)-ac
11How strictly to follow standards, allowed values: "very", "strict", "normal", "experimental"-strict
101Places the MoovAtom in MP4 format files at the start of the file enabling the file to be HTTP streamed.MoovAtom

In this example we have added the following global options (i.e. these are used in every conversion):

  • -ar 44100
  • -ab 48000
  • -vcodec libx264

We can see all of the options defined above together in this example:

Limitations

It is not currently possible to define new options and add them to the VideoCommandOption table - the list of options defined there is fixed due to coding constraints.

Was this article helpful?

Yes No

Thanks for your feedback!