Video freeze and Audio Stutter when transitioning Tracks

Hi,

I am currently experiencing a stutter when transitioning from one track to another.
Here is the JSON i am using to make the call:

{
	"timeline": {
		"background": "#000000",
		"tracks": [{
				"clips": [{
					"asset": {
						"type": "video",
						"src": "https://s3.amazonaws.com/appforest_uf/f1644613959178x951703076454153200/video-full.mp4",
						"volume": 1
					},
					"start": 0,
					"length": 5.705
				}]
			},
			{
				"clips": [{
					"asset": {
						"type": "video",
						"src": "https://shotstack-api-v1-output.s3-ap-southeast-2.amazonaws.com/9woyk7kqcc/a315d933-4380-453c-b6a2-09190fc6d2bf.mp4",
						"volume": 1
					},
					"start": 5.705,
					"length": 10.4
				}]
			},
			{
				"clips": [{
					"asset": {
						"type": "video",
						"src": "https://shotstack-api-v1-output.s3-ap-southeast-2.amazonaws.com/9woyk7kqcc/6b2fcfc9-190b-4166-abe2-e277c1f74ab1.mp4",
						"volume": 1
					},
					"start": 16.105,
					"length": 10
				}]
			}
		]
	},
	"output": {
		"format": "mp4",
		"resolution": "1080"
	}
}

Here is the rendered video: https://shotstack-api-stage-output.s3-ap-southeast-2.amazonaws.com/9x06v367kd/166bb5ab-ae9b-4ecd-9c4e-91106fe55325.mp4
The stutter occurs on seconds 0, 5, and 15.

I would kindly ask for any assistance in determining the cause of this stutter.

Kind Regards,

Nils

Hey @Nils,

Just took a look at the video and the stutter is indeed quite noticeable. I checked the metadata on probe.video but this appears to be stripped. (You can use the media inspector API here as well)

Also the two final clips don’t appear to be available anymore.

I re-encoded the initial clip and generated the missing presentation time stamp:

ffmpeg -fflags +genpts -i video-full.mp4 -r 29.97 mp4-file.mp4

This shows me the following when using:

  • Video stream duration: 5.638972
  • Audio stream duration: 5.640000

The reason you don’t notice the discrepancy on an in-browser video player is that is adjusts playback for the smoothest viewing experience. When working with video editors they take the duration of different streams a little more stringent.

Hence when looping the re-encoded video at the duration of the video stream the stuttering disappears. You still hear a small audio artifact at the start of the video but the stuttering as it is shown in the initial video is gone:

{
	"timeline": {
		"background": "#000000",
		"tracks": [{
				"clips": [{
					"asset": {
						"type": "video",
						"src": "https://shotstack-content.s3.amazonaws.com/support/nils-1.mp4",
						"volume": 1
					},
					"start": 0,
					"length": 5.638972
				}]
			},
			{
				"clips": [{
					"asset": {
						"type": "video",
						"src": "https://shotstack-content.s3.amazonaws.com/support/nils-1.mp4",
						"volume": 1
					},
					"start": 5.638972,
					"length": 5.638972
				}]
			}
		]
	},
	"output": {
		"format": "mp4",
		"resolution": "1080"
	}
}

How do you encode your videos? Is there a way to make sure the timestamps are included with the video? This way you can make sure the clips only lasts for as long as it needs to run.

I am seeing a lot of this from webm videos. There’s a lot of it happening on our product here. Would love to know if there’s a way of fixing? https://playmonash.com

1 Like