Playing mpg file in XNA - xna

Is there any way to play mpg files in XNA? (I want to develop a game that a video stream has to play at background)

XNA has built-in video playback. A good place to get started using it might be Catalin's XNA 3.1 Video Sample.
One downside to XNA's built-in functionality is that it has limited format support (specifically WMV9). So you will need to convert your video to that format. Two options for encoding are Windows Movie Maker and Windows Media Encoder (which seems to have recently become Expression Encoder 4).
Once in that format, you can simply add it as content to your project. Then load it as a Video through the content manager, and use VideoPlayer to play it back, calling videoPlayer.GetTexture() to get a texture of the current video frame you can set on the device or pass to spriteBatch.Draw().

Related

Manual Bit rate control of video in swift

I wanted to implement a video quality control in video player in swift.I have used preferredPeakBitRate of avplayer item but I am not able to change the quality of video while the video is playing.I have the manifest file URL that contains different bit rates of video.Kindly suggest me any third party video player that used manual video quality control or tell me how I can achieve using avplayer in swift.

How to select a video codec when capturing with DSPack?

I need to create an application that captures a video from a webcam. Later on I need to load the video and be able to navigate around in the video freely.
When I use the videocap-demo that comes with the Sources of DSPack, the captured video is encoded in H264. When I navigate around in that video, the picture becomes blurry, with wrong colors and you can't recognize the picture. (I tried with VLC and Windows media player)
...playing the video works, but after jumping to any position in the video, it looks like this...
How can I tell DSPack to capture the video e.g. in the old MJPEG-format?
(I tried with old videos from my camera. In MJpeg the navigation seems to work flawless)
Thanks in advance, R.

Load video from iPhone library, modify frame and play it in real-time

I'm looking for a tips to develop an application for iPhone/iPad that will be able to process video (let's consider only local files stored on the device for simplicity) and play it in real-time. For example you can choose any movie and choose "Old movie" filter and want it like on old lamp TV.
In order to make this idea real i need to implement two key features:
1) Grab frames and audio stream from a movie file and get access to separate frames (I'm interested in raw pixel buffer in BGRA or at least YUV color space).
2) Display processed frames somehow. I know it's possible to render processed frame to OpenGL texture, but i would like to have more powerful component with playback controls. Is there any class of media player that supports playing custom image and audio buffers?
The processing function is done and it's fast (less than duration on one frame).
I'm not asking for ready solution, but any tips are welcome!
Answer
Frame grabbing.
It seems the only way to grab video and audio frames is to use AVAssetReader class. Although it's not recommended to use for real-time grabbing it does the job. In my tests on iPad2 grabbing single frame needs about 7-8 ms. Seeking across the video is a tricky. Maybe someone can point to more efficient solution?
Video playback. I've done this with custom view and GLES to render a rectangle texture with a video frame inside of it. As far as i know it's the fastest way to draw bitmaps.
Problems
Need to manually play a sound samples
AVAssetReader grabbing should be synchronized with a movie frame rate. Otherwise movie will go too fast or too slow.
AVAssetReader allows only continuous frame access. You can't seek forward and backward. Only proposed solution is to delete old reader and create a new with trimmed time range.
This is how you would load a video from the camera roll..
This is a way to start processing video. Brad Larson did a great job..
How to grab video frames..
You can use AVPlayer+ AVPlayerItem, it provide you a chance to apply a filter on the display image.

How to build a video wall with multi-streams

I am attempting to make a mosaic display for our video wall. The mosaic will play video files (wmv) in a matrix view (probably 4x2). I am looking for a programmatic aproach to stream multiple videos using mms.
I have accomplished something similar using vlc mosaic plugin, but it terminates when the first video finishes playing. I am interested in running the tool in a loop.
Here is a vlc mosaic example: https://gist.github.com/1367589
First question, what is the easiest technology that I can implement this in, DirectX SDK, Windows SDK for Media Foundation, OpenGL, libvlc?
Are there any tutorials for multi video playback coding?
VLC and gStreamer are good options for this and have support for picture in picture videomixing.

How to display and control full-screen video in an XBOX game

I would like to create a game for XBox360 which is mostly full-screen HD videos. The player will be given choices during the game to determine which video is to be played.
I need very fine-grained control over the video such as controlling playback speed, seeking to video frames and possibly applying simple effects to the videos.
I also want to be able to use augmented reality to add elements to the videos so I need to be able to render 3d objects over the video.
It would be great if this could be done in XNA however there is only basic video playback functionality there. What other options do I have?
Your options for decoding videos are limited. The VideoPlayer class provides functionality for playing videos from the start, pausing and resuming them, looping them, and setting their audio volume.
As far as displaying videos goes - you have a huge degree of freedom. You basically get each frame of the video as a texture that you can draw as a sprite, or apply to any 3D object. This includes using it as an input to a pixel shader, allowing you to apply all kinds of effects to the video.
The only alternative to the built-in player is to create your own. If you want to target the Xbox 360 this will limit you to managed code only. I am not aware of any suitable video decoder libraries.
For Windows, a little Googling revealed this library, which may be a good starting point.

Resources