Video audio with a soundtrack and soundtrack loop

Hi there, I have a couple of questions, I do see that there is an option of setting the volume for an input video. The videos that I’m creating are a combination of images and videos and I’m also using the soundtrack option, so the final video will always have sound even when it is displaying images or videos.

  1. Is there a way to mute the soundtrack while an input video is being displayed? or to put the soundtrack volume down?
  2. Is there a way to loop the soundtrack? So when it finishes, it will start again

Thanks in advance

Hi Josue!

Audio can be muted by using an AudioAsset instead of Soundtrack. You can mute the AudioAsset by setting it’s volume to zero, and set it’s start, length and trim position like other assets.

Here is a JSON example showing how to start playing audio, then mute, then resume at the spot it was left off:

{
    "timeline": {
        "tracks": [
            {
                "clips": [
                    {
                        "asset": {
                            "type": "video",
                            "src": "https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/footage/sparks-sd.mp4"
                        },
                        "start": 0,
                        "length": 5
                    },
                    {
                        "asset": {
                            "type": "audio",
                            "src": "https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/music/unminus/palmtrees.mp3"
                        },
                        "start": 0,
                        "length": 2
                    },
                    {
                        "asset": {
                            "type": "audio",
                            "src": "https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/music/unminus/palmtrees.mp3",
                            "volume": 0
                        },
                        "start": 2,
                        "length": 1
                    },
                    {
                        "asset": {
                            "type": "audio",
                            "src": "https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/music/unminus/palmtrees.mp3",
                            "trim": 3
                        },
                        "start": 3,
                        "length": 2
                    }
                ]
            }
        ]
    },
    "output": {
        "format": "mp4",
        "resolution": "sd"
    }
}

The Soundtrack property doesn’t support looping, but check out this other community post Loop/repeat a sound track for some ideas.

2 Likes