大疆社区

标题: MediaCodec解码视频的问题。 [打印本页]

作者: shadowyin    时间: 2015-8-20
标题: MediaCodec解码视频的问题。
    protected ArrayList<byte[]> splitNALUnits3(byte[] videoBuffer,ArrayList<byte[]> arrayList)
            {
            byte[] videoBufferTemp = new byte[50000];
            byte[] videoBufferTemp2= new byte[50000];
//由于担心会有videoBuffer的分界处是帧界定符的情况出现,就每次都将多出来不满的一帧复制过来,并将videoBuffer接到后面,每次判断都重头遍历,时间复杂度比较高
            int k = 0;
            int size=0;                              
              if (FrameLenth != 0) {
            
                        System.arraycopy(videoBufferUnOneFrame, 0, videoBufferTemp2, 0,
                                FrameLenth);
             //videoBufferUnOneFrame用来存放不满一帧的数据
            }
   
           size=FrameLenth+videoBuffer.length;
           
           System.arraycopy(videoBuffer, 0, videoBufferTemp2, FrameLenth, videoBuffer.length);
              for(int i=0;i<size;i++)   
              {
                  if (videoBufferTemp2[i] == 0 && videoBufferTemp2[i + 1] == 0
                           && videoBufferTemp2[i + 2] == 0 && videoBufferTemp2[i + 3] == 1
                         && videoBufferTemp2[i + 4] == 9)
                  {
                      if(num!=0&&k!=0)//判断是否是第一帧
                        k=0;
                         num=1;
                      i=i+5;
                     
                  }
                  
                  videoBufferTemp[k++] =videoBufferTemp2[i];
              }
              if(k!=0){
              System.arraycopy(videoBufferTemp,0,videoBufferUnOneFrame, 0, k);}
              FrameLenth = k;//保存不满一帧的数据的长度
            return arrayList;
        
            }


也是跟之前的朋友一样,卡到了outputIndex了,感觉还是取帧有问题,请各位帮忙看看,,哪里有问题

作者: shadowyin    时间: 2015-8-20
注释的时候漏了一句话。。arrayList.add(videoBufferTemp);
作者: Qingyan    时间: 2016-5-1
您好,请问这段程序中的sum是什么?您最后运行成功了吗?





欢迎光临 大疆社区 (https://bbs.dji.com/) Powered by Discuz! X3.2