To create an optimized encoding using FFmpeg, send a POST
request to /ffmpeg
.
Use an FFmpegRequest to specify the FFmpeg command(s) you use to produce your desired encoded video(s). Stream Smart supports a number of FFmpeg encoding commands including:
- Single-pass constant rate factor (CRF)
- Single-pass variable bitrate (VBR)
- Multi-pass variable bitrate
Please see the examples to the side for further details.
During optimization, Stream Smart will produce the encoded video(s) using your chosen FFmpeg command (i.e. the anchor video(s)) along with the optimized encoded video(s) (i.e. the result(s)) which have been created to achieve the same target quality using fewer bits.
Request body
Responses
FFmpeg using VBR
curl -X POST "http://localhost/ffmpeg" \
-H "Content-Type: application/json" \
-d '{
"title": "Tears of Steel",
"config": {
"inputLocation": {
"key": "sources/tearsofsteel/tearsofsteel_4k.mov",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
},
"encodes": [
{
"commands": [
"ffmpeg -r 24 -i {INPUT_LOCATION} -pix_fmt yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range mpeg -c:v libx264 -x264-params \"ref=3:bframes=3:b_adapt=2:keyint=50:keyint_min=50:scenecut=0:stitchable=1\" -profile:v high -level:v 4.1 -b:v 5000k -maxrate 6250k -bufsize 10000k -r 24 -vf scale=1920x1080 -an {OUTPUT_LOCATION}"
],
"outputLocation": {
"path": "example/output/path/encoded_video.mp4",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
}
}
]
}
}'
FFmpeg using multipass VBR
curl -X POST "http://localhost/ffmpeg" \
-H "Content-Type: application/json" \
-d '{
"title": "Tears of Steel",
"config": {
"inputLocation": {
"key": "sources/tearsofsteel/tearsofsteel_4k.mov",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
},
"encodes": [
{
"commands": [
"ffmpeg -i {INPUT_LOCATION} -passlogfile {TEMP_FILE_1} -fps_mode cfr -s 1920x1080 -aspect 1.778 -pix_fmt yuv420p -y -f mp4 -movflags +faststart -profile:v high -preset slow -pass 1 -vcodec libx264 -bf 0 -refs 4 -b:v 8000k -maxrate:v 12000k -bufsize:v 18000k -minrate:v 8000k -tune animation -x264opts rc-lookahead=48:keyint=96:stitchable=1 -keyint_min 48 -g 96 -force_key_frames \\"expr:eq(mod(n,48),0)\\" -an -sn -dn -map_chapters -1 -hide_banner -loglevel info -nostdin -copyts -start_at_zero -max_delay 0 -max_muxing_queue_size 1024 -an /dev/null",
"ffmpeg -i {INPUT_LOCATION} -passlogfile {TEMP_FILE_1} -fps_mode cfr -s 1920x1080 -aspect 1.778 -pix_fmt yuv420p -y -f mp4 -movflags +faststart -profile:v high -preset slow -pass 2 -vcodec libx264 -bf 0 -refs 4 -b:v 8000k -maxrate:v 12000k -bufsize:v 18000k -minrate:v 8000k -tune animation -x264opts rc-lookahead=48:keyint=96:stitchable=1 -keyint_min 48 -g 96 -force_key_frames \\"expr:eq(mod(n,48),0)\\" -an -sn -dn -map_chapters -1 -hide_banner -loglevel info -nostdin -copyts -start_at_zero -max_delay 0 -max_muxing_queue_size 1024 -an {OUTPUT_LOCATION}"
],
"outputLocation": {
"path": "example/output/path/encoded_video.mp4",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
}
}
]
},
"ssimwaveInternal": {
"lastStep": "scoreoptimized"
}
}'
FFmpeg using single command CRF
curl -X POST "http://localhost/ffmpeg" \
-H "Content-Type: application/json" \
-d '{
"title": "Tears of Steel",
"config": {
"inputLocation": {
"key": "sources/tearsofsteel/tearsofsteel_4k.mov",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
},
"encodes": [
{
"commands": [
"ffmpeg -r 24 -i {INPUT_LOCATION} -pix_fmt yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range mpeg -c:v libx264 -x264-params \\"ref=3:bframes=3:b_adapt=2:keyint=48:keyint_min=48:scenecut=0\\" -profile:v high -level:v 4.1 -preset slow -crf 23 -b:v 4000k -maxrate 6000k -bufsize 8000k -an {OUTPUT_LOCATION}"
],
"outputLocation": {
"path": "example/output/path/encoded_video.mp4",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
}
}
]
}
}'
Customized configuration for the FFmpeg encoder.
{
"inputLocation": {
"key": "sources/tearsofsteel/tearsofsteel_4k.mov",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
},
"encodes": [
{
"commands": [
"ffmpeg -r 24 -i {INPUT_LOCATION} -pix_fmt yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range mpeg -c:v libx264 -x264-params \"ref=3:bframes=3:b_adapt=2:keyint=50:keyint_min=50:scenecut=0:stitchable=1\" -profile:v high -level:v 4.1 -b:v 5000k -maxrate 6250k -bufsize 10000k -r 24 -vf scale=1920x1080 -an {OUTPUT_LOCATION}"
],
"outputLocation": {
"path": "example/output/path/encoded_video.mp4",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
}
}
]
}
Used to specify details about the location and name of the reference asset to be optimized.
An array of FFmpeg encoding commands to apply to the given reference asset and output locations in which to store the encoded videos.
The FFmpeg encoding commands to apply to the given reference asset. Within each command, you reference the input location of the reference asset using {INPUT_LOCATION} and the output location of the encoded video using {OUTPUT_LOCATION}.
[
"ffmpeg -r 24 -i {INPUT_LOCATION} -pix_fmt yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range mpeg -c:v libx264 -x264-params \"ref=3:bframes=3:b_adapt=2:keyint=50:keyint_min=50:scenecut=0:stitchable=1\" -profile:v high -level:v 4.1 -b:v 5000k -maxrate 6250k -bufsize 10000k -r 24 -vf scale=1920x1080 -an {OUTPUT_LOCATION}"
]
The output location in which to store the encoded videos.
Represents the body of a request sent to the /ffmpeg endpoint.
{
"title": "Tears of Steel",
"config": {
"inputLocation": {
"key": "sources/tearsofsteel/tearsofsteel_4k.mov",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
},
"encodes": [
{
"commands": [
"ffmpeg -r 24 -i {INPUT_LOCATION} -pix_fmt yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range mpeg -c:v libx264 -x264-params \"ref=3:bframes=3:b_adapt=2:keyint=50:keyint_min=50:scenecut=0:stitchable=1\" -profile:v high -level:v 4.1 -b:v 5000k -maxrate 6250k -bufsize 10000k -r 24 -vf scale=1920x1080 -an {OUTPUT_LOCATION}"
],
"outputLocation": {
"path": "example/output/path/encoded_video.mp4",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
}
}
]
}
}
The title of the content being optimized.
Captures the FFmpeg configuration, principally the FFmpeg enconding command(s).
An optional object used to capture various configuration options that apply to the optimization algorithms. Please consult your Stream Smart representative for more details on the applicability of this object for your use case.
The location to save the output optimized asset(s) to.
{
"path": "example/output/path/encoded_video.mp4",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
}
Path in which to store the video file(s).
The location that the specified video is stored at.
{
"x1": 30,
"x2": 50,
"y1": 1,
"y2": 2.5
}
Represents the reference or mezzanine video asset in the system and is the source for the encoding operation.
{
"key": "sources/tearsofsteel/tearsofsteel_4k.mov",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
}
The full key for the video file in the StorageLocation
The location of the specified video.
An object that can be used to capture various configuration options that apply to the optimization algorithms. Please consult your Stream Smart representative for more details on the applicability of this object for your use case(s).
{
"qualityDelta": {
"x1": 30,
"x2": 50,
"y1": 1,
"y2": 2.5
},
"rateControlOverride": [
""
],
"segmentScoreMethod": "persecondslidingwindowminimum",
"scoreMetric": "eps",
"lastStep": "stitch",
"copyEncodeLocation": "",
"bandingQualityDelta": {
"x1": 65,
"x2": 85,
"y1": 8,
"y2": 4
},
"displayDevice": "oled65c9pua",
"optimizationMode": {
"type": "bitrate-savings",
"config": {}
}
}
Acceptable delta in quality from the anchor encode
{
"x1": 30,
"x2": 50,
"y1": 0,
"y2": 2.5
}
Override dynamically chosen Rate Control values with this list
[
]
This specifies a storage location for a video asset.
{
"type": "S3",
"name": "reference-assets"
}
The type of storage being used (ie: S3)
The name of the S3 bucket
The type of storage to use.
Amazon S3
Represents the response from a succesful POST to the /ffmpeg endpoint.
{
"title": "Tears of Steel",
"config": {
"inputLocation": {
"key": "sources/tearsofsteel/tearsofsteel_4k.mov",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
},
"encodes": [
{
"commands": [
"ffmpeg -r 24 -i {INPUT_LOCATION} -pix_fmt yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range mpeg -c:v libx264 -x264-params \"ref=3:bframes=3:b_adapt=2:keyint=50:keyint_min=50:scenecut=0:stitchable=1\" -profile:v high -level:v 4.1 -b:v 5000k -maxrate 6250k -bufsize 10000k -r 24 -vf scale=1920x1080 -an {OUTPUT_LOCATION}"
],
"outputLocation": {
"path": "example/output/path/encoded_video.mp4",
"storageLocation": {
"type": "S3",
"name": "reference-assets"
}
}
}
]
},
"id": "04a2e841-9c9e-4f50-9f9f-4a8b847f5b3e"
}
The UUID that represents the analysis that was done as part of the optimization process.