C++ video handling - c++

What is the easiest method for reading in the raw data (raw RGB image data for each frame) from a video file, in C++.
I really would appreciate some good detailed responses, or helpful links. I intend to manipulate the data using inline assembly.
I am using microsoft visual C++ 2010 express.

If you want to manipulate the frame, OpenCV is a good tool. Here you have a pointer to read video.

You could use DirectShow for this purpose. There are many add-ons available to help you render most of the video formats. It also supports rendering images from webcams AFAIK. The other alternative would be to use MediaFoundation SDK that comes with Windows SDK 7.0. MediaFoundation SDK will supersede DirectShow in future.

Related

Video Playback in DirectX 11

Pretty self explanatory. Microsoft had DirectShow for DirectX 9, but using DirectShow with DX11 is a COM nightmare beyond words. Is there a standard for video rendering I haven't heard of, or perhaps a free third-party library for this purpose?
Edit: Thanks to Mgetz, I am aware of Microsoft's attempt at a solution, Media Foundation. However, it's limited to Windows 8+, which I would much prefer to avoid.
This may not exactly match your requirement, but for your GOAL, you may take a look on ffmpeg, libx264 and theora(for ogg sound) or faad(decode aac).
I have done using ffmpeg to open container(3gp/mp4 is simple to implment yourself btw if full GPL licence is a concern), libx264 to decode to frame and upload to opengl texture, performance is good (on mac pro it can render 50 fps for 1080p without optimization) and by getting your hand dirty you can have fun doing stupid things with the texture and 3d transforms.
Media Foundation says that it "enables the development of applications and components for using digital media on Windows Vista and later."
So, it looks like it should work for Vista, Windows 7, and Windows 8.
There is DirectX Video Acceleration 2.0 which has a fabulous API, the DXVA-HD (after one has seen VMR9's API, especially with that custom allocator/presenter for renderless drawing, every other API is fabulous :) )
Have a look at: https://msdn.microsoft.com/en-us/library/windows/desktop/ee663586(v=vs.85).aspx
Also, there is a sample in: https://msdn.microsoft.com/en-us/library/windows/desktop/dd756740(v=vs.85).aspx
Windows 7 is the minimum supported windows version
You will not believe how straight forward it is with this API to have it decode the video into your texture.

DirectShow webcam recording

I need to use DirectShow (C++) for recording a webcam and saving the data to a file.
I really don't know how DirectShow works, this is a "stage" (working experience), but at school we didn't study it.
I think the best way to implement this could be:
List the video devices connected to the computer
Select the correct camera (there will be only one)
Retrieve the video
Save it to a file
Now there are two problems:
Where can I find a good reference book or how do I start?
The saved video shouldn't be too big, does DirectShow provide a way to compress it?
I won't use OpenCV because sometime it doesn't work properly (It doesn't find the camera).
Are there any high level wrapper that could help?
EDIT: the program won't have a window, it will run in background called by a dll.
Where can I find a good reference book or how do I start?
DirectShow introduction material
The saved video shouldn't be too big, does DirectShow provide a way to compress it?
Yes it provides capabilities to attach codecs, that needs to be installed in the system. These are typically third party codecs (for reasons beyond the scope of brief answer). You might want to record into Windows Media files to not depend on third party codecs. SWee more on MSDN: Choosing a Compression Filter.

edit frames from a video source before render c++

I need you to recommend me a library for c++ to use with visual c++ 2008 to perform an edition ef the frames from a video source before been rendered on the screen. I dont want to perform effects like blur or things like that, I want to change the size en some cases and other stuff.
I have tried with phonon (where I cant access the frames) and opencv (where I can get the frames but I cant display the audio because the library is for other purpose), I have been reading about directshow on windows but I still dont know if I can recover the frame.
Regards, Marco.
Try ffmpeg. It's what OpenCV uses to read frames.
FFMPEG includes a simple player -- ffplay. Have a look at its source for an idea of how to use the library.
As misha said FFMPEG is THE library for videoacquisition. As you use C++, you can try the simpler to use FOBS, which is a C++ encapsulation of FFMPEG. You can look at the sources if you want to do your own C++ wrap around FFMPEG.
my2c

How to render direct3d in a directshow source filter

Using c++ in visual studio 2008. How can I render d3d content as a directshow source filter.
Matt
Why is DirectShow involved? A DirectShow source filter provides a stream of data for other filters to process. Direct3D is an API that allows for accessing the graphics card for rendering. DirectShow and Direct3D are two separate things.
If you want to render Direct3D content, then you use Direct3D. There are some Direct3D 9.0 samples here for you to examine. I suggest you start looking at the "Initialization" sample and work upwards from there.
Edit: If we're not talking about a full-blown high-performance graphics solution, you can refer to this Stack Overflow question and this MSDN forum question. Hopefully it can get you started.
There's a nice example video source filter at http://tmhare.mvps.org/downloads.htm "capture source filter"

Rendering Video in OpenGL

Is there a good solution for playing a compressed video in OpenGL?
It needs to
Be cross-platform (Windows and MacOSX)
Render to a texture (preferably but not 100% needed)
Cost less than Bink
Any ideas?
Qt can be used to render widgets (including a video player) in an OpenGL scene. It has a multimedia framework called phonon that can play video and audio.
See this demo video.
Qt is cross-platform and is now licensed under LGPL.
I recommend the Theora video format.
Here are the benefits:
Totally open, free and patent-unencoumbered specification
Free working library implementation (encoder/decoder) and source-code examples, available under a BSD-style license
Not too shabby documentation.
Portable
The decoder lets you decode to R'G'B', which can easily be uploaded with an OpenGL buffer object and fetched in a shader via a sampler.
if you mean by solution that you can build/code it, i can suggest quicktime (easy on mac with cocoa, strange on windows but it works) or you can checkout mplayer/vlc sources and try to integrate that. there are a lot of demos about this on the web.
since you need cross platform, i guess gstreamer, video4linux and directshow are nothing for you. but there are video players that support different backends on different platforms - like openFrameworks