# Extract audio to file from movie clip - with Blender?

In this excellent answer I learned how to extract a series of individual frames from a movie clip node.

This solution suits me well - there is a python script, and a few nodes, and it runs automatically.

Is there a way I could extract the audio from a clip - either the whole thing, or possibly just between two frame number limits, using a similarly simple technique in Blender? For me simple is python and nodes - I am not an advanced user, and something I can automate and customize is the most useful in my case.

I've have tried to examine the attributes of the vidNode but didn't find anything that looked like audio:

S = bpy.context.scene
n = S.node_tree

vidNode = n.nodes['Movie Clip']


• What about ffmpeg: stackoverflow.com/a/27413824/3091066 ? – p2or Sep 3 '16 at 9:45
• @poor Thanks! I'm sure there are several ways to do this, but I am looking for something that runs in a python environment - preferably either my anaconda installation or preferably in Blender. The more ways I learn to use capabilities of Blender, the more I can learn about Blender. If there is a way I can do this using Blender, I would like to understand how. Even if it's not the "best" way to do it, if it can be done here I'd really like to do it here. – uhoh Sep 3 '16 at 15:49
• In my opinion your best bet is to use VSE. Even if I don't know its python capabilities I think it's the only part of Blender that can do audio things (except Game Engine). – Polosson Sep 12 '16 at 7:33

## 1 Answer

Currently there isn't a node with that capability built in. The simplest that you might script is the following:

• add the clip to the VSE
• set start and endframe: bpy.context.scene.frame_start and .frame_end
• call the mixdown operator: bpy.ops.sound.mixdown (see the docs for parameters)
• reset frame start/end if you need to.

something like this.

import bpy

def main(filepath_source, filepath_destination, frame_start=0, frame_end=20):
scn = bpy.context.scene

scn.frame_start = frame_start
scn.frame_end = frame_end

if not scn.sequence_editor:
scn.sequence_editor_create()

sequences = scn.sequence_editor.sequences
sequences.new_sound(
name='drone_detroit',
filepath=filepath_source,
channel=0, frame_start=0
)
bpy.ops.sound.mixdown(filepath=filepath_destination)

fp_source = r"C:\Users\zeffi\Downloads\DRONE\0001-2964.avi"
fp_destination = r"C:\Users\zeffi\OneDrive\Documents\chopper_drone4.flac"

main(fp_source, fp_destination, frame_start=500, frame_end=560)


the sequences.new_sound, lifts the audio track off the .avi.

The mixdown operator will output the audio of whatever is between those two frames.

• zeffii to the rescue - OK that's great. This will drag me kicking and screaming into the world of the video sequence editor - which is a good thing. There's a typhoon coming so I'll be stuck indoors in need of a project, perfect timing! – uhoh Sep 12 '16 at 9:57