Hi
using blender ro convert a video demands to go to different panels :
here’s a panel to have just one converter
The panel becomes the last panel in Sequence Editor ( N )
import bpy
from mathutils import Vector
bl_info = {
"name": "br_VideoReformat",
"author": "Bruno 'dindoun' Sanchiz ",
"version": (2, 0),
"blender": (2, 7, 1),
"location": "SEQUENCE_EDITOR > UI",
"description": "transform a video",
"category": "video",
'wiki_url': '' \
'',
'tracker_url': ''\
''}
class CustomPanel(bpy.types.Panel):
"""A Custom Panel in the Viewport Toolbar"""
bl_label = "transform video"
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
_frame_rate_args_prev = None
_preset_class = None
@classmethod
def poll(cls, context):
return 'pas n one'#pas None
def draw_header(self, context):
layout = self.layout
def _draw_framerate_label(*args):
# avoids re-creating text string each draw
if CustomPanel._frame_rate_args_prev == args:
return CustomPanel._frame_rate_ret
fps, fps_base, preset_label = args
if fps_base == 1.0:
fps_rate = round(fps)
else:
fps_rate = round(fps / fps_base, 2)
# TODO: Change the following to iterate over existing presets
custom_framerate = (fps_rate not in {23.98, 24, 25, 29.97, 30, 50, 59.94, 60})
if custom_framerate is True:
fps_label_text = "Custom (%r fps)" % fps_rate
show_framerate = True
else:
fps_label_text = "%r fps" % fps_rate
show_framerate = (preset_label == "Custom")
CustomPanel._frame_rate_args_prev = args
CustomPanel._frame_rate_ret = args = (fps_label_text, show_framerate)
return args
@staticmethod
def draw_framerate(sub, rd):
if CustomPanel._preset_class is None:
CustomPanel._preset_class = bpy.types.RENDER_MT_framerate_presets
args = rd.fps, rd.fps_base, CustomPanel._preset_class.bl_label
fps_label_text, show_framerate = CustomPanel._draw_framerate_label(*args)
sub.menu("RENDER_MT_framerate_presets", text=fps_label_text)
if show_framerate:
sub.prop(rd, "fps")
sub.prop(rd, "fps_base", text="/")
def act_strip(self,context):
try:
return context.scene.sequence_editor.active_strip
except AttributeError:
return None
def draw(self, context):
scene=bpy.context.scene
print('scene.sequence_editor.sequences',scene.sequence_editor.sequences.new_movie,dir(scene.sequence_editor.sequences))
layout = self.layout
rd = scene.render
##########################################################################"
'''
col = layout.column()
#scene.sequence_editor.sequences.new_movie
col.prop(scene, "sequence_editor.sequences.new_movie", text="X")
#tex = context.texture
#layout.template_image(tex, "image", tex.image_user)
#bpy.ops.sequencer.movie_strip_add()
'''
col = layout.column()
sub = col.column(align=True)
sub.label(text="Resolution:")
sub.prop(rd, "resolution_x", text="X")
sub.prop(rd, "resolution_y", text="Y")
sub.prop(rd, "resolution_percentage", text="")
self.draw_framerate(sub,rd)
row = layout.row()
try:
strip = self.act_strip(context)
row.prop(strip, "frame_start")
row.prop(strip, "filepath", text="")
print(strip.name,dir(strip))
except:
try:
strip = self.act_strip(context)
split.prop(strip, "filepath", text="")
except:
pass
rd = context.scene.render
image_settings = rd.image_settings
file_format = image_settings.file_format
layout.prop(rd, "filepath", text="")
split = layout.split()
col = split.column()
col.active = not rd.is_movie_format
col.prop(rd, "use_overwrite")
col.prop(rd, "use_placeholder")
split.prop(rd, "use_file_extension")
layout.template_image_settings(image_settings, color_management=False)
if file_format == 'QUICKTIME':
quicktime = rd.quicktime
split = layout.split()
col = split.column()
col.prop(quicktime, "codec_type", text="Video Codec")
col.prop(quicktime, "codec_spatial_quality", text="Quality")
# Audio
col.prop(quicktime, "audiocodec_type", text="Audio Codec")
if quicktime.audiocodec_type != 'No audio':
split = layout.split()
if quicktime.audiocodec_type == 'LPCM':
split.prop(quicktime, "audio_bitdepth", text="")
split.prop(quicktime, "audio_samplerate", text="")
split = layout.split()
col = split.column()
if quicktime.audiocodec_type == 'AAC':
col.prop(quicktime, "audio_bitrate")
subsplit = split.split()
col = subsplit.column()
if quicktime.audiocodec_type == 'AAC':
col.prop(quicktime, "audio_codec_isvbr")
col = subsplit.column()
col.prop(quicktime, "audio_resampling_hq")
#encoding
rd = context.scene.render
if rd.image_settings.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}:
ffmpeg = rd.ffmpeg
layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
split = layout.split()
split.prop(rd.ffmpeg, "format")
if ffmpeg.format in {'AVI', 'QUICKTIME', 'MKV', 'OGG'}:
split.prop(ffmpeg, "codec")
elif rd.ffmpeg.format == 'H264':
split.prop(ffmpeg, "use_lossless_output")
else:
split.label()
row = layout.row()
row.prop(ffmpeg, "video_bitrate")
row.prop(ffmpeg, "gopsize")
split = layout.split()
col = split.column()
col.label(text="Rate:")
col.prop(ffmpeg, "minrate", text="Minimum")
col.prop(ffmpeg, "maxrate", text="Maximum")
col.prop(ffmpeg, "buffersize", text="Buffer")
col = split.column()
col.prop(ffmpeg, "use_autosplit")
col.label(text="Mux:")
col.prop(ffmpeg, "muxrate", text="Rate")
col.prop(ffmpeg, "packetsize", text="Packet Size")
layout.separator()
# Audio:
if ffmpeg.format != 'MP3':
layout.prop(ffmpeg, "audio_codec", text="Audio Codec")
row = layout.row()
row.prop(ffmpeg, "audio_bitrate")
row.prop(ffmpeg, "audio_volume", slider=True)
row = layout.row()
row.operator("render.render", text="Animation", icon='RENDER_ANIMATION').animation = True
def register():
print("debut register")
bpy.utils.register_class(CustomPanel)
print("fin register")
def unregister():
bpy.utils.unregister_class(CustomPanel)
if __name__ == "__main__":
register()