zoukankan      html  css  js  c++  java
  • 录转rtsphan

    java 部分

        int  myFrameSize = 36748;
        byte[] myBuf;
        byte[] myFreameBuf ;//=  new byte[myFrameSize];
        private void recordVirtualDisplay() {
            while (!mQuit.get()) {
                int index = mediaCodec.dequeueOutputBuffer(bufferInfo, 10000);
                if (index == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
    
                } else if (index >= 0) {
                    boolean mbTemp = encodeToVideoTrack(index);
                    mediaCodec.releaseOutputBuffer(index, false);
                }
            }
        }
        
        private boolean encodeToVideoTrack(int index) {
            ByteBuffer encodedData = mediaCodec.getOutputBuffer(index);
    
            int end = bufferInfo.flags
                    &MediaCodec.BUFFER_FLAG_END_OF_STREAM;
            if(end!=0) return false;
    
            if (bufferInfo.size == 0) {
                encodedData = null;
                return false;
            }
            if (encodedData != null) {
                encodedData.position(bufferInfo.offset);
                encodedData.limit(bufferInfo.offset + bufferInfo.size);
             
                myFrameSize = encodedData.remaining();
                myFreameBuf = new byte[myFrameSize];
                encodedData.get(myFreameBuf, 0, myFreameBuf.length);
                Log.e("-----", "myFrameSize = "+myFrameSize);
                sendFrameFromJNI(myFreameBuf,myFrameSize);
                Log.e("-----", "come after sendFrameFromJNI");
     
                return false;
            }
            return false;
        }
    
    
      #define MAX_FRAME_SIZE 50*1024

      unsigned char jniFrameBuffer[MAX_FRAME_SIZE] = {0};
      int frameSize = 0;

    extern
    "C" JNIEXPORT jstring JNICALL Java_com_example_testrtsp_MainActivity_sendFrameFromJNI( JNIEnv* env, jobject /* this */, jbyteArray buffer, jint len ) { LOGE(" 1212 _sendFrameFromJNI len= %d", len); jboolean isCopy = true; unsigned char *pBuffer = (unsigned char *)env->GetByteArrayElements(buffer,&isCopy); memcpy(jniFrameBuffer,pBuffer,len); frameSize = len; SendFrame((char*)jniFrameBuffer,&frameSize); std::string hello = "Hello from C++"; env->ReleaseByteArrayElements(buffer,(jbyte*)pBuffer,0); return env->NewStringUTF(hello.c_str()); }

    https://www.cnblogs.com/Sharley/p/5610778.html

    这个有nalu

    https://www.jianshu.com/p/1977d151c7dc

    https://github.com/EricLi22/AndroidMultiMedia/releases

    java读二进制 和cpp修改

            String path = "E:\\test.264";
            File file = new File(path);
            FileInputStream in1 = new FileInputStream(file);
            DataInputStream data_in = new DataInputStream(in1);
            int length = (int)file.length();
            byte[] itemBuf = new byte[length];
            data_in.read(itemBuf,0,length);
    
            data_in.close();
            in1.close();
     
  • 相关阅读:
    C
    如何让asp.net mvc 直接运行mobile页面
    Nuget找不到服务器
    C#调用R语言输出图片
    sql列转行
    C#读取注册表
    关于这个博客,关于我
    NOIP 2016 简要题解
    CSP2019 题解
    CF 练死劲
  • 原文地址:https://www.cnblogs.com/cnchengv/p/15635181.html
Copyright © 2011-2022 走看看