{"id":936,"date":"2012-04-06T21:47:27","date_gmt":"2012-04-06T13:47:27","guid":{"rendered":"http:\/\/www.magicandlove.com\/blog\/?p=936"},"modified":"2012-04-06T22:54:34","modified_gmt":"2012-04-06T14:54:34","slug":"video-playback-performance-processing","status":"publish","type":"post","link":"http:\/\/www.magicandlove.com\/blog\/2012\/04\/06\/video-playback-performance-processing\/","title":{"rendered":"Video Playback Performance &#8211; Processing"},"content":{"rendered":"<p>I try out different video playback mechanism in the <a href=\"http:\/\/www.processing.org\">Processing<\/a> to compare their performance. The digital video is the one I used in the last post. It is the <a href=\"http:\/\/www.youtube.com\/watch?v=ENCvYCRkepY\">trailer of the film Hugo<\/a>. The details are: 1280 x 692 H.264 AAC, bitrate 2,093.<\/p>\n<p>The computer I am using is iMac 3.06 GHz Intel Core 2 Duo, 4 GB RAM, ATI Radeon HD 4670 256 MB graphic card. Processing is the latest 1.5.1 version.<\/p>\n<p>For the video playback classes, I tested the default <a href=\"http:\/\/processing.org\/reference\/libraries\/video\/index.html\">QuickTime Video<\/a> library, a <a href=\"http:\/\/danieloberhoff.de\/processing\/FasterMovie.pde\">FasterMovie<\/a> class, the <a href=\"http:\/\/gsvideo.sourceforge.net\/\">GSVideo<\/a> library, and the <a href=\"http:\/\/www.mat.ucsb.edu\/~a.forbes\/PROCESSING\/jmcvideo\/jmcvideo.html\">JMCVideo<\/a> library with JavaFX 1.2 SDK.<\/p>\n<p>To render the video, I start with the standard <a href=\"http:\/\/processing.org\/reference\/image_.html\">image()<\/a> function, and proceed to test with various OpenGL texturing methods, including the <a href=\"http:\/\/glgraphics.sourceforge.net\/\">GLGraphics<\/a> library.<\/p>\n<p>Again, I sample the CPU and Memory usage with the Activity Monitor from the Mac OSX utilities, in an interval of 30 seconds. The results are the average of 5 samples.<\/p>\n<p><strong>Performance with 2D image function<\/strong><\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\n<tbody>\n<tr>\n<td><\/td>\n<td>CPU (%)<\/td>\n<td>Memory (Mb)<\/td>\n<\/tr>\n<tr>\n<td>QuickTime<\/td>\n<td>175<\/td>\n<td>221<\/td>\n<\/tr>\n<tr>\n<td>FasterMovie<\/td>\n<td>137<\/td>\n<td>275<\/td>\n<\/tr>\n<tr>\n<td>GSVideo<\/td>\n<td>151<\/td>\n<td>118<\/td>\n<\/tr>\n<tr>\n<td>JMCVideo<\/td>\n<td>147<\/td>\n<td>87<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The OpenGL and QuickTime video libraries have problem working together. The program stops at the size() statement. I have to either put the first video related command before the size() or a dummy line<\/p>\n<pre lang=\"java\">\r\nprintln(Capture.list());\r\nsize(1280, 692, OPENGL);\r\n<\/pre>\n<p>The second batch of tests use the standard OpenGL vertex and texture functions.<\/p>\n<p><strong>Performance with OpenGL texture and vertex functions<\/strong><\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\n<tbody>\n<tr>\n<td><\/td>\n<td>CPU (%)<\/td>\n<td>Memory (Mb)<\/td>\n<\/tr>\n<tr>\n<td>QuickTime<\/td>\n<td>158<\/td>\n<td>430<\/td>\n<\/tr>\n<tr>\n<td>FasterMovie<\/td>\n<td>143<\/td>\n<td>610<\/td>\n<\/tr>\n<tr>\n<td>GSVideo<\/td>\n<td>147<\/td>\n<td>315<\/td>\n<\/tr>\n<tr>\n<td>JMCVideo<\/td>\n<td>142<\/td>\n<td>397<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The third batch of tests involve custom arrangement in OpenGL. Both GSVideo and JMCVideo come with their own functions to write directly to OpenGL texture. For the FasterMovie test, I combine it with the pixel buffer object I have shown in my <a href=\"http:\/\/www.magicandlove.com\/blog\/2012\/03\/26\/pixel-buffer-object-in-processing\/\">previous post<\/a>.<br \/>\n&nbsp;<br \/>\n<strong>Performance with custom OpenGL texture method<\/strong><\/p>\n<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\">\n<tr>\n<td>&nbsp;<\/td>\n<td>CPU (%)<\/td>\n<td>Memory (Mb)<\/td>\n<\/tr>\n<tr>\n<td>FasterMovie+PBO<\/td>\n<td>69<\/td>\n<td>275<\/td>\n<\/tr>\n<tr>\n<td>GSVideo+GLGraphics<\/td>\n<td>58<\/td>\n<td>120<\/td>\n<\/tr>\n<tr>\n<td>JMCVideo+OpenGL<\/td>\n<td>57<\/td>\n<td>91<\/td>\n<\/tr>\n<\/table>\n<p>&nbsp;<br \/>\nSample code for GSVideo and GLGraphics (from <a href=\"http:\/\/codeanticode.wordpress.com\/\">codeanticode<\/a>)<\/p>\n<pre lang=\"java\">\r\nimport processing.opengl.*;\r\nimport codeanticode.glgraphics.*;\r\nimport codeanticode.gsvideo.*;\r\n\r\nGSMovie mov;\r\nGLTexture tex;\r\n\r\nvoid setup() \r\n{\r\n  size(1280, 692, GLConstants.GLGRAPHICS);\r\n  background(0);   \r\n  mov = new GSMovie(this, \"Hugo.mp4\");\r\n  tex = new GLTexture(this);\r\n  mov.setPixelDest(tex);  \r\n  mov.loop();\r\n}\r\n\r\nvoid draw() \r\n{\r\n  if (tex.putPixelsIntoTexture()) \r\n  {\r\n    image(tex, 0, 0);\r\n  }\r\n}\r\n\r\nvoid movieEvent(GSMovie _m) {\r\n  _m.read();\r\n}\r\n<\/pre>\n<p>&nbsp;<br \/>\nSample code for JMCVideo (from <a href=\"http:\/\/www.mat.ucsb.edu\/a.forbes\/blog\/\">Angus Forbes<\/a>)<\/p>\n<pre lang=\"java\">\r\nimport jmcvideo.*;\r\nimport processing.opengl.*;\r\nimport javax.media.opengl.*; \r\n\r\nJMCMovieGL mov;\r\nPGraphicsOpenGL pgl;\r\n\r\nvoid setup() \r\n{\r\n  size(1280, 692, OPENGL);\r\n  background(0);\r\n  mov = new JMCMovieGL(this, \"Hugo.mp4\", ARGB);\r\n  mov.loop();\r\n  \r\n  pgl = (PGraphicsOpenGL) g;\r\n  GL gl = pgl.beginGL();  \r\n  gl.glViewport(0, 0, width, height);\r\n  pgl.endGL();\r\n}\r\n\r\nvoid draw() \r\n{\r\n  GL gl = pgl.beginGL();  \r\n  mov.image(gl, 0, 0, width, height);\r\n  pgl.endGL();\r\n}  \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I try out different video playback mechanism in the Processing to compare their performance. The digital video is the one I used in the last post. It is the trailer of the film Hugo. The details are: 1280 x 692 H.264 AAC, bitrate 2,093. The computer I am using is iMac 3.06 GHz Intel Core [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[62,101],"class_list":["post-936","post","type-post","status-publish","format-standard","hentry","category-testing","tag-processing-org","tag-video-playback"],"_links":{"self":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/comments?post=936"}],"version-history":[{"count":15,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/936\/revisions"}],"predecessor-version":[{"id":951,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/936\/revisions\/951"}],"wp:attachment":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/media?parent=936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/categories?post=936"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/tags?post=936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}