[Libav-user] Displaying video in Windows
Oleg
mybrokenbeat at gmail.com
Tue Nov 13 11:17:23 CET 2012
The most easiest native way:
Decoding part:
Read thread: Open file, read packets and push them to audio and video shared queues;
Audio thread: Read packets from audio queue, decode and push to audio play queue(in PCM format);
Video thread: Read packets from video queue, decode, convert from YUV to RGB(using sws_scale) and push to video play queue(in RGB format).
Examples for this part are ffplay and Dranger's example (http://dranger.com/ffmpeg/);
Drawing part:
1. Create window and get HWND pointer;
2. Create OpenGL context and set pixel format for that window http://www.nullterminator.net/opengl32.html ;
3. Create timer for your window(WM_TIMER) with interval equal to video's 1second / frame rate;
4. When receiving timer event - draw next frame from video queue using glTexSubImage2d(probably, fastest way)\ glTexImage2d or glDrawBuffer;
Audio part:
1. Init XAudio2 and create media buffer with sample rate, frequency and channels same as in your video;
2. Attach callback for playing audio;
3. When callback is called - read next audio frame from audio queue and play it;
These steps are minimum for creating own video player which will work on windows 2000 and all older versions. You can change drawing part to DirectX API, but this way is not cross-platform.
After this you will have problems with audio\video synchronizations. How to solve them you may also see in ffplay or Dranger's example.
After this you will probably want to convert YUV to RGB on shader, but that is another story.
So, as you see it is not so easy as you may think. So ffplay is probably best way for fast development. Also you may try VLC's libraries APIs which are embedding directly to HWND. SDL may also create window using SDL_CreateWindowFrom, for example.
13.11.2012, в 7:12, Tom Isaacson написал(а):
> I've looked at the source for ffplay and can see that the video is displayed using SDL. But as far as I can tell this doesn't actually use a real window in Windows, it just creates a space on the screen then watches for mouse events in the area.
>
> Are there any examples that show how to play video in Windows using the native functions rather than SDL?
>
> Thanks.
>
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20121113/af429cc9/attachment.html>
More information about the Libav-user
mailing list