sonysuqin / WasmVideoPlayer

Play file/stream with wasm & webgl & web audio api, using ffmpeg for multi codec support, especially for h265,support http, websocket, http-flv stream.
GNU General Public License v3.0
1.3k stars 370 forks source link

Not YUV420P, but unsupported format 12. #51

Closed tingting007xxx closed 4 years ago

tingting007xxx commented 4 years ago

这个视频文件为什么会报错?https://4dkk2.4dage.com/test/test114.mp4

sonysuqin commented 4 years ago

https://github.com/sonysuqin/WasmVideoPlayer/blob/master/decoder.c

ErrorCode processDecodedVideoFrame(AVFrame *frame) { ErrorCode ret = kErrorCode_Success; double timestamp = 0.0f; do { if (frame == NULL || decoder->videoCallback == NULL || decoder->yuvBuffer == NULL || decoder->videoBufferSize <= 0) { ret = kErrorCode_Invalid_Param; break; }

    if (decoder->videoCodecContext->pix_fmt != AV_PIX_FMT_YUV420P) {
        simpleLog("Not YUV420P, but unsupported format %d.", decoder->videoCodecContext->pix_fmt);
        ret = kErrorCode_Invalid_Format;
        break;
    }

目前写死了只支持YUV420P,这个文件是YUVJ420P ,这两个就是颜色范围有点区别,数据格式是一样,这里你让这个条件通过就好了。如果是其他格式的话,就需要修改一下copyYuvData函数,就能处理其他格式的了。