3
$\begingroup$

I can't get the sound_bake function to work by script while it works fine from the menu (Unsupported audio format). Any idea ?

I have no backslashes in the path and my blender build includes ffmpeg... so I am out of idea... ?

Especially since it works when I bake manually from the menu with the same file !

Here's the piece of code :

# get the path from the sequencer
bpy.context.area.type = "SEQUENCE_EDITOR"
for s in bpy.context.scene.sequence_editor.sequences:
    if s.type == 'SOUND':
        file_path = s.filepath

# insert keyframe to the VU of the 3d object        
bpy.context.area.type = "VIEW_3D"
bpy.context.scene.objects.active = bpy.data.objects['vu']

bpy.ops.anim.keyframe_insert_menu(type = "Scaling")
bpy.context.active_object.animation_data.action.fcurves[0].lock = True
bpy.context.active_object.animation_data.action.fcurves[1].lock = True

# bake
bpy.context.area.type = "GRAPH_EDITOR"
bpy.ops.graph.sound_bake(filepath=file_path, low=(0), high=(2000))

Thanks for reading !

$\endgroup$
6
  • $\begingroup$ Have you checked the python command log in the Info Editor (The one you get when dragging down the topmost interface element in the default interface) when doing the bake manually from the menu? Maybe it's calling the functionality in a slightly different way there, providing e.g. more parameters for sound_bake(...) or doing additional calls before or after. Investigate and let us know! :) $\endgroup$
    – Simon Repp
    Aug 25, 2014 at 11:53
  • $\begingroup$ Thanks for your answer. Unfortunately the log remains silent.... nothing is written there when I bake from the menu. $\endgroup$
    – Nikos_VSE
    Aug 25, 2014 at 12:13
  • $\begingroup$ Ouch, alright, let's tackle it from another side: Have you absolutely ruled out the possibility that it's a problem with the path? (absolute vs. relative, autopack interfering maybe in some way?) Maybe post some sample path strings you are using! Also it'd be interesting to know about your used audio format ... encoding, channels, samplerate, file extension, etc., anything that might provide clues! $\endgroup$
    – Simon Repp
    Aug 25, 2014 at 13:01
  • $\begingroup$ ok, mh... I think you are right and the exception message is misleading. I tried : file_path = 'aaargh', which is obviously not a file and got the same message. That leaves us with the probable path issue. I recall that the script succeeded once... Here's my file: dl.dropboxusercontent.com/u/15662864/vu.zip Thanks Simon for your help, I really appreciate it ! $\endgroup$
    – Nikos_VSE
    Aug 25, 2014 at 14:29
  • $\begingroup$ ok, it works with an 'absolute' path ! You were right ! That's wonderful ! Now I just have to figure out how to get the absolute path out of a sequence, from the VSE. $\endgroup$
    – Nikos_VSE
    Aug 25, 2014 at 14:35

1 Answer 1

3
$\begingroup$

So here's the trick : Blender internally use relative paths but provides a function to convert it to 'absolute'.

In my case, I just had to add the line :

absolute_path = bpy.path.abspath(s.file_path) 

Thanks again Simon

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .