- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我第一次从Processing OSX 移植GLSL 着色器以在Raspberry Pi 3 B+ 上运行的Processing Pi 上运行。我有一个非常基本的着色器,可以在两个视频播放之间溶解。它在我的 Mac 上运行得很好,但当它移植到 Processing Pi 并更新为使用处理视频库 GLvideo 时,它会抛出错误。
该着色器最初是从 ShaderToy 帖子转换而来的,但我将其重新编写为直接 GLSL,以确保不存在任何兼容性问题。我环顾四周,找不到任何我认为会导致此问题的具体内容。因此,任何引用、指示或帮助将不胜感激。
我尝试了其他一些方法,我将视频大小调整得更小,将 Pi 的 GPU 内存更新为 256mb 等。我确保它仍然可以在 OSX 上运行,但是当它在 Raspberry Pi 3B+ 上运行时,草图是一个空的白色屏幕。
我想也许 Pi 处理 GLSL 的方式有所不同?或者 Pi GPU 中的sampler2D 纹理是否有限制?更重要的是在处理方面,它跨越了我的也许不支持在处理 pi 的着色器中将 PGraphics 从Processing 设置为sampler2D 纹理?当你设置texture3D时,也许GLVideo图像有问题。另外,也许是我混淆了碎片和颜色着色器的工作方式。目前我认为我正在使用处理颜色着色器。
控制台中唯一的输出是:
Final caps: video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)640, height=(int)360, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)25/1, texture-target=(string)2D
Final caps: video/x-raw(memory:GLMemory), format=(string)RGBA, width=(int)640, height=(int)360, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)25/1, texture-target=(string)2D
shaderDisolveGLSL.pde
//import processing.video.*;
import gohai.glvideo.*;
PShader mixShader;
PGraphics pg;
PGraphics pg2;
//Movie movie;
//Movie movie2;
GLMovie movie;
GLMovie movie2;
void setup() {
size(640, 360, P2D);
noSmooth();
pg = createGraphics(640, 360, P2D);
//movie = new Movie(this, "_sm/LabspaceDawnv1blur2.mp4");
movie = new GLMovie(this, "_sm/LabspaceDawnv1blur2.mp4");
movie.loop();
//movie2 = new Movie(this, "_sm/LabspaceFireblur2.mp4");
movie2 = new GLMovie(this, "_sm/LabspaceFireblur2.mp4");
movie2.loop();
pg = createGraphics(width, height, P2D);
pg2 = createGraphics(width, height, P2D);
mixShader = loadShader("fadeshader.glsl");
mixShader.set("iResolution", float(width), float(height));
mixShader.set("iTime", millis()/1000.);
mixShader.set("iChannel0", pg);
mixShader.set("iChannel1", pg2);
}
//void movieEvent(Movie m) {
void movieEvent(GLMovie m) {
m.read();
redraw();
}
void draw() {
pg.beginDraw();
pg.image(movie, 0, 0, width, height);
pg.endDraw();
pg2.beginDraw();
pg2.image(movie2, 0, 0, width, height);
pg2.endDraw();
shader(mixShader);
rect(0, 0, width, height);
}
fadeshader.glsl
// Type of shader expected by Processing
#define PROCESSING_COLOR_SHADER
uniform float iTime;
uniform sampler2D iChannel0;
uniform sampler2D iChannel1;
uniform vec2 iResolution;
void main() {
vec2 uv = gl_FragCoord.xy / iResolution.xy;
vec4 mixColor = vec4(0.0);
vec4 color0 = vec4(uv.x,uv.y,0.0,1.0);
vec4 color1 = vec4(uv.x,uv.y,0.0,1.0);
color0 = texture2D(iChannel0, uv);
color1 = texture2D(iChannel1, uv);
float duration = 10.0;
float t = mod(float(iTime), duration) / duration;
mixColor = mix(color0, color1, t);
gl_FragColor = mixColor;
}
如果有人好奇的话,我已经用较小的视频更新了示例草图的新版本:https://www.dropbox.com/sh/fu2plxmqhf7shtp/AADxqmW9zf73EsdzworCb5ECa?dl=0
任何关于可能出现的情况或从哪里开始调试更多内容的建议或想法将不胜感激。
谢谢!
最佳答案
我不是 100% 确定,但错误可能与视频编码以及 GLVideo 库可以在 Raspberry PI 上解码的内容(依赖于 gstreamer)有关
我已经在旧系统上的 OSX 上遇到了错误:草图在灰色屏幕上卡住了几秒钟,然后崩溃,没有任何警告或错误。
我建议重新编码视频,如果不需要则删除音频 channel ,并使用与处理传输视频相同或相似的 H.264 编码器(例如示例 > 库 > 视频 > 电影 > 循环)
ffprobe -i /Users/George/Desktop/shaderDisolveGLSL/data/_sm/LabspaceDawn\ v1\ blur\ 2.mp4
ffprobe version 3.3.3 Copyright (c) 2007-2017 the FFmpeg developers
built with Apple LLVM version 7.0.0 (clang-700.0.72)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/George/Desktop/shaderDisolveGLSL/data/_sm/LabspaceDawn v1 blur 2.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2020-03-15T14:03:48.000000Z
Duration: 00:00:49.09, start: 0.000000, bitrate: 218 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/bt709), 640x360 [SAR 1:1 DAR 16:9], 119 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
creation_time : 2020-03-15T14:03:48.000000Z
handler_name : ISO Media file produced by Google Inc. Created on: 03/15/2020.
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s (default)
Metadata:
creation_time : 2020-03-15T14:03:48.000000Z
handler_name : ISO Media file produced by Google Inc. Created on: 03/15/2020.
公交视频详情:
ffprobe -i /Users/George/Desktop/shaderDisolveGLSL/data/transit.mov
ffprobe version 3.3.3 Copyright (c) 2007-2017 the FFmpeg developers
built with Apple LLVM version 7.0.0 (clang-700.0.72)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/George/Desktop/shaderDisolveGLSL/data/transit.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2012-08-31T20:17:39.000000Z
Duration: 00:00:12.38, start: 0.000000, bitrate: 731 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 640x360, 727 kb/s, 29.97 fps, 29.97 tbr, 600 tbn, 1200 tbc (default)
Metadata:
creation_time : 2012-08-31T20:17:44.000000Z
handler_name : Apple Alias Data Handler
encoder : H.264
什么似乎有效:
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 640x360, 727 kb/s, 29.97 fps, 29.97 tbr, 600 tbn, 1200 tbc (default)
什么似乎崩溃了:
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/bt709), 640x360 [SAR 1:1 DAR 16:9], 119 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
在使用 movieEvent
时,我遇到了一些其他间歇性 JOGL 错误:在 draw()
中偷偷调用 .read()
似乎解决问题。
这是我在 OSX 上运行的代码的调整版本:
import processing.video.*;
//import gohai.glvideo.*;
PShader mixShader;
PGraphics pg;
PGraphics pg2;
Movie movie;
Movie movie2;
//GLMovie movie;
//GLMovie movie2;
void setup() {
size(640, 360, P2D);
noSmooth();
noStroke();
//movie = new Movie(this, "_sm/LabspaceDawnv1blur2.mp4");
movie = new Movie(this, "transit.mov");
//movie = new GLMovie(this, "_sm/LabspaceDawnv1blur2.mp4");
movie.loop();
//movie2 = new Movie(this, "_sm/LabspaceFireblur2.mp4");
movie2 = new Movie(this, "transit2.mov");
//movie2 = new GLMovie(this, "_sm/LabspaceFireblur2.mp4");
movie2.loop();
pg = createGraphics(width, height, P2D);
pg2 = createGraphics(width, height, P2D);
mixShader = loadShader("fadeshader.glsl");
mixShader.set("iResolution", float(width), float(height));
mixShader.set("iChannel0", pg);
mixShader.set("iChannel1", pg2);
}
//void movieEvent(Movie m) {
//void movieEvent(GLMovie m) {
//m.read();
//redraw();
//}
void draw() {
if(movie.available()){ movie.read(); }
if(movie2.available()){ movie2.read(); }
pg.beginDraw();
// for testing only since both movies are the same
movie.filter(GRAY);
pg.image(movie, 0, 0, width, height);
pg.endDraw();
pg2.beginDraw();
pg2.image(movie2, 0, 0, width, height);
pg2.endDraw();
// don't forget to update time
mixShader.set("iTime", millis() * 0.01);
shader(mixShader);
rect(0, 0, width, height);
}
希望这可以与 Raspberry Pi 上的 Transit mov 配合使用来测试编解码器。一旦顺利运行,请重新编码您的视频(Handbreak 可能会有所帮助),然后重试。
@jshaw3 我进行了更改以在 RPI3 上进行测试。 GLVideo 似乎有问题。如果您不需要音频,您也许可以使用图像序列:Image Sequence Player可以让这变得更容易。请记住,这应该在不到 5 秒的时间内初始化,以避免 P3D/GL 端超时(否则推迟加载到第一帧):
import com.hirschandmann.image.*;
PShader mixShader;
PGraphics pg;
PGraphics pg2;
ISPlayer movie1;
ISPlayer movie2;
boolean loadTriggered = false;
void setup() {
size(640, 360, P2D);
noSmooth();
pg = createGraphics(640, 360, P2D);
pg = createGraphics(width, height, P2D);
pg2 = createGraphics(width, height, P2D);
mixShader = loadShader("fadeshader.glsl");
mixShader.set("iResolution", float(width), float(height));
mixShader.set("iTime", millis()/1000.);
mixShader.set("iChannel0", pg);
mixShader.set("iChannel1", pg2);
}
void draw() {
if(!loadTriggered){
movie1 = new ISPlayer(this,dataPath("_sm/LabspaceDawnv1blur2Frames"));
movie1.loop();
movie2 = new ISPlayer(this,dataPath("_sm/LabspaceFireblur2Frames"));
movie2.loop();
loadTriggered = true;
}
pg.beginDraw();
if(movie1 != null) pg.image(movie1, 0, 0, width, height);
pg.endDraw();
pg2.beginDraw();
if(movie2 != null) pg2.image(movie2, 0, 0, width, height);
pg2.endDraw();
shader(mixShader);
rect(0, 0, width, height);
}
注意以上假设您已将 .mp4 文件转换为图像序列(例如 LabspaceDawnv1blur2.mp4
-> LabspaceDawnv1blur2Frames
)。这是一个 ffmepg 示例:
ffmpeg -i LabspaceDawnv1blur2.mp4.mp4 -vf fps=1/60 LabspaceDawnv1blur2.mp4Frames/frame_%04d.png
关于java - 在 Pi 3 B+ 上使用 Processing Pi 的 GLSL 着色器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60758549/
我有两种结构,Header 和Session,它们都符合协议(protocol)TimelineItem。 我有一个 Array 由 TimelineItem 组成,如下所示: [Header1, S
这个问题在这里已经有了答案: Multiple assignment and evaluation order in Python (11 个答案) 关闭 6 年前。 我刚接触python所以想问你
我试图找到一种方法来在 R 中获取 A、A、A、A、B、B、B、B、B 的所有可能的唯一排列的列表。 组合最初被认为是获得解决方案的方法,因此组合的答案。 最佳答案 我认为这就是你所追求的。 @bil
我怎样才能将两个给定的向量混合成一个新的向量,它以交替的顺序保存它们的值。 (f [a a] [b b]) ; > [a b a b] 这是我想到的: (flatten (map vector [:a
这是我的第一个问题,我开始学习Python。之间有区别吗: a, b = b, a + b 和 a = b b = a + b 当您在下面的示例中编写它时,它会显示不同的结果。 def fib(n):
这个问题在这里已经有了答案: Why is there an injected class name? (1 个回答) 12 个月前关闭。 我不知道如何解释: namespace A { struct
我尝试了一些代码来交换 Java 中的两个整数,而不使用第三个变量,使用 XOR。 这是我尝试过的两个交换函数: package lang.numeric; public class SwapVars
假设类 B 扩展类 A,并且我想为 B 声明一个变量。什么更有效?为什么? B b或 A b . 最佳答案 您混淆了两个不同的概念。 class B extends A { } 意味着B 是 A .
我不确定这个问题的标题是什么,这也可能是一个重复的问题。所以请相应地指导。 我是 python 编程的新手。我有这个简单的代码来生成斐波那契数列。 1: def fibo(n): 2: a =
我在谷歌上搜索了有关 dynamic_cast 的内容,我发现显式地将基类对象转换为派生类指针可能是不安全的。但是当我运行一些示例代码来检查它时,我没有收到任何错误。请在下面找到我的代码: class
这个问题在这里已经有了答案: What is this weird colon-member (" : ") syntax in the constructor? (14 个答案) 关闭 8 年前。
在不重现产生非整数值的表达式的情况下实现以下目标的惯用方法是什么(在我的真实情况下,该值是在我不想重现的冗长查询之后计算为百分比的): SELECT * FROM SomeTable WHERE 1/
在析构中,这两个代码的结果确实不同。我不确定为什么。 提示说 const [b,a] = [a,b] 将导致 a,b 的值为 undefined (从左到右的简单分配规则)。我不明白为什么会这样。 l
C++ Templates - The Complete Guide, 2nd Edition介绍max模板: template T max (T a, T b) { // if b < a th
我最近开始学习代码(Java),并根据第 15.17.3 节在 Oracle 网站上查找了模运算符。以下链接: http://docs.oracle.com/javase/specs/jls/se8/
无法理解以下行为。 d1 := &data{1}; 的区别d1 和 d2 := 数据{1}; &d1。两者都是指针,对吧?但他们的行为不同。这里发生了什么 package main import "f
这个问题在这里已经有了答案: How to make loop infinite with "x = y && x != y"? (4 个回答) How can i define variables
在我的程序中,当我调试我的代码时,它似乎在我生成的代码中的某处 X1=['[a,a,a]','[b,b,b]'] 还有我生成的其他地方 X2=[[a,a,a],[b,b,b]] 当我想添加这两个列表然
我试图使用递归将两个整数相乘,并意外编写了这段代码: //the original version int multiply(int a, int b) { if ( !b ) retu
我有一个列表中数字之间所有可能的操作组合: list = ['2','7','8'] 7+8*2 8+7*2 2*8+7 2+8*7 2-8*7 8-2/7 etc 我想知道是否可以说像 ('7*2+
我是一名优秀的程序员,十分优秀!