<div dir="ltr"><div><div><div><div><div><div>Hi, <br><br></div>I'm doing an exporter to ardour and it runs an external ffmpeg. I'm wondering if there is a way of letting user point to a local ffmpeg executable in case it is not recognized by "which". The idea is to replace the RuntimeError with something like:<br>
<br>with open(self.filepath) as file:<br>            ffCommand = self.filepath<br><br></div><div>but this only works inside classes.<br></div><div><br><br><br></div>Relevant code is below:<br><br></div>this is the main class:<br>
<br>class ExportArdour(bpy.types.Operator, ExportHelper):<br>    """Export audio timeline (including audios from videos) to Ardour"""<br>    bl_idname = "export.ardour"<br>    bl_label = "Export to Ardour"<br>
    filename_ext = ".ardour"<br>    filter_glob = StringProperty(default="*.ardour", options={'HIDDEN'})<br><br>    @classmethod<br>    def poll(cls, context):<br>        if bpy.context.sequences:<br>
            return context.sequences is not None<br><br>    def execute(self, context):<br>        scene = bpy.context.scene<br>        startFrame = scene.frame_start<br>        endFrame = scene.frame_end<br>        fps, timecode = checkFPS()<br>
<br>        system = bpy.context.user_preferences.system<br>        audioRate = int(system.audio_sample_rate.split("_")[1])<br>        <br>        audiosFolderPath, ardourFile = os.path.split(self.filepath)<br>        ardourBasename = os.path.splitext(ardourFile)[0]<br>
        audiosFolder = audiosFolderPath + os.sep + "Audios_for_" + ardourBasename<br>        <br>        Session = createXML(startFrame, endFrame, fps, timecode, audioRate, <br>                            ardourBasename, audiosFolder)<br>
<br>        runFFMPEG(sources, audioRate, audiosFolder)<br>        writeXML(self.filepath, Session)<br><br>        return {'FINISHED'}<br><br><br></div>..........that calls this function (notice the RunTime error):<br>
<br>def runFFMPEG(sources, audioRate, outputFolder):<br>    if which('ffmpeg') is not None:<br>        if (<a href="http://os.name">os.name</a> == "nt"):<br>            ffCommand = ffmpegPath + os.sep + "ffmpeg.exe"<br>
        else:<br>            ffCommand = "ffmpeg"<br>    else:<br>        raise RuntimeError("You don\'t seem to have FFMPEG installed on your system. \<br>                            Please install it and re-run the Ardour exporter.")<br>
<br>    if (os.path.exists(outputFolder) is False):<br>        os.mkdir(outputFolder)<br>            <br>    for source in sources:<br>        basename, ext = os.path.splitext(source['name'])<br><br>        input = source['origin']<br>
        if (input.startswith("//")):<br>            input = input.replace("//", "")        <br><br>        output = outputFolder + os.sep + basename + ".wav"<br><br>        # Due to spaces, the command entries (ffCommand, input and output) have <br>
        # to be read as strings by the call command, thus the escapings below<br>        callFFMPEG = "\"%s\" -i \"%s\" -y -vn -ar %i -ac 1 \"%s\"" \<br>                     % (ffCommand, input, audioRate, output)<br>
        call(callFFMPEG, shell=True)<br>        <br>    return {'FINISHED'}<br><br></div><br><br>thanks.<br><br></div>flavio<br></div>