Adding multiple parts of video leaves a black screen

Example video: 1 minute

Hello I am trying to add the first 5 seconds from a video and the last 5 seconds of a video together, but whenever I try this it leaves a black screen with all of the time between the first 5 and last 5 seconds. So if the video was 1 minute long it would get the first 5 seconds of the video and then 50 seconds of black screen and then 5 seconds of the end of the video. I have checked my JSON and there is no html or video that would make the video even play during the black screen. I also do not have a soundtrack.

Example inputs:
Video 1: 1 minute long

Desire: 1 10 seconds video with the first 5 seconds of Video 1 and last 5 seconds of Video 1

Current Output: 1 60 second video with 50 seconds of black screen

The way to achieve this is to use the trim property to make it start (video_asset_duration - 5) seconds.

It’s important to note that the length property informs the duration of the video you are creating. If you only want your video to last 10 seconds, then the sum of your length property values shouldn’t exceed 10s.

You can use the media inspector endpoint to get the length of a video file.

{
    "timeline": {
        "background": "#000000",
        "tracks": [
            {
                "clips": [
                    {
                        "asset": {
                            "type": "video",
                            "src": "https://shotstack-ingest-api-v1-au.s3.ap-southeast-2.amazonaws.com/wzr6y0wtti/zzyb4vat-4dax-eo21-dyip-0lkkmh1x5zo2/source.mp4"
                        },
                        "start": 0,
                        "length": 5
                    }
                ]
            },
            {
                "clips": [
                    {
                        "asset": {
                            "type": "video",
                            "src": "https://shotstack-ingest-api-v1-au.s3.ap-southeast-2.amazonaws.com/wzr6y0wtti/zzyb4vam-2u2v-ai38-qzhm-0oiqkz0epcos/source.mp4",
                            "trim": 15.62
                        },
                        "length": 5,
                        "start": 5
                    }
                ]
            }
        ]
    },
    "output": {
        "format": "mp4",
        "size": {
            "width": 1024,
            "height": 576
        },
        "fps": 30
    }
}

Thank you. I got it fixed!

It’s slightly confusing to work with because trim, length, start are all different but glad I got my functions made!

1 Like