mplayer preset, plays back movies and image sequences.

added scene.render.is_movie_format
This commit is contained in:
Campbell Barton
2010-03-07 02:04:30 +00:00
parent c3c16603d2
commit c052a5bc36
3 changed files with 50 additions and 10 deletions

View File

@@ -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)