After removing the audio part of a video strip, is there a way to bring it back (other than Ctrl+Z or manually re-importing and re-cutting the video)?
For example, in Kdenlive, you can right-click on a strip and click on "Restore audio".
After removing the audio part of a video strip, is there a way to bring it back (other than Ctrl+Z or manually re-importing and re-cutting the video)?
For example, in Kdenlive, you can right-click on a strip and click on "Restore audio".
It is possible to do using Python.
As a standalone script to run from the text editor or used in the Toolshelf addon (success and error messages will be posted in Blender's console):
import bpy
if (video_strip := bpy.context.scene.sequence_editor.active_strip):
# Check if the strip is a video strip
if video_strip.type == 'MOVIE':
movie_file = video_strip.filepath
movie_name = video_strip.name
start_frame = video_strip.frame_start
final_duration = video_strip.frame_final_duration
start_offset = video_strip.frame_offset_start
end_offset = video_strip.frame_offset_end
# Create a new sound strip using the same data block
sound_strip = bpy.context.scene.sequence_editor.sequences.new_sound(
name=f"{movie_name} Audio",
filepath=movie_file,
channel=video_strip.channel + 1,
frame_start=int(start_frame)
)
sound_strip.frame_final_duration = final_duration
sound_strip.frame_offset_start = start_offset
sound_strip.frame_offset_end = end_offset
print("Audio strip successfully recovered.")
else:
print("Selected strip is not a video strip.")
else:
print("Please select a video strip.")
Or as an operator under the sequencer's strip menu:
import bpy
class sequencer_OT_audio_from_video(bpy.types.Operator):
"""Recreates audio strip from selected video strip"""
bl_idname = "sequencer.simple_operator"
bl_label = "Audio from Video strip"
@classmethod
def poll(cls, context):
if context.scene.sequence_editor.active_strip == None:
cls.poll_message_set("Please select a video strip.")
return context.scene.sequence_editor.active_strip
def execute(self, context):
video_strip = bpy.context.scene.sequence_editor.active_strip
# Check if the strip is a video strip
if video_strip.type == 'MOVIE':
movie_file = video_strip.filepath
movie_name = video_strip.name
start_frame = video_strip.frame_start
final_duration = video_strip.frame_final_duration
start_offset = video_strip.frame_offset_start
end_offset = video_strip.frame_offset_end
# Create a new sound strip using the same data block
sound_strip = bpy.context.scene.sequence_editor.sequences.new_sound(
name=f"{movie_name} Audio",
filepath=movie_file,
channel=video_strip.channel + 1,
frame_start=int(start_frame)
)
sound_strip.frame_final_duration = final_duration
sound_strip.frame_offset_start = start_offset
sound_strip.frame_offset_end = end_offset
self.report({"INFO"}, "Audio strip successfully recovered.")
else:
self.report({"WARNING"}, "Selected strip is not a video strip.")
return {'FINISHED'}
def menu_func(self, context):
self.layout.operator(sequencer_OT_audio_from_video.bl_idname, text=sequencer_OT_audio_from_video.bl_label)
def register():
bpy.utils.register_class(sequencer_OT_audio_from_video)
bpy.types.SEQUENCER_MT_strip.append(menu_func)
def unregister():
bpy.utils.unregister_class(sequencer_OT_audio_from_video)
bpy.types.SEQUENCER_MT_strip.remove(menu_func)
if __name__ == "__main__":
register()
It will have a proper GUI. And you can save it in your Blender user directory/script/startup to always have it registered when Blender starts. But it will ask permission to be executed.