I'm trying to decode an MP4 file i've created using mp4creator library. I can't find a ffmpeg or libav example that actually works with the libraries, because the code is incompatible with the examples.
I need a simple way of reading the mp4 file and decoding it into raw audio and video frames. In needs to work on windows too.
If someone can point me towards a working and compatible ffmpeg/libav library + example source file that could work too.
If i could get the library version which was used in this tutorial that would work, since this guy seems to be the only one who wrote a decent tutorial on FFMPEG (albeit on some ancient version)
http://dranger.com/ffmpeg/
edit:
In the latest version of ffmpeg i found the example named: filtering_video.c
using a patch found: http://ffmpeg.org/pipermail/ffmpeg-devel/2012-June/126587.html I have gotten the program to do "something" It looks to be working so I will investigate further.
As edited into the question: In the latest version of ffmpeg i found the example named: filtering_video.c
using a patch found: http://ffmpeg.org/pipermail/ffmpeg-devel/2012-June/126587.html I have gotten the program to work.
Using the function avtoipl described here: http://www.digipedia.pl/usenet/thread/16949/6806/
I've gotten the data into an opencv RGB image which i can display.
Related
Referring to the opencv VideoCapture documentation here, there are a few properties that only work DC1394 v 2.x backend (specifically CV_CAP_PROP_BUFFERSIZE is what I want to change). Looking at the buildInformation for openCV on my machine I see it is compiled with support for DC1394 v 2.x, FFMPEG, Gstreamer. I cannot see to figure out how to set the video backend when initializing VideoCapture. Any ideas?
Looking at the VideoCapture source code there doesn't seem to be a way to open with a specific backend in opencv 2.4.
In fact it will just pick the first backend available it can find with a defined order in the code (for example lets suppose you have opencv compiled for ffmpeg and gstreamer, the order ffmpeg first and gstreamer second, if you distribute your binary to someone and they have gstreamer but not ffmpeg it will fail to open the video capture but continue to search for the next option, in this case gstreamer). So as far as I can see you have 3 choices to use the DC1394 backend:
Modify the source so it always tries to search for DC1394 first (or even further add a function to choose a backend)
Compile with just support for DC1394 as a video backend
Convert your code to opencv 3.x which has the option to set a backend when opening the video capturer.
I want to encode images to H264 video in OpenCV.
As part of my software for image tracking, I'm using VideoWriter in OpenCV 3.4 (64-bit) with Visual Studio 2017 C++. I use ffmpeg for manual encoding, and as it comes with OpenCV I assume this is the best option. My version of OpenCV indicates it has been compiled with ffmpeg, and I can verify it loads the opencv_ffmpeg340_64.dll.
Decoding H264 (AVC1) is absolutely fine, including when specifically using the ffmpeg API. But encoding anything other than MJPG or raw images doesn't work:
VideoWriter.Open() mostly returns false, for some cases it only writes an empty or small header but won't write frames. I've tried not only the ffmpeg API, but also any available API. Redirecting console/debug output to intermediate window in VC doesn't give any messages from OpenCV or ffmpeg.
There are numerous posts on previous versions of OpenCV using FFmpeg, including (Cisco) OpenH264 library and difficulties using this. I've tried many options, installing codecs pack including H264, ffmpeg static version, Cisco openH264 library, setting paths etc and even tried the low level ffmpeg library functions such as cvCreateVideoWriter exposed in OpenCV, and using different video containers (AVI, MPG, MP4) as well as fourcc strings.
I can't believe in 2018 the great OpenCV with FFmpeg support is unable to encode anything but arcane MJPG or raw images. If it uses FFmpeg surely a significant set of functionality should be available?
Though I think this should work, my next best option would be using a separate ffmpeg library, which would ironically add another ffmpeg.dll to my solution I imagine. Any suggestion appreciated!
Code fragment (using any video encoding API):
VideoWriter writer;
int codec = VideoWriter::fourcc('X', '2', '6', '4');
writer.open("test.avi", codec, 30, colorImage.size(), true);
writer.write(colorImage);
writer.release();
To answer my own question - thank you for the previous suggestions though - I've managed to create and write frames to H264 video now, without any recompiling needed. This is what I've used:
Using OpenCV version 3.4.1
In the same folder as the exe: opencv_ffmpeg341_64.dll (provided with OpenCV)
In the same folder: openh264-1.7.0-win64.dll (available from: https://github.com/cisco/openh264/releases)
Use OpenCV VideoWriter class, omitting a specific encoding API
Container: MP4
Codec fourcc string: "H264"
I formatted my machine (Windows 10 64bit) so I can't exclude any issues with potential codec-clashing - also I have not fully tested for other combinations. As this appears to be such a common problem (with many misconceptions) I hope this is useful.
I am writing an application on linux (debian) that uses both libvlc and ffmpeg.
Both run fine separately, but the moment I try to compile both functionalities into my app, libvlc stops working (complains about not finding the codecs).
I have been able to isolate the problem, basically libvlc runs fine until I compile the first line of ffmpeg code (av_register_all), at which point the linker brings in my own ffmpeg compiled lib, and the moment I do that, it stops playing the file. Obviously I have 2 conflicting ffmpeg libs on my system, the one libvlc is using, and the newer one I built myself to write ffmpeg code.
My question is, how do I make libvlc work with the newer library? Considering there were functions deprecated in the newer ffmpeg code, would that involve recompiling libvlc? Is the libvlc code up to date with the newest ffmpeg library(new function signatures)?
Any help is appreciated!
I'm trying to go through the DirectShow documentation provided on MSDN. I'm a relative beginner to C++, as well. I was on the first example code in the DirectShow documentation here:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd389098(v=vs.85).aspx
I followed along, modified the file string to point to a video on my own computer, included and added the strmiids.lib library as a reference. My code builds successfully, and the Console Window appears. But that's it. No video renders.
I'm using VS2015, on a Windows 8.1 laptop, and I have the Windows SDK installed as well. That's where i got the strmiids.lib file.
Any help would be awesome, as this has been a frustrating obstacle in the way of learning DirectShow programming.
Thanks!
As I've mentioned in my another question, I'm having trouble with Qt 5.1's multimedia module. The QMediaPlayer class can't play some MP3 files. I haven't tested other formats thoroughly.
I'm not sure if this is a codec related problem. But I'm interested in using codec directly in my program rather than relying on the backend support for playing media files. I'll be developing the application in Qt 5.1 for desktop Windows platform.
I have no idea about using codecs in programs. Any pointer will be greatly appreciated.
You can go to [FFMPEG]: http://www.ffmpeg.org/ to integrate the open-source codec to play your media file.