Skip to main content
Participating Frequently
March 11, 2024
Question

InsertClip adding strange offset in audio-only track-item for a particular audio file.

  • March 11, 2024
  • 1 reply
  • 1728 views

Goal:

  • Using PP-Scripting Clone a subsequence (created using Sequence.createSubsequence()) in its raw clips form to create a target sequence. Multiple subsequences will be used to create the complete target sequence without using subsequences to avoid nested sequences.

Scenario:

  • Multiple cameras are used for footage, while their audios are not used. Audios are sourced from separate audio recording devices.
  • Adobe Premiere Pro 2024 (Version 24.2.1) Build 2
  • Windows 10

Method Adopted:

  • Looped over each video track in the source. Copied each clip and inserted it into the target, similar to the source, using insertClip(). Removed its audio part. Then, looped over each audio track in the source. Inserted each audio clip into the target, similar to the source.

Problem:

  • This worked fine for video tracks. However, for audio tracks, the first track clip (Track 2) with the Audio Item (Tr2.wav) seems to get inserted with an offset. The original subsequence had Track 2 at 0 ticks. Inserting it in the Target Sequence at 0 ticks yields a clip with a few seconds offset.

    Important Note:

    • The problem does not occur when a .prproj file is downgraded for opening in Premiere Pro 2023 and saved. Processing this saved .prproj file, even with Premiere Pro 2024, yields the expected result (clip insertion at specified start time-ticks).

Comments:

  • I am not sure if this is a bug in Premiere Pro 2024, a problem in the approach used, or some error in the code. Maybe I forgot a terminator 😄

Code: (For audio-tracks cloning portion)

 

 

 

    // Loop through each audio track in the source sequence
    for (var i = 0; i < src_seq.audioTracks.numTracks; i++) {
        var audioTrack = src_seq.audioTracks[i];
        var targetAudioTrack = target_seq.audioTracks[i];

        var clipOffset = 0; // Initialize clip offset

        // Process each clip in the current audio track
        for (var j = 0; j < audioTrack.clips.numItems; j++) {
            var clip = audioTrack.clips[j];
            var clip_projectItem = clip.projectItem;

            var inPoint = clip.inPoint;
            var outPoint = clip.outPoint;
            var clipDuration = clip.end.ticks - clip.start.ticks; // Duration in ticks

            var newClipStartTime = lastEndTime + clipOffset; // Calculate new start time

            targetAudioTrack.insertClip(clip_projectItem, String(newClipStartTime));            
            
            var targetClipIndex = targetAudioTrack.clips.numItems - 1;
            var targetClip = targetAudioTrack.clips[targetClipIndex];

            var curr_end_sec = tick_to_sec(newClipStartTime + clipDuration);

            // Set the in and out points for the target clip
            targetClip.inPoint = inPoint;
            targetClip.outPoint = outPoint;
            targetClip.end = curr_end_sec; // Adjust the end time

            targetClip.disabled = clip.disabled; // Copy the disabled state

            clipOffset = clipDuration; // Update clip offset for the next iteration

        }
    }

 

 

 

 

This topic has been closed for replies.

1 reply

Bruce Bullis
Legend
March 14, 2024

Nice details; we'll have a look. 

Is there a possibility that the offset, is the result of PPro moving to a frame boundary? 

>The problem does not occur when a .prproj file is downgraded for opening in Premiere Pro 2023 and saved

How are you performing that downgrade? 


Participating Frequently
March 14, 2024

Hey Bruce,

   Thanks for responding. I am not sure what you mean by,

Is there a possibility that the offset, is the result of PPro moving to a frame boundary? 

 

  • The downgrade was done simply by opening the saved .prproj using Premier. Pro 2023. It gives the dialogue that it seems the . prproj was saved using a newer version of Premier pro and proceeds to save a downgraded version to be able to open it with Premier Pro 2023. This new .prproj is saved with I think a subscript of ._1.prproj.
Bruce Bullis
Legend
March 14, 2024

My untested theory was that PPro may have been creating that offset, to align with frame boundaries within that sequence .

And yes, I just wanted to make sure you weren't using some dodgy 3rd party utility to downgrade the .prproj.