Hi,
Am 25.08.2014 21:44, schrieb Marcelo Marcet:
Thank you for taking the time to reply to this question and for
offering your help. I am also interested in quad-buffered stereo play
back.
Sorry, maybe I wasn't clear in my first mail: I don't have experience
with quad-buffered stereo playback. All I have done is preparing 3D
stereo movie files using PyMOL and ffmpeg[1] which I can play on a 3D TV
(using a side-by-side stereo movie file and polarization glasses) or on
a regular beamer (anaglyph red/cyan movie with red/cyan glasses).
I expect that one could play these (or similarly prepared) movie files
with a movie player that makes use of OpenGL quad-buffered 3D
capabilities of a graphics card - but I never tried this myself.
AFAIU, there is no such thing as a quad-buffered movie file - it's just
the movie player that plays back a 3D stereo movie file using OpenGL
quad-buffered stereo on hardware that supports it. A player that might
work is bino[2], but, as I said, I never got around to try it out.
Would you be able to provide us with a bit more methodology information?
It sounds like you have a script that helps you save the side-by-side
images and later you use a software called ffmpeg to render the movie.
Is this correct?
Yes, this is correct. Here is how I did it:
1) Prepare a movie in PyMOL
2) run the attached python script ("run /path/to/mpng_3d.sh"). This will
add a new command to pymol: mpng_3d
It works similar to the mpng command, but saves 2 images for each movie
frame, one for the left and one for the right eye. If ray traced frames
are desired, do "set ray_trace_frames, 1". You can also play around with
the stereo_angle setting (e.g. "set stereo_angle, 3"). This defines the
difference in viewing angle of the images for the left and right eye.
The mpng_3d command takes the following options:
mpng_3d <prefix>, <width>, <height>, [start=1], [end=-1]
render stereoscopic frames sized <width> x <height> pixels.
Files will be named <prefix>_%04d.png.
Render frames <start> to <end> (default: all frames)
Example: "mpng_3d my_movie, 1920, 1080" will write png files called
my_movie_0001.png, my_movie_0002.png, ...
If ray_trace_frames is set (recommended), the images will be ray traced
and have a size of 1920x1080 pixels (i.e. full HD).
3) Use ffmpeg to encode a movie from the individual frames saved with
mpng_3d:
For h.264 encoding:
ffmpeg -i "my_movie_%04d.png" \
-an \
-r 30 -aspect 1.78 -pix_fmt yuv420p \
-c:v libx264 -tune animation \
-vf stereo3d=al:sbsl \
-profile:v baseline -level 3.0 -refs 4 -qmin 4 \
"my_movie.mp4"
For WMV encoding:
ffmpeg -i "my_movie_%04d.png" \
-an \
-r 30 -aspect ${aspect} \
-vf stereo3d=al:sbsl \
-q:v 2 -c:v msmpeg4v3 \
"my_movie.wmv"
These are the commands I used on linux. Similar ffmpeg commands should
also work on Windows or OS X. Video quality and file size were
reasonable with the above settings, and the files played all right on
almost all video players I tested (the wmv files work with all versions
of PowerPoint I tested, the h.264 movies do not work with WinXP).
If you change the size of the images, also change the -aspect parameter
in the ffmpeg commands accordingly (for 1920x1080 pixel images:
aspect=1920/1080=1.78).
The above commands produce side-by-side stereo movies, i.e. the images
for the left and right eye are shown next to each other in each frame
of the movie. Check the ffmpeg docs[3] for other output options.
For some movie players (e.g. the one on my LG 3D TV) it might be
necessary to scale the pymol-rendered frames to half-width before
encoding them to a side-by-side stereo movie with ffmpeg. This can be
done e.g. with the "convert" command from the imagmagick[4] suite.
I hope this helps!
Christian
[1] http://ffmpeg.org
[2] http://bino3d.org
[3] http://ffmpeg.org/ffmpeg-filters.html#stereo3d
[4] http://www.imagemagick.org
--
Christian Becke
Freie Universität Berlin
Fachbereich Biologie, Chemie, Pharmazie
Institut für Chemie und Biochemie
AG Strukturbiochemie
Takustr. 6
14195 Berlin
Germany
Phone: +49 (0)30 838-57344
Fax: +49 (0)30 838-56981
E-mail: christian.be...@fu-berlin.de
# vim: set fileencoding=utf8 ts=4 sw=4 noexpandtab :
# AUTHOR: Christian Becke <christian.be...@fu-berlin.de>
# DATE: 2013-12-15
from pymol import cmd
def mpng_3d (pfx, width, height, start=1, end=-1):
"""mpng_3d <prefix>, <width>, <height>, [start=1], [end=-1]
render stereoscopic frames sized <width> x <height> pixels.
Files will be named <prefix>_%04d.png.
Render frames <start> to <end> (default: all frames)"""
width = int (width)
height = int (height)
start = int (start)
end = int (end)
if end == -1:
end = cmd.count_frames ()
outframe = start
stereo_angle = cmd.get ('stereo_angle')
for frame in xrange (start, end + 1):
print "Rendering frame %d (%d of %d)" % (
frame, frame - start + 1, end - start + 1)
cmd.frame (frame)
# left frame
if cmd.get ("ray_trace_frames"):
cmd.ray (width, height, angle=stereo_angle, quiet=1)
cmd.png ("%s_%04d.png" % (pfx, outframe), quiet=1)
outframe += 1
# right frame
if cmd.get ("ray_trace_frames"):
cmd.ray (width, height, angle=-stereo_angle, quiet=1)
cmd.png ("%s_%04d.png" % (pfx, outframe), quiet=1)
outframe += 1
print "Rendering done."
print "Frames for the left eye have odd numbers,\nframes for the right eye even numbers."
print "use ffmpeg -vf stereo3d=al:... for encoding."
cmd.extend ("mpng_3d", mpng_3d)
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net