forked from bartvdbraak/blender
mplayer preset, plays back movies and image sequences.
added scene.render.is_movie_format
This commit is contained in:
parent
c3c16603d2
commit
c052a5bc36
@ -25,25 +25,25 @@
|
||||
# Originally written by Matt Ebb
|
||||
|
||||
import bpy
|
||||
import subprocess
|
||||
import os
|
||||
import platform
|
||||
|
||||
|
||||
def guess_player_path(preset):
|
||||
import platform
|
||||
|
||||
if preset == 'BLENDER24':
|
||||
player_path = 'blender'
|
||||
player_path = "blender"
|
||||
|
||||
if platform.system() == 'Darwin':
|
||||
test_path = '/Applications/blender 2.49.app/Contents/MacOS/blender'
|
||||
test_path = "/Applications/blender 2.49.app/Contents/MacOS/blender"
|
||||
elif platform.system() == 'Windows':
|
||||
test_path = '/Program Files/Blender Foundation/Blender/blender.exe'
|
||||
test_path = "/Program Files/Blender Foundation/Blender/blender.exe"
|
||||
|
||||
if os.path.exists(test_path):
|
||||
player_path = test_path
|
||||
|
||||
elif preset == 'DJV':
|
||||
player_path = 'djv_view'
|
||||
player_path = "djv_view"
|
||||
|
||||
if platform.system() == 'Darwin':
|
||||
test_path = '/Applications/djv-0.8.2.app/Contents/Resources/bin/djv_view'
|
||||
@ -51,10 +51,13 @@ def guess_player_path(preset):
|
||||
player_path = test_path
|
||||
|
||||
elif preset == 'FRAMECYCLER':
|
||||
player_path = 'framecycler'
|
||||
player_path = "framecycler"
|
||||
|
||||
elif preset == 'RV':
|
||||
player_path = 'rv'
|
||||
player_path = "rv"
|
||||
|
||||
elif preset == 'MPLAYER':
|
||||
player_path = "mplayer"
|
||||
|
||||
|
||||
return player_path
|
||||
@ -67,6 +70,8 @@ class PlayRenderedAnim(bpy.types.Operator):
|
||||
bl_options = {'REGISTER'}
|
||||
|
||||
def execute(self, context):
|
||||
import subprocess
|
||||
|
||||
scene = context.scene
|
||||
rd = scene.render
|
||||
prefs = context.user_preferences
|
||||
@ -74,19 +79,33 @@ class PlayRenderedAnim(bpy.types.Operator):
|
||||
preset = prefs.filepaths.animation_player_preset
|
||||
player_path = prefs.filepaths.animation_player
|
||||
file_path = bpy.utils.expandpath(rd.output_path)
|
||||
is_movie = rd.is_movie_format
|
||||
|
||||
# try and guess a command line if it doesn't exist
|
||||
if player_path == '':
|
||||
player_path = guess_player_path(preset)
|
||||
|
||||
if preset in ('FRAMECYCLER', 'RV'):
|
||||
if is_movie == False and preset in ('FRAMECYCLER', 'RV', 'MPLAYER'):
|
||||
# replace the number with '#'
|
||||
file_a, file_b = rd.frame_path(frame=0), rd.frame_path(frame=1)
|
||||
file_a = rd.frame_path(frame=0)
|
||||
|
||||
# TODO, make an api call for this
|
||||
frame_tmp = 9
|
||||
file_b = rd.frame_path(frame=frame_tmp)
|
||||
|
||||
while len(file_a) == len(file_b):
|
||||
frame_tmp = (frame_tmp * 10) + 9
|
||||
print(frame_tmp)
|
||||
file_b = rd.frame_path(frame=frame_tmp)
|
||||
file_b = rd.frame_path(frame=int(frame_tmp / 10))
|
||||
|
||||
file = ''.join([(c if file_b[i] == c else "#") for i, c in enumerate(file_a)])
|
||||
else:
|
||||
# works for movies and images
|
||||
file = rd.frame_path(frame=scene.start_frame)
|
||||
|
||||
file = bpy.utils.expandpath(file) # expand '//'
|
||||
|
||||
cmd = [player_path]
|
||||
# extra options, fps controls etc.
|
||||
if preset == 'BLENDER24':
|
||||
@ -101,6 +120,15 @@ class PlayRenderedAnim(bpy.types.Operator):
|
||||
elif preset == 'RV':
|
||||
opts = ["-fps", str(rd.fps), "-play", "[ %s ]" % file]
|
||||
cmd.extend(opts)
|
||||
elif preset == 'MPLAYER':
|
||||
opts = []
|
||||
if is_movie:
|
||||
opts.append(file)
|
||||
else:
|
||||
opts.append("mf://%s" % file.replace("#", "?"))
|
||||
opts += ["-mf", "fps=%.4f" % (rd.fps / rd.fps_base)]
|
||||
opts += ["-loop", "0", "-really-quiet", "-fs"]
|
||||
cmd.extend(opts)
|
||||
else: # 'CUSTOM'
|
||||
cmd.append(file)
|
||||
|
||||
|
@ -369,6 +369,12 @@ static int rna_RenderSettings_threads_get(PointerRNA *ptr)
|
||||
return BLI_system_thread_count();
|
||||
}
|
||||
|
||||
static int rna_RenderSettings_is_movie_fomat_get(PointerRNA *ptr)
|
||||
{
|
||||
RenderData *rd= (RenderData*)ptr->data;
|
||||
return BKE_imtype_is_movie(rd->imtype);
|
||||
}
|
||||
|
||||
static int rna_RenderSettings_save_buffers_get(PointerRNA *ptr)
|
||||
{
|
||||
RenderData *rd= (RenderData*)ptr->data;
|
||||
@ -2321,6 +2327,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
|
||||
RNA_def_struct_name_property(srna, prop);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
||||
prop= RNA_def_property(srna, "is_movie_format", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_funcs(prop, "rna_RenderSettings_is_movie_fomat_get", NULL);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Movie Format", "When true the format is a movie");
|
||||
|
||||
prop= RNA_def_property(srna, "free_image_textures", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FREE_IMAGE);
|
||||
RNA_def_property_ui_text(prop, "Free Image Textures", "Free all image texture from memory after render, to save memory before compositing");
|
||||
|
@ -2564,6 +2564,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
|
||||
{2, "DJV", 0, "Djv", "Open source frame player: http://djv.sourceforge.net"},
|
||||
{3, "FRAMECYCLER", 0, "FrameCycler", "Frame player from IRIDAS"},
|
||||
{4, "RV", 0, "rv", "Frame player from Tweak Software"},
|
||||
{5, "MPLAYER", 0, "MPlayer", "Media player for video & png/jpeg/sgi image sequences"},
|
||||
{50, "CUSTOM", 0, "Custom", "Custom animation player executable path"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user