Hi Jack,
Yes. Stitching together a range of videos using the API is very easy to do. In the following example I’ll stitch together a range of videos. You can also use transitions between clips.
Stitching Videos Using the API
Videos to be stitched
- https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/footage/table-mountain.mp4
- https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/footage/beach-cliffs.mp4
Result
JSON
{
"timeline": {
"tracks": [
{
"clips": [
{
"asset": {
"type": "video",
"src": "https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/footage/table-mountain.mp4"
},
"start": 0,
"length": 18.6
},
{
"asset": {
"type": "video",
"src": "https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/footage/beach-cliffs.mp4"
},
"start": 18.6,
"length": 20.6
}
]
}
]
},
"output": {
"format": "mp4",
"resolution": "hd"
}
}
Stitching videos with unknown durations
Often you do not know the exact length of the video. For this you can use the Media Inspector API endpoint. This endpoint provides you with detailed metadata of your video. Just make sure to encode your the URL you’re looking to probe like this:
Original url
https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/footage/table-mountain.mp4
Encoded url
https%3A%2F%2Fshotstack-assets.s3-ap-southeast-2.amazonaws.com%2Ffootage%2Ftable-mountain.mp4
curl -X GET https://api.shotstack.io/edit/{version}/probe/{video_url} \
-H 'Accept: application/json' \
-H 'x-api-key: API_KEY'
{
"success": true,
"message": "ok",
"response": {
"metadata": {
"streams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"profile": "High",
"codec_type": "video",
"codec_time_base": "1/48",
"codec_tag_string": "avc1",
"codec_tag": "0x31637661",
"width": 1920,
"height": 1080,
"coded_width": 1920,
"coded_height": 1088,
"closed_captions": 0,
"has_b_frames": 2,
"pix_fmt": "yuv420p",
"level": 40,
"color_range": "tv",
"color_space": "bt709",
"color_transfer": "bt709",
"color_primaries": "bt709",
"chroma_location": "left",
"refs": 1,
"is_avc": "true",
"nal_length_size": "4",
"r_frame_rate": "24/1",
"avg_frame_rate": "24/1",
"time_base": "1/24",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 451,
"duration": "18.791667",
"bit_rate": "5678807",
"bits_per_raw_sample": "8",
"nb_frames": "451",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"creation_time": "2019-10-22T12:47:31.000000Z",
"language": "und",
"handler_name": "L-SMASH Video Handler",
"encoder": "AVC Coding"
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "LC",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "mp4a",
"codec_tag": "0x6134706d",
"sample_fmt": "fltp",
"sample_rate": "48000",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 902080,
"duration": "18.793333",
"bit_rate": "253374",
"max_bit_rate": "259456",
"nb_frames": "881",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"creation_time": "2019-10-22T12:47:31.000000Z",
"language": "und",
"handler_name": "L-SMASH Audio Handler"
}
}
],
"chapters": [],
"format": {
"filename": "https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/footage/table-mountain.mp4",
"nb_streams": 2,
"nb_programs": 0,
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"format_long_name": "QuickTime / MOV",
"start_time": "0.000000",
"duration": "18.793333",
"size": "13944999",
"bit_rate": "5936147",
"probe_score": 100,
"tags": {
"major_brand": "mp42",
"minor_version": "0",
"compatible_brands": "mp42mp41isomavc1",
"creation_time": "2019-10-22T12:47:31.000000Z"
}
}
}
}
}
Stitching Videos Using Integromat or Zapier
You can also stitch together your videos using an automation platform like Zapier or Integromat. Here the duration of your videos is calculated for you. Easy.