VSE: Adding packed sound via python API produces strip with incorrect length #103662

Open
opened 2023-01-05 15:55:33 +01:00 by Antonio Vazquez · 13 comments

Broken: Blender 3.4.1

image.png

Steps to reproduce
#103662.blend

  • Open file
  • Run script

Look in console

It prints Strip duration is 1 which is incorrect.
This is because BKE_sound_info_get() does not work correctly with packed sound.

Broken: Blender 3.4.1 ![image.png](https://archive.blender.org/developer/F14115563/image.png) **Steps to reproduce** [#103662.blend](https://archive.blender.org/developer/F14136196/T103662.blend) - Open file - Run script # Look in console It prints `Strip duration is 1` which is incorrect. This is because `BKE_sound_info_get()` does not work correctly with packed sound.
Author
Member

Added subscriber: @antoniov

Added subscriber: @antoniov
Author
Member

Added subscribers: @mendio, @pepe-school-land

Added subscribers: @mendio, @pepe-school-land
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
Member

Hi, can confirm in uploaded file for versions 3.2 and later.
But I'm not able to replicate this from scratch. @antoniov , can you share the python code/command?

Hi, can confirm in uploaded file for versions 3.2 and later. But I'm not able to replicate this from scratch. @antoniov , can you share the python code/command?
Member

Added subscriber: @iss

Added subscriber: @iss
Member

git bisect points to: 302b04a5a3
@iss ^

git bisect points to: 302b04a5a3 @iss ^
Pratik Borhade changed title from VSE: Strip bar is displayed before Offset position to Regression: VSE: Strip bar is displayed before Offset position 2023-01-06 07:28:18 +01:00
Author
Member

@PratikPB2123 The script is complex and it's part of the new version of the Storypencil add-on.

here an extract

def send_sound_strip(s, dest_scn):
    '''recreate sound strip in another scene
    :dest_scn: scene destination
    :return: newly create sound strip
    '''

    if s.type != 'SOUND':
        return
    vse = dest_scn.sequence_editor
    ns = vse.sequences.new_sound(name=s.name, filepath=s.sound.filepath, channel=s.channel, frame_start=int(s.frame_start))
    ns.sound = s.sound # reget the same sound source

    for attr in ('pitch',
                 'pan',
                 'show_waveform',
                 'speed_factor',
                 'volume',
                 'mute'):
        if hasattr(s, attr):
            setattr(ns, attr, getattr(s, attr))
    if ns.volume == 0:
        ns.volume = 1
    return ns


- s must be a sound type strip
- tgt_scene is the target scene
ns = send_sound_strip(s, tgt_scene)
if ns:
    ns.frame_start = new_start
    ns.frame_offset_start = s.frame_offset_start
    ns.frame_final_duration = s.frame_final_duration

The script is adding a sound strip to a different scene, I mean, there is a VSE scene where you are editing the storyboard and when you switch to the Strip scene (you have one strip for each scene in the VSE), the audio is copied to the Edit scene.

If you need the full script I can provide you, but sure you will need some "training" to use it. Let me know if you need it and I can help you with the test.

@PratikPB2123 The script is complex and it's part of the new version of the `Storypencil` add-on. here an extract ``` def send_sound_strip(s, dest_scn): '''recreate sound strip in another scene :dest_scn: scene destination :return: newly create sound strip ''' if s.type != 'SOUND': return vse = dest_scn.sequence_editor ns = vse.sequences.new_sound(name=s.name, filepath=s.sound.filepath, channel=s.channel, frame_start=int(s.frame_start)) ns.sound = s.sound # reget the same sound source for attr in ('pitch', 'pan', 'show_waveform', 'speed_factor', 'volume', 'mute'): if hasattr(s, attr): setattr(ns, attr, getattr(s, attr)) if ns.volume == 0: ns.volume = 1 return ns - s must be a sound type strip - tgt_scene is the target scene ns = send_sound_strip(s, tgt_scene) if ns: ns.frame_start = new_start ns.frame_offset_start = s.frame_offset_start ns.frame_final_duration = s.frame_final_duration ``` The script is adding a sound strip to a different scene, I mean, there is a VSE scene where you are editing the storyboard and when you switch to the Strip scene (you have one strip for each scene in the VSE), the audio is copied to the Edit scene. If you need the full script I can provide you, but sure you will need some "training" to use it. Let me know if you need it and I can help you with the test.

Changed status from 'Needs Developer To Reproduce' to: 'Needs User Info'

Changed status from 'Needs Developer To Reproduce' to: 'Needs User Info'

I can confirm there is difference in strip appearance between versions, but I don't think this is actual bug.

Applying following code produced correct result:

    ns.frame_start = new_start
    ns.frame_offset_start = s.frame_offset_start
    ns.frame_final_duration = s.frame_final_duration

One thing that is odd is that in sample file seq->len is 1, which seems to produce incorrect end offset and strip ends up inverted. This can happen if filepath argument of new_sound() is not valid.

Duration of sound strip can be fixed by triggering update via scene FPS property. But the strip is then even more broken than before, but this is bit different issue, see D9997.

@antoniov Can you check if sound file is correct? Or perhaps look at strip.frame_duration property during strip execution - it should not be 1.

I can confirm there is difference in strip appearance between versions, but I don't think this is actual bug. Applying following code produced correct result: ``` ns.frame_start = new_start ns.frame_offset_start = s.frame_offset_start ns.frame_final_duration = s.frame_final_duration ``` One thing that is odd is that in sample file `seq->len` is 1, which seems to produce incorrect end offset and strip ends up inverted. This can happen if `filepath` argument of `new_sound()` is not valid. Duration of sound strip can be fixed by triggering update via scene FPS property. But the strip is then even more broken than before, but this is bit different issue, see [D9997](https://archive.blender.org/developer/D9997). @antoniov Can you check if sound file is correct? Or perhaps look at `strip.frame_duration` property during strip execution - it should not be 1.
Author
Member

@iss The sound strip looks right in the target scene. If you play it, you get the right sound in the right place. About duration, in the UI I can see it's 42, the correct number.

Maybe I need to run some type of update to refresh Strip information.... any idea about this? You say FPS update the strips... what is your advice, change FPS to something and then back to the right value?

EDIT: It looks reload strips fix the issue.

@iss The sound strip looks right in the target scene. If you play it, you get the right sound in the right place. About `duration`, in the UI I can see it's 42, the correct number. Maybe I need to run some type of update to refresh Strip information.... any idea about this? You say `FPS` update the strips... what is your advice, change FPS to something and then back to the right value? EDIT: It looks reload strips fix the issue.

In #103662#1470250, @antoniov wrote:
@iss The sound strip looks right in the target scene. If you play it, you get the right sound in the right place.

Ah did not realize there are more scenes... So I will try to run the script to reproduce. The issue could be, that the sound is packed.

About duration, in the UI I can see it's 42, the correct number.

Correct, but duration in UI is calculated from whole strip duration minus offsets. Internally the strip had duration of 1 frame.

It looks reload strips fix the issue.

Never used that operator so did not come to my mind, but glad there is solution to fix existing file. Still would like to prevent such issue.

> In #103662#1470250, @antoniov wrote: > @iss The sound strip looks right in the target scene. If you play it, you get the right sound in the right place. Ah did not realize there are more scenes... So I will try to run the script to reproduce. The issue could be, that the sound is packed. > About `duration`, in the UI I can see it's 42, the correct number. Correct, but duration in UI is calculated from whole strip duration minus offsets. Internally the strip had duration of 1 frame. > It looks reload strips fix the issue. Never used that operator so did not come to my mind, but glad there is solution to fix existing file. Still would like to prevent such issue.
Richard Antalik changed title from Regression: VSE: Strip bar is displayed before Offset position to VSE: Adding packed sound via python API produces strip with incorrect length 2023-01-09 18:56:45 +01:00

Changed status from 'Needs User Info' to: 'Confirmed'

Changed status from 'Needs User Info' to: 'Confirmed'
Bastien Montagne added this to the Core project 2023-02-09 15:43:54 +01:00
Bastien Montagne removed this from the Core project 2023-02-09 18:20:29 +01:00
Philipp Oeser removed the
Interest
VFX & Video
label 2023-02-10 09:31:28 +01:00
Philipp Oeser added the
Interest
Core
label 2023-02-10 11:09:21 +01:00
Sergey Sharybin added
Type
Bug
and removed
Type
Report
labels 2023-02-15 12:45:20 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#103662
No description provided.