Converting Horizontal Video to Vertical
Introduction
Horizontal to Vertical conversion places a landscape video on a vertical canvas (9:16 by default), so it fits vertical feeds without cropping the picture. The whole frame stays visible: the video is scaled to the width of the new canvas and centered, and the space above and below it is filled with either a solid color or a blurred copy of the same video.
The conversion also works in the opposite direction: a vertical video can be placed on a landscape canvas (16:9 by default), with the space on the left and right filled the same way.
Conversion Modes
The conversion is enabled with the video_filters attribute of the output format. The filter name selects the direction and the type of fill.
| Filter name | Direction | Fill | Default aspect ratio |
|---|---|---|---|
| h2v | Horizontal to vertical | Solid color | 9:16 |
| h2v_blur | Horizontal to vertical | Blurred copy of the video | 9:16 |
| v2h | Vertical to horizontal | Solid color | 16:9 |
| v2h_blur | Vertical to horizontal | Blurred copy of the video | 16:9 |
Convert Horizontal Video to Vertical
Add video_filters with the name h2v to the output format in your transcoding job. Use the /v1/start_encode2 method to launch the job. The optional color parameter sets the fill color; it defaults to black.
Request example: solid color fill
{
"query": {
"encoder_version": 2,
"source": "YOUR_VIDEO_URL",
"format": [
{
"output": "mp4",
"video_filters": {
"name": "h2v",
"params": {
"color": "purple"
}
},
"destination": [
{
"url": "YOUR_STORAGE_URL",
"key": "YOUR_KEY",
"secret": "YOUR_SECRET"
}
]
}
]
}
}To fill the space with a blurred copy of the video instead, use the name h2v_blur. No parameters are required.
Request example: blurred fill
{
"query": {
"encoder_version": 2,
"source": "YOUR_VIDEO_URL",
"format": [
{
"output": "mp4",
"video_filters": {
"name": "h2v_blur"
},
"destination": [
{
"url": "YOUR_STORAGE_URL",
"key": "YOUR_KEY",
"secret": "YOUR_SECRET"
}
]
}
]
}
}Convert Vertical Video to Horizontal
Use the name v2h to place a vertical video on a landscape canvas with a solid color on both sides, or v2h_blur to fill the sides with a blurred copy of the video.
Request example: solid color fill
{
"query": {
"encoder_version": 2,
"source": "YOUR_VIDEO_URL",
"format": [
{
"output": "mp4",
"video_filters": {
"name": "v2h",
"params": {
"color": "lime"
}
},
"destination": [
{
"url": "YOUR_STORAGE_URL",
"key": "YOUR_KEY",
"secret": "YOUR_SECRET"
}
]
}
]
}
}Request example: blurred fill
{
"query": {
"encoder_version": 2,
"source": "YOUR_VIDEO_URL",
"format": [
{
"output": "mp4",
"video_filters": {
"name": "v2h_blur"
},
"destination": [
{
"url": "YOUR_STORAGE_URL",
"key": "YOUR_KEY",
"secret": "YOUR_SECRET"
}
]
}
]
}
}Filter Settings
| Parameter | Type | Requirement | Description |
|---|---|---|---|
| name | string | Required | Conversion mode: h2v, h2v_blur, v2h or v2h_blur. |
| params | object | Optional | Settings for the selected mode, listed below. If omitted, the defaults are used. |
| params.aspect | string | Optional | Aspect ratio of the output canvas in width:height format, for example 9:16, 4:5 or 1:1. Both values must be positive integers. Works with all four modes. Default: 9:16 for h2v and h2v_blur, 16:9 for v2h and v2h_blur. |
| params.color | string | Optional | Fill color for h2v and v2h, as a color name (for example purple) or a hex value (for example #1E90FF). Default: black. Not used by the blur modes. |
| params.radius | integer | Optional | Blur radius for h2v_blur and v2h_blur. A larger value gives a stronger blur. Default: 40. |
| params.power | integer | Optional | Number of times the blur is applied for h2v_blur and v2h_blur. A larger value gives a smoother blur. Default: 2. |
Request example: 4:5 canvas with a custom color
{
"query": {
"encoder_version": 2,
"source": "YOUR_VIDEO_URL",
"format": [
{
"output": "mp4",
"height": 720,
"video_filters": {
"name": "h2v",
"params": {
"aspect": "4:5",
"color": "#1E90FF"
}
},
"destination": [
{
"url": "YOUR_STORAGE_URL",
"key": "YOUR_KEY",
"secret": "YOUR_SECRET"
}
]
}
]
}
}Output Size
The conversion keeps the height of the output and changes its width to match the canvas aspect ratio. The width is rounded down to an even number.
| Source | Settings | Output |
|---|---|---|
| 1920x1080 | h2v, default aspect (9:16) | 606x1080 |
| 1920x1080 | h2v, aspect 4:5, height: 720 | 576x720 |
| 1920x1080 | h2v_blur, default aspect (9:16), height: 1920, upscale: 1 | 1080x1920 |
To get a vertical output that is taller than the source, for example 1080x1920 from a 1920x1080 source, set the output height and enable upscale in the query.
Request example: 1080x1920 output from a 1920x1080 source
{
"query": {
"encoder_version": 2,
"source": "YOUR_VIDEO_URL",
"upscale": 1,
"format": [
{
"output": "mp4",
"height": 1920,
"video_filters": {
"name": "h2v_blur"
},
"destination": [
{
"url": "YOUR_STORAGE_URL",
"key": "YOUR_KEY",
"secret": "YOUR_SECRET"
}
]
}
]
}
}Limitations
- Requires encoder_version: 2.
- Available through the API only. The conversion is set in the job request and is not available in the portal UI.
- The blur modes (h2v_blur and v2h_blur) are billed at 1.4 times the rate of the same output without the filter. The solid-color modes (h2v and v2h) add no charge.
- The picture is never cropped or stretched. To convert a landscape video to vertical by cropping to the main subject instead, see Smart Cropping.
- The color parameter applies to h2v and v2h only. The radius and power parameters apply to h2v_blur and v2h_blur only.
- The aspect value must be two positive integers separated by a colon.
Need More Help?
For additional information, tutorials, or support, visit the Qencode Documentation page or contact Qencode Support at support@qencode.com.