Frame Rate Conversion
You may need to change frame rates to convert between standards. There are two distinct methods that can be used to convert from one frame rate to another:
Convert While Preserving Duration
Preserving the duration without any filter will duplicate/drop frames as needed to achieve the desired output frame rate. Specifying a new frame rate in the target will achieve a frame rate conversion that results in the same duration. Given that frames may be duplicated or dropped, there may be visual jitter.
Frame Duplication or Dropping
Here is a simple example where you could have a source of any frame rate which needs to be converted to 25fps:
{
"video": {
"codec": "h264",
"width": 720,
"height": 406,
"frame_rate": 25
}
}
Allow Duration to Change - Speed Change
Using the Speed Change filter will transfer every video frame from the source to the output. It is most often used to convert 23.976fps sources to 25fps, also known as “fast PAL”, but it can also be used for the reverse conversion. The filter essentially overrides the source file’s perceived frame rate, allowing conversion to a new frame rate without duplicating frames or dropping frames. This will have a more natural visual quality.
The resulting output will have a different duration compared to the source; either shorter (23.976 –> 25) or longer (25 –> 23.976). Because the timing will change, the audio is sped up or slowed down to match.
- Audio pitch will be corrected by default unless
"pitch_correction": false
is included in the filter payload. - You must include a
frame_rate
value (the desired output frame rate) in your transcode task video object - You can include
pitch_correction
, but this can introduce artifacts. Most European content (converted from 23.976 to 25) is not pitch corrected. In this case, audio pitch is slightly higher. - The value for factor should be
(desired output fps)/(source fps)
.
Example code for conversion to 25fps from 23.976fps (Fast PAL):
"container": {
"kind": "mp4",
"filters": [
{
"kind": "speed_change",
"payload": {
"factor": "25/(24000/1001)",
"pitch_correction": true
}
}
]
}
For a full job sample, see the Example Jobs below.
Comparing Both Approaches
The following graphic shows how source frames are transferred to the output when speed_change
is used or not:
Adjusting captions to match the new frame rate output
If you want to deliver subtitles or captions for an output created using the speed_change
filter, the subtitle event timings will need to be adjusted with a subtitle editing program as follows:
- If necessary, offset all events to be zero-hour based (e.g. if captions are intended to match a source with 1-hour timecode, subtract one hour from all events). A caption event originally set to start at
01:00:15:22
should now be00:00:15:22
- Change frame rate from X to Y (either 25 to 23.976 or 23.976 to 25). Another option here is to adjust speed by percentage, either
104.27%
for 25 to 23.976 or96%
for 23.976 to 25. - If an offset was performed in step #1, offset all events again, increasing by one hour - a reverse of the example in step #1 above.