MediaCodecEncodeH264 icon indicating copy to clipboard operation
MediaCodecEncodeH264 copied to clipboard

How to encode YUV video by your sample code??

Open robinsd opened this issue 7 years ago • 1 comments

為何我使用已錄好的NV21 video下去做264編碼,是可以成功得到264 file,但為何影片的fps會如此之快而且只有1秒呢?? 以下是我修改過的地方,可否幫我確認是哪個環節出錯或者應該要怎麼修改呢??

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); avcCodec = new AvcEncoder(width,height,framerate,biterate); avcCodec.StartEncoderThread(); SupportAvcCodec(); Thread desktopSerThread = new Thread(clientSocket); desktopSerThread.start(); }

Runnable clientSocket = new Runnable() {


    @Override
    public void run() {

        try {

            int k=width*height*3/2;

FileInputStream intra = new FileInputStream("//storage//3133-3233//download//CIF yuv420.yuv");

            byte intrabuf[] = new byte[194*k];//已知有194張frame
            byte buffer[]=new byte[k];
            intra.read(intrabuf);

            for(int i =0;i<194;i++)
            {
                for(int j=0;j<k;j++) {
                    buffer[j]=intrabuf[i*k+j];
                }
                putYUVData(buffer,buffer.length);

            }
	  avcCodec.StopThread();

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
};

robinsd avatar Apr 23 '17 10:04 robinsd

我猜测你只保存了一帧数据

windouxp avatar Mar 01 '20 13:03 windouxp