【问题标题】:Using Processing-3.2.2 from shell从 shell 使用 Processing-3.2.2
【发布时间】:2016-11-05 13:45:03
【问题描述】:

伙计们,我正在研究音频可视化,并在 pde 中制作了一个成功的运行文件。该代码采用“input.mp3”,然后导出 .mp4 文件。我们可以通过终端(.sh)使用它吗?我的意思是通过编写一些命令来执行程序。喜欢:

processing-3.2.2 filename.pde input.mp3

它会生成该 input.mp3 的视频。这是我的代码:

import ddf.minim.*;
import ddf.minim.analysis.*;
import com.hamoid.*;

Minim minim;
AudioPlayer player;
AudioMetaData meta;
BeatDetect beat;
VideoExport videoExport;
int  r = 200;
float rad = 70;
void setup()
{
  size(600, 600);
  //size(600, 400);
  minim = new Minim(this);
  player = minim.loadFile("son_final.mp3");
  meta = player.getMetaData();
  beat = new BeatDetect();
  videoExport = new VideoExport(this, "basic.mp4");
  player.loop();
  //player.play();
  background(-1);
  noCursor();
}

void draw()
{ 
  float t = map(mouseX, 0, width, 0, 1);
  beat.detect(player.mix);
  fill(#1A1F18, 20);
  noStroke();
  rect(0, 0, width, height);
  translate(width/2, height/2);
  noFill();
  fill(-1, 10);
  if (beat.isOnset()) rad = rad*0.9;
  else rad = 70;
  ellipse(0, 0, 2*rad, 2*rad);
  stroke(-1, 50);
  int bsize = player.bufferSize();
  for (int i = 0; i < bsize - 1; i+=5)
  {
    float x = (r)*cos(i*2*PI/bsize);
    float y = (r)*sin(i*2*PI/bsize);
    float x2 = (r + player.left.get(i)*100)*cos(i*2*PI/bsize);
    float y2 = (r + player.left.get(i)*100)*sin(i*2*PI/bsize);
    line(x, y, x2, y2);
  }
  beginShape();
  noFill();
  stroke(-1, 50);
  for (int i = 0; i < bsize; i+=30)
  {
    float x2 = (r + player.left.get(i)*100)*cos(i*2*PI/bsize);
    float y2 = (r + player.left.get(i)*100)*sin(i*2*PI/bsize);
    vertex(x2, y2);
    pushStyle();
    stroke(-1);
    strokeWeight(2);
    point(x2, y2);
    popStyle();
  }
  endShape();
   if (flag) showMeta();
   videoExport.saveFrame();
 }



void showMeta() {
  int time =  meta.length();
  textSize(50);
  textAlign(CENTER);
  text( (int)(time/1000-millis()/1000)/60 + ":"+ (time/1000-millis()/1000)%60, -7, 21);
}

boolean flag =false;
void mousePressed() {
  if (dist(mouseX, mouseY, width/2, height/2)<150) flag =!flag;
}

void keyPressed() {
  if(key==' ')exit();
  if(key=='s')saveFrame("###.jpeg");
}

【问题讨论】:

    标签: shell audio video terminal processing


    【解决方案1】:

    您不能从命令行或脚本运行.pde 文件。

    但是您可以将 .pde 文件转换为 Java 应用程序,然后像运行任何其他 Java 应用程序一样运行该 Java 应用程序。

    第一步,从处理编辑器转到File &gt; Export Application...,这会打开导出选项窗口。在那里设置您的选项(可能会稍微玩一下以查看每个选项的作用),然后单击 Export 按钮。

    这会将应用程序导出到您的草图目录。该应用程序为您提供各种 .java.jar 文件,您可以将它们用作 Java 应用程序。

    从那里只需像运行任何其他 .jar 文件一样运行 .jar 文件。

    【讨论】:

    • 嘿@KevinWorkman 我尝试了该导出选项,它确实导出了文件。但是我收到了太多文件。如何知道脚本中要运行哪个文件?
    • @PradhvanBisht 您需要所有文件。您将运行具有您的草图名称的.jar.java 文件,并将其余部分添加到您的类路径中。来自-cp 选项的脚本。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多