edit frames from a video source before render c++ - 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

Related

Generate Live Mp4 in UWP

I want to develop a slide-show kind of app that could be casted to smart TV, similar to showing a PowerPoint slide show. Standard Miracast solution via the Connect app does not work nicely since the phone resolution does not match the high resolution of the TV; not to count the fact that there is no way to hide the navigation bar with TryEnterFullscreenAsync. The images could be quickly rendered from vector sources. So my question is whether there is a way to generate MP4 on the fly.
As long as you can gerate the bitmaps on the fly, as you mentioned, then you can use FFmpeg to create the MP4.
Download ffmpeg source code and check the source of doc/examples/muxing.c
This example is pretty much doing this. Just replace the fill_yuv_image() by the actual thing you are rendering.
Don't forget to convert your pictures to YUV format. In this example, the encoder will need a YUV bitmap and you will probably render an RGB image. Google for swscale or even check the other examples from FFmpeg in order to solve this problem.
--
If you really want something Microsoft specific, then you must use the "Microsoft Media Foundation". There's a lot of samples here on how to encode and decode:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa371827(v=vs.85).aspx
And you can use all these codecs:
https://msdn.microsoft.com/en-us/library/windows/desktop/ff819077(v=vs.85).aspx

Rendering to video file by SFML

I have written a program using SFML Library (in C++) rendering simple 2D animation.
I would like to save the animation to a video file instead of drawing it on the screen.
Does SFML provide such functionality? Is there any other, portable way to do this? (portable between different OSes)
SFML does not have such a feature, especially since video processing is a whole world of its own. You can take a look at FFmpeg and GStreamer. Both libraries are cross-platform and should be able to record, playback and stream videos. If you want a specific codec, you could directly look at the codec's website and/or search for good encoder.
Overall it's not an easy task and depending on what you're trying to do, you could also think about grabbing the rendering directly with an third-party application, e.g. Open Broadcaster Software or (again) FFmpeg.

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.

C++ video handling

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.

Extract sound from video

I'm currently doing my Multimedia assignment where I have to create a new video using one video as a foreground and another as a background. OpenCV allows me to do just that: extracting images from each frame in video, processing them and putting the results back into a video format. However, OpenCV is only a computer vision library. Is there a library that allows me to do the same for sound? I'd like to extract sound (music, actually) from a video I'm using and put it into the final video.
You can use libavcodec library used in FFmpeg.
Try Tuna Audio Extracter (http://github.com/tuna74/TunaAudioExtracter). You can use the extracter part from that program.