yuv的保存有问题吧?YUV 4:2:0采样,每四个Y共用一组UV分量。而且你确定了摄像头采集的格式了吗?

解决方案 »

  1.   


    摄像头的采集格式参数设置为:YCbCr_420_SP
      

  2.   

    typedef struct
    {
        int i_ref_idc;  /* nal_priority_e */
        int i_type;     /* nal_unit_type_e */
        int b_long_startcode;
        int i_first_mb; /* If this NAL is a slice, the index of the first MB in the slice. */
        int i_last_mb;  /* If this NAL is a slice, the index of the last MB in the slice. */    /* Size of payload in bytes. */
        int     i_payload;
        /* If param->b_annexb is set, Annex-B bytestream with startcode.
         * Otherwise, startcode is replaced with a 4-byte size.
         * This size is the size used in mp4/similar muxing; it is equal to i_payload-4 */
        uint8_t *p_payload;
    } x264_nal_t;
    p_payload是不带startcode的,需要自己添加,H264要加00 00 00 01
      

  3.   

    另外,为什么要把长度写到文件里?H264文件是不带长度信息的,只有mp4的startcode那四个字节是长度