SDL 中播YUV和PCM数据的步骤:
1,播放YUV数据: 其实就是不断更新纹理
//1 打开文件
video_file = fopen(path, "r");
//2 读取数据
video_buff_len = fread(video_buf, 1, yuv_frame_len, video_file)
//3 更新纹理
SDL_UpdateTexture(texture, NULL, video_pos, video_width);
1,播放PCM数据
需要 SDL_OpenAudio(&spec, NULL) 打开播放器 spec 是设置参数:
//SDL_AudioSpec
spec.freq = 44100;
spec.format = AUDIO_S16SYS;
spec.channels = 2;
spec.silence = 0;
spec.samples = 1024;
spec.callback = read_audio_data;
spec.userdata = NULL;```
SDL_PauseAudio(0); // 播放 暂停
SDL_CloseAudio(); 结束
//1 打开文件
video_file = fopen(path, "r");
//2 读取数据
video_buff_len = fread(video_buf, 1, yuv_frame_len, video_file)
3 在播放器回调函数中填充读取的数据
SDL_MixAudio(stream, audio_pos, len, SDL_MIX_MAXVOLUME);
最后附上 雷神的学习资料