3
$\begingroup$

I'm following this tutorial and I'm about 29 minutes in. I'm using the .mp3 mentioned in the tutorial. Here's my latest .blend...

My script will create a single cube and switch the window context to GRAPH_EDITOR, but then crashes out with the error, "unsupported audio format". Error text follows...

Traceback (most recent call last): File "J:\My Documents\Desktop\Motion Graphics\cgCookieVisualiser01001Rev.blend \Text", line 34, in File "E:\Program Files\Blender Foundation\Blender\2.70\scripts\modules\bpy\ops .py", line 188, in call ret = op_call(self.idname_py(), None, kw) RuntimeError: Error: Unsupported audio format

Error: Python script fail, look in the console for now...

It seems strange that the .mp3 wouldn't import via script. Has anybody a suggestion on how I should tackle this?

$\endgroup$
0

2 Answers 2

5
$\begingroup$

I just tested your file with one of my own .mp3s and found two problems:

  1. The path contains backslashes. This is standard in Windows, but has special meaning in many programming languages. The backslash means that the following character should not be interpreted as a normal character but as a control character (like \n stands for new-line and \a will make a beeping sound). Your path contains a \0 which (at least in C) is interpreted as 'End of String'. This messes up your path: When the string ends there, the file is actualy a folder and has no extension. Thus it can not be recognized as a supported audio format.
    There are two possible solutions:

    1. Replace all backslashes with forward slashes / and make a Unix-style path
    2. Replace them with double backslashes \\. The first backslash removes the special meaning of the second backslash and makes it a normal character again.
  2. You wrote true instead of True (with a capital letter) in line 37. This is a minor issue, but causes an error when you run the script ;)

After that your script runs fine.

EDIT :
I just found another mehtod to use string literals with backslashes. If you write

mypath = r"C:\Path\To\Some\File.mp3"

the r in front of the string literal tells python that this is a so-called raw string literal. This will preserve the backslashes and not use them to create control characters.

$\endgroup$
5
  • $\begingroup$ Both your points are accurate but this is probably not the problem. It doesn't correlate with the error message OP posted. $\endgroup$
    – iKlsR
    May 10, 2014 at 10:47
  • $\begingroup$ @iKlsR I think it does. In his path there is a \0 which (at least in C) is interpreted as 'End of String'. When the string ends there, the file is actualy a folder and has no extension. Thus it can not be recognized as a supported audio format. I added it to the answer. $\endgroup$
    – maddin45
    May 10, 2014 at 10:57
  • $\begingroup$ YOP. Does the trick. And dern'd educational too! Shoulda spotted the backslash thing, but I'm just not used to Unix and the \0 thing is just cunning. Double backslashes seemed to cause Blender to lock up, but forward slashes results in sweet, sweet expected behaviour. Regards 'true'... sigh Well, this is the first Python I've ever touched...! =) Many thanks to both of you for your observation and knowledge! $\endgroup$ May 10, 2014 at 11:08
  • $\begingroup$ @maddin45 I checked the blend file. It was partly the issue but I know Blender spits the same error if ffmpeg is missing. $\endgroup$
    – iKlsR
    May 10, 2014 at 11:19
  • $\begingroup$ It's worth mentioning that in Win7 and .Net languages paths work fine under windows even with unix style paths using /, whenever or not this was also the case before Win7 is something I don't know right now. $\endgroup$ Dec 24, 2016 at 9:50
3
$\begingroup$

In addition to the points maddin45 shared which directly pertain to your script, to play .mp3 files in Blender, you need a build that was compiled with ffmpeg support.

If your current build for some reason doesn't have this, you can always grab a new one.

$\endgroup$

You must log in to answer this question.

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