The task: A provided input video file will be converted to different resolutions (e.g. 720p, 480p, 360p) and make it ready for HTTP streaming. Also, the curent resolution and codecs of the input file should be considered and a thumbnail will be created.
First we need to know what exactly the input file contains: codecs, video resolution etc. Based on this information we want to convert the video later. Also, we want to generate a thumbnail of the video.
As always, we need a Process URL first. Therefore we need our personal API Key. Because we are not doing any conversion in part 1, we need to set mode
to info
. Click "Execute" to request the Process URL.
Using the obtained Process URL, the process is started using the following request. To get information about the input file, we do not set the outputformat
option. Also, we set thumbnail_format
to get a thumbnail of the video. We set thumbnail_size
to 400x
, which means the width of the thumbnail should be 400 and the height will be automatically set based on the video resolution.
Therefore do GET request to the Process URL. Do this unless the step is "finished"
Using the collected information we now want to convert the video to different resolutions.
We need to create another Process URL.
Using the obtained Process URL, the process is started using the following request. We set the outputformat
to mp4 this time. As input file
parameter we use the input.url
of the process of part 1 - so we do not need to upload the file again.
We set the video_codec
, the video_resolution
and a constant rate facor video_crf
which influences the video quality and size. The default is 23, which is a good starting point. A lower value means higher quality. Also we set the faststart
option, which mooves the video information (moov atom) to the front of the file. This is needed for HTTP streaming.
All possible options can be identified with the Conversion types API and/or the API console.
Therefore do GET request to the Process URL. Do this unless the step is "finished"
When the process is finished, output.url
is available, which refers to the output video. We can do part 2 again for different video resolutions.