Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/464.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用JMuxer.js玩Java';s FFMPEGFRAME抓取框架_Javascript_Java_Cordova - Fatal编程技术网

Javascript 如何使用JMuxer.js玩Java';s FFMPEGFRAME抓取框架

Javascript 如何使用JMuxer.js玩Java';s FFMPEGFRAME抓取框架,javascript,java,cordova,Javascript,Java,Cordova,1.我有来自JAVA UDP的原始数据 Log.d(TAG,Arrays.toString(temp2));//Length 951 [0,0,0,1,103,77,0,40,87,80,10,0,73,66,0,0,7,48,0,1,122,96,8,0,0,0,0,1,104,18,60,128,0,0,0,0,0,0,…] 2.JMuxer可以播放h264数据 //html <video controls autoplay id="_play" style=

1.我有来自JAVA UDP的原始数据

Log.d(TAG,Arrays.toString(temp2));//Length 951
[0,0,0,1,103,77,0,40,87,80,10,0,73,66,0,0,7,48,0,1,122,96,8,0,0,0,0,1,104,18,60,128,0,0,0,0,0,0,…]

2.JMuxer可以播放h264数据

//html
  <video controls autoplay id="_play" style="width: 300px; height: 300px;>
  </video>
3.问题:我可以将FFmpegFrameGrabber帧传输到Javascript吗

我试过了

  • 帧传输到位图
  • 位图传输到Base64
  • Base64返回Javascript的画布, 但是这条路太慢了
    var nn1=[0,0,0,1,103,66,192,30,218,2,128,191,229,192,90,128,128,128,160,0,0,125,32,0,23,112,1,226,197,212,0,0,0,1,104,206,60,128,0,0,0,1,101,136,132,55,255,255,208,92,80,0,16,89,...];
    //Length 26139
    player = new JMuxer({
      node: '_play',
      mode: 'video',
      fps: 25,
      debug: true
    });
    
    setTimeout(function () {
       player.feed({
          video: new Uint8Array(nn1)
        });
    }, 500);
    
    
    //JAVA
    ...
        private PipedOutputStream outputStream = null;
        private PipedInputStream inputStream = null;
        private FFmpegFrameGrabber grabber = null;
    
     private void init() {
            if (this.grabber == null) {
                this.grabber = new FFmpegFrameGrabber(this.inputStream);
                this.grabber.setVideoCodec(27);
                this.grabber.setFrameRate(25.0D);
                this.grabber.setVideoBitrate(1200000);
                this.grabber.setImageWidth(1280);
                this.grabber.setImageHeight(720);
                this.grabber.setVideoCodecName("libx264");
                this.grabber.setOption("bufsize", "10000");
                this.grabber.setOption("filter:v", "fps=fps=25");
    ...
    
            }
        }
    
    
      public void run() {
            super.run();
            try {
                this.outputStream.write(new byte[1024]);
                this.outputStream.flush();
            } catch (IOException var6) {
                System.out.println(var6);
            }
    
    
            try {
                this.grabber.startUnsafe(false);
                try {
                    Thread.sleep(50L);
                } catch (InterruptedException var5) {
                }
    
                Frame frame;
    
                while((frame = this.grabber.grabFrame(false,true,false,false,false)) != null){
    
                  //Can I transfer frame to buffer array? //[0,0,0,1,103,66,192,30,...]  
                  //I need a complete frame to play
    
                }
    
            } catch (FrameGrabber.Exception e) {
                e.printStackTrace();
            }
    
            System.out.println("FFmpeg stop && release");
        }