Skip to content

bug: Audio clips fail validation in loadEdit() but work when added programmatically #59

@jeffreytung7

Description

@jeffreytung7

Issue Summary

Audio clips with valid, accessible URLs throw "Invalid audio source" error when included in the initial edit.loadEdit() call, but work correctly when added programmatically using edit.addClip() after the edit loads.

Expected Behavior

Audio clips should load successfully when included in the edit configuration passed to edit.loadEdit(), just like video and image clips do.

Actual Behavior

When an audio clip is included in the initial edit configuration, loadEdit() throws an error:

Error: Invalid audio source 'https://cdn.jsdelivr.net/npm/@audio-samples/piano-mp3-velocity16@1.0.5/audio/A0v16.mp3'.

However, the same audio clip works perfectly when:

  1. Loading the edit without the audio track
  2. Then adding the audio clip programmatically using edit.addClip()

Steps to Reproduce

  1. Create an edit configuration with an audio clip:
const editConfig = {
    timeline: {
        tracks: [
            {
                clips: [
                    {
                        fit: 'none',
                        start: 0,
                        length: 10,
                        asset: {
                            type: 'audio',
                            src: 'https://cdn.jsdelivr.net/npm/@audio-samples/piano-mp3-velocity16@1.0.5/audio/A0v16.mp3',
                            volume: 0.2,
                            effect: 'none',
                        },
                    },
                ],
            },
        ],
    },
    output: {
        format: 'mp4',
        fps: 25,
        size: { width: 1080, height: 1920 },
    },
};
  1. Try to load the edit:
const edit = new Edit(editConfig.output.size, '#000000');
await edit.load();
await edit.loadEdit(editConfig); // ❌ Throws "Invalid audio source" error
  1. Workaround that works:
// Load without audio track
const editWithoutAudio = {
    ...editConfig,
    timeline: {
        tracks: editConfig.timeline.tracks.filter(track => 
            !track.clips.some(clip => clip.asset.type === 'audio')
        ),
    },
};
await edit.loadEdit(editWithoutAudio); // ✅ Works

// Add audio clip programmatically
const audioClip = editConfig.timeline.tracks[0].clips[0];
edit.addClip(0, audioClip); // ✅ Works

Technical Analysis

No response

Possible Solutions

No response

Tested Environment

Package: @shotstack/shotstack-studio@1.10.1
Browser: Chrome (latest)
OS: macOS
Framework: Nuxt 4.2.2 / Vue 3
TypeScript: 5.9.3

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwontfixThis will not be worked on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions