Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4k高清视频黑屏 #100

Open
iWolfSex opened this issue Nov 3, 2024 · 0 comments
Open

4k高清视频黑屏 #100

iWolfSex opened this issue Nov 3, 2024 · 0 comments

Comments

@iWolfSex
Copy link

iWolfSex commented Nov 3, 2024

  • (void) texture:(MDVideoFrame*)frame{
    dispatch_sync(dispatch_get_main_queue(), ^{
    int planes[3] = { 0, 1, 2 };
    const GLsizei widths[3] = { frame->pitches[0], frame->pitches[1], frame->pitches[2] };
    const GLsizei heights[3] = { frame->h, frame->h / 2, frame->h / 2 };
    const GLubyte *pixels[3] = { frame->pixels[0], frame->pixels[1], frame->pixels[2] };

      switch (frame->format) {
          case SDL_FCC_I420:
              break;
          case SDL_FCC_YV12:
              planes[1] = 2;
              planes[2] = 1;
              break;
          default:
              NSLog(@"[yuv420p] unexpected format %x\n", frame->format);
              return;
      }
      
      if ([self beginCommit]) {
          for (int i = 0; i < 3; ++i) {
              int plane = planes[i];
              glBindTexture(GL_TEXTURE_2D, self.program.mTextureUniformHandle[i]);
              glTexImage2D(GL_TEXTURE_2D,
                           0,
                           GL_LUMINANCE,
                           widths[plane],
                           heights[plane],
                           0,
                           GL_LUMINANCE,
                           GL_UNSIGNED_BYTE,
                           pixels[plane]);
          }
          [self postCommit];
          
          self.mRendererBegin = YES;
          [self.sizeContext updateTextureWidth:frame->w height:frame->h];
          GLenum errorCode = glGetError();
          if (errorCode)
          {
              printf("glGetError:%d\n", errorCode);
              //throw;
          }
      }
    

    });
    } 你好我播放视频的时候报[yuv420p] unexpected format 4254565f 可能是视频分辨率过大导致的 请问该怎么解决呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant