[Libav-user] Displaying video in Windows
Tom Isaacson
Tom.Isaacson at navico.com
Tue Nov 13 11:52:14 CET 2012
I probably should have mentioned that the source is an RTSP server and it's only video, so audio\video synchronisation is not an issue. What I want to do is write a Windows 8 Metro app that displays this video stream. Unfortunately Microsoft don't support RTSP (see http://stackoverflow.com/questions/12994188/how-can-i-play-h-264-rtsp-video-in-windows-8-metro-c-sharp-xaml-app) so rather than attempt to write a media source plugin I'm going to try using VLC's libraries. Hopefully I'll also be able to recompile them for ARM to get it working on WinRT but that will come later.
Thanks for your help.
From: libav-user-bounces at ffmpeg.org [mailto:libav-user-bounces at ffmpeg.org] On Behalf Of Oleg
Sent: Tuesday, 13 November 2012 11:17 p.m.
To: This list is about using libavcodec, libavformat, libavutil,libavdevice and libavfilter.
Subject: Re: [Libav-user] Displaying video in Windows
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
More information about the Libav-user
mailing list