{"id":1254,"date":"2018-02-23T22:59:03","date_gmt":"2018-02-23T21:59:03","guid":{"rendered":"http:\/\/yarogniew.net\/arduino\/?page_id=1254"},"modified":"2018-02-25T22:00:37","modified_gmt":"2018-02-25T21:00:37","slug":"processing-video","status":"publish","type":"page","link":"https:\/\/arduino.net.pl\/index.php\/processing\/processing-video\/","title":{"rendered":"Processing &#8211; video"},"content":{"rendered":"<p>\u22a5 \u0179r\u00f3d\u0142o:\u00a0<a href=\"https:\/\/processing.org\/tutorials\/video\/\">Video, Daniel Shiffman<\/a><\/p>\n<p><strong>VIDEO_TEST1<\/strong> &#8211; \u00a0odtwarzamy film w formacie &#8222;mov&#8221;<br \/>\nImportujemy bibliotek\u0119:\u00a0<em>Video <\/em>Autor:<em>\u00a0The Processing Foundation<\/em><br \/>\nPrzeci\u0105gamy i upuszczamy plik &#8222;testowy.mov&#8221; na okno programu, dzi\u0119ki czemu trafi on do foldera &#8222;data&#8221; w katalogu szkicu.<\/p>\n<pre class=\"brush: plain; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\r\n\/\/VIDEO_TEST1\r\n\r\nimport processing.video.*; \r\n\r\n\/\/ Step 1. Declare a Movie object.\r\nMovie movie; \r\n\r\nvoid setup() {  \r\n  size(500,500);  \r\n\r\n  \/\/ Step 2. Initialize Movie object. The file &quot;testowy.mov&quot; should live in the data folder.\r\n  movie = new Movie(this, &quot;testowy.mov&quot;);  \r\n \r\n\r\n  \/\/ Step 3. Start playing movie. To play just once play() can be used instead.\r\n  movie.loop();\r\n}\r\n\r\n\/\/ Step 4. Read new frames from the movie.\r\nvoid movieEvent(Movie movie) {  \r\n  movie.read();\r\n}\r\n\r\n\/\/ Step 5. Display movie.\r\nvoid draw() {\r\n  image(movie, 10, 10);\r\n}\r\n\r\n<\/pre>\n<p><strong>VIDEO_TEST2<\/strong> &#8211; \u00a0dodajemy nieco chaosu<\/p>\n<pre class=\"brush: plain; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\r\n\/\/ VIDEO_TEST2\r\n\r\nimport processing.video.*;\r\n\r\nMovie movie;\r\n\r\nvoid setup() {\r\n  size(500, 500);  \r\n  background(255);  \r\n  movie = new Movie(this, &quot;testowy.mov&quot;);\r\n  println(movie.duration());\r\n  movie.loop();\r\n}\r\n\r\nvoid movieEvent(Movie movie) {  \r\n  movie.read();\r\n}\r\n\r\nvoid draw() {  \r\n  \/\/ Ratio of mouse X over width\r\n  float ratio = random(0.05,0.95); \/\/ przypadek zmienia punkt odtwarzania filmu\r\n  println(ratio);\r\n\r\n  if(random(0,1)&lt;0.1) \/\/ zmniejszam cz\u0119stotliwo\u015b\u0107 zmian\r\n    {\r\n    movie.jump(ratio * movie.duration()); \r\n    } \r\n  \r\n  image(movie, 10, 10);\r\n\r\n}\r\n<\/pre>\n<p><strong>VIDEO_TEST3<\/strong> &#8211; \u00a0po naci\u015bni\u0119ciu myszki odtwarzamy losowo fragmenty filmu dodatkowo zmieniaj\u0105c tempo odtwarzania.<\/p>\n<pre class=\"brush: plain; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\r\n\/\/ VIDEO_TEST3\r\n\r\nimport processing.video.*;\r\nMovie myMovie;\r\n\r\nfloat tempo=random(0.125,1.0);\r\nfloat xtime=0.0;\r\n\r\nvoid setup() {\r\n  size(500, 500);  \r\n  background(255); \r\n  frameRate(30);\r\n\r\n\r\n  myMovie = new Movie(this, &quot;testowy.mov&quot;);\r\n  myMovie.speed(0.25);\r\n  myMovie.loop();\r\n\r\n}\r\n\r\nvoid draw() {\r\n  if (myMovie.available()) {\r\n    myMovie.read();\r\n    xtime=random(myMovie.duration());\r\ntempo=random(0.125,1.0);\r\n  }\r\n  image(myMovie, 10, 10);\r\n}\r\n\r\nvoid mousePressed() {\r\n\r\n  myMovie.speed(tempo);\r\n  myMovie.jump(xtime);\r\n}\r\n\r\n<\/pre>\n<p><strong>VIDEO_TEST4<\/strong> &#8211; doda\u0142em pasek, kt\u00f3ry pokazuje w kt\u00f3rym momencie filmu jeste\u015bmy<\/p>\n<pre class=\"brush: plain; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\r\n\/\/VIDEO_TEST4\r\n\r\nimport processing.video.*;\r\nMovie myMovie;\r\n\r\nvoid setup() {\r\n  size(480, 480);\r\n  frameRate(30);\r\n  myMovie = new Movie(this, &quot;testowy.mov&quot;);\r\n  myMovie.play();\r\n}\r\n\r\nvoid draw() {\r\n  \/\/background(255);\r\n  if (myMovie.available()) {\r\n    myMovie.read();\r\n  }\r\n  image(myMovie, 0, 0);\r\n  \/\/ Draws a line on the screen\r\n  \/\/ when the movie half-finished\r\n  float md = myMovie.duration();\r\n  float mt = myMovie.time();\r\n  float x = mt*width\/md;\r\n  \r\n  strokeCap(SQUARE);\r\n  strokeWeight(10);  \/\/ Thicker\r\n  stroke(255);\r\n  line(0, height-6, x, height-6);\r\n  \r\n}<\/pre>\n<h5>MATERIA\u0141Y DODATKOWE<\/h5>\n<p>Biblioteka pozwalaj\u0105ca eksportowa\u0107 rezultaty naszych dzia\u0142a\u0144 jako plik wideo (nie sprawdzi\u0142em jeszcze):<br \/>\n<a href=\"https:\/\/github.com\/hamoid\/video_export_processing\">hamoid\/video_export_processing<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u22a5 \u0179r\u00f3d\u0142o:\u00a0Video, Daniel Shiffman VIDEO_TEST1 &#8211; \u00a0odtwarzamy film w formacie &#8222;mov&#8221; Importujemy bibliotek\u0119:\u00a0Video Autor:\u00a0The Processing Foundation Przeci\u0105gamy i upuszczamy plik &#8222;testowy.mov&#8221; na okno programu, dzi\u0119ki czemu trafi on do foldera&#8230;<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":1256,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-1254","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages\/1254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/comments?post=1254"}],"version-history":[{"count":12,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages\/1254\/revisions"}],"predecessor-version":[{"id":1259,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages\/1254\/revisions\/1259"}],"up":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages\/1256"}],"wp:attachment":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/media?parent=1254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}