Re: [PyMOL] pymol 3D movies

2014-09-08 Thread Christoph Parthier
Hi,

...a more simplicistic approch to generate side-by-side stereo PNG files 
from an animation in PyMOL would be to activate wall-eye stereo in PyMOL 
(stereo walleye) and double the x dimension of your graphics windows 
(viewport command). Then use the 'Save Movie as... PNG' command (mpng...).

Of course image size (x,y pixels) will be limited to screen 
resolution/viewport size. If you need higher resolution than your screen 
(e.g. full HD in side-by-side 3D) then I recommend putting the commands 
into a pml-script in which you also set your desired image size (e.g. 
viewport 3840,1080), and which you can run in the GUI-less PyMOL mode 
(pymol -qc your_script.pml).

As mentioned here already, after merging the PNGs into a side-by-side 
stereo movie (using e.g. Virtualdub, ffmpeg) you need a movie player 
which supports side-by-side stereo movies and is able to output to 
quad-buffered 3D displays (free: Bino, commercial: Stereoscopic Player, 
there may be more...).

Christoph

(just saw this thread now, sorry if it's not adding anything useful...)



On 08/26/2014 10:02 PM, Marcelo Marcet wrote:
> Hi Christian,
>
> Thanks so much for your email. I am looking forward to testing your approach 
> and scripts soon. Again, thanks for the detailed explanations and the scripts.
>
> Best regards,
> Marcelo
>
> On Aug 25, 2014, at 6:02 PM, Christian Becke  
> wrote:
>
>> 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 , , , [start=1], [end=-1]
>> render stereoscopic frames sized  x  pixels.
>> Files will be named _%04d.png.
>> Render frames  to  (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 mov

Re: [PyMOL] pymol 3D movies

2014-08-26 Thread Marcelo Marcet
Hi Christian,

Thanks so much for your email. I am looking forward to testing your approach 
and scripts soon. Again, thanks for the detailed explanations and the scripts. 

Best regards,
Marcelo

On Aug 25, 2014, at 6:02 PM, Christian Becke  
wrote:

> 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 , , , [start=1], [end=-1]
> render stereoscopic frames sized  x  pixels.
> Files will be named _%04d.png.
> Render frames  to  (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
> --
> 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.co

Re: [PyMOL] pymol 3D movies

2014-08-25 Thread Christian Becke

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 , , , [start=1], [end=-1]
render stereoscopic frames sized  x  pixels.
Files will be named _%04d.png.
Render frames  to  (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 
# DATE: 2013-12-15

from pymol import cmd

def mpng_3d (pfx, width, height, start=1, end=-1):
	"""mpng_3d , , , [start=1], [end=-1]
render stereoscopic frames sized  x  pixels.
Files will be named _%04d.png.
Render frames  to  (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, outfr

Re: [PyMOL] pymol 3D movies

2014-08-25 Thread Marcelo Marcet
Hi Christian,

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. 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?

Thanks so much,
Marcelo


On Aug 25, 2014, at 10:38 AM, Christian Becke 
mailto:christian.be...@fu-berlin.de>> wrote:

Hi Xevi,

I have prepared side-by-side 3D movies that I could play on a 3D TV using pymol 
and ffmpeg. I ray-traced the movie, one frame for each eye, and used ffmpeg to 
compile the resulting png files to an h264 movie file. With side-by-side 
stereo, you of course lose resolution, but ffmpeg can also do 
alternating-frames stereo with no loss in resolution. If you find a movie 
player that renders such a movie using your quad-buffer capable hardware, you 
should be all set. Let me know if you want to try this, I would be happy to 
share my scripts.

Christian


Am Montag, den 25.08.2014, 09:35 -0400 schrieb Xavier Fradera:

Hi,

I am looking into making a quad-buffered stereo 3D movie. Is this possible with 
mpeg or any other format ? I know I could just play the movie from pymol, but 
would like to be able to save as mpeg with x-ray traced images for higher 
quality.

Xevi

--
Xavier Fradera

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

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

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

Re: [PyMOL] pymol 3D movies

2014-08-25 Thread Christian Becke
Hi Xevi,

I have prepared side-by-side 3D movies that I could play on a 3D TV 
using pymol and ffmpeg. I ray-traced the movie, one frame for each 
eye, and used ffmpeg to compile the resulting png files to an h264 
movie file. With side-by-side stereo, you of course lose resolution, 
but ffmpeg can also do alternating-frames stereo with no loss in 
resolution. If you find a movie player that renders such a movie using 
your quad-buffer capable hardware, you should be all set. Let me know 
if you want to try this, I would be happy to share my scripts.

Christian

Am Montag, den 25.08.2014, 09:35 -0400 schrieb Xavier Fradera:
> Hi,
>  
> I am looking into making a quad-buffered stereo 3D movie. Is this 

> possible with mpeg or any other format ? I know I could just play 

> the movie from pymol, but would like to be able to save as mpeg with 

> x-ray traced images for higher quality.
>  
> Xevi
>  
> --
> Xavier Fradera
> --

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

[PyMOL] pymol 3D movies

2014-08-25 Thread Xavier Fradera
Hi,

I am looking into making a quad-buffered stereo 3D movie. Is this possible
with mpeg or any other format ? I know I could just play the movie from
pymol, but would like to be able to save as mpeg with x-ray traced images
for higher quality.

Xevi

-- 
Xavier Fradera
--
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