I'm trying to use FFMpeg to create a video. So far i've been playing with a multiplexing example:
http://ffmpeg.org/doxygen/trunk/muxing_8c-source.html, and i'm able to create a compressed video from an already existing video.
Because my program is going to run on an embedded platform I would like to use some custom code (generated by a colleague) to compress the video data and place it into the video file.
So I'm looking for a way to create a video file in c/c++ using ffmpeg in which i have full control over the compression part (to basically circumvent ffmpeg from doing the compression for me and inserting my own code).
To clarify i'm planning to use this to save film from an intelligent camera into a compressed h264 mpeg-4 file.
You could pipe the output with -vcodec rawvideo to your custom program, or write it as a codec and have ffmpeg handle it.
By the way, ffmpeg was superceded by avconv. ffmpeg only exists for backwards compatibility now.
Edit: apparently avconv is a newer fork of ffmpeg, and seems to have more support. Either way, the options are almost the same.
Related
I have a application (qt c++) that reads data from USB-device, decodes that data into 24bit RGB pixels which are stored in a uchar array.
Framerate is ~10 FPS. Framesize is 128x4096.
Question is: How to encode these frames into VP8 or h.264 video in real time?
No external processes are allowed, everything needs to run inside my application.
ffmpeg is an option but how to include it to my project and use it? Documentation is rather bad to say the least. Also x264 could be an option but same question as to ffmpeg. And it's also quite expensive, 1$ for unit and minimum of 10000.
Simple guide would be helpful but I doubt there exists one.
Application should run in Windows and Linux.
The problem with the VP8 SDK is that the examples only encode to IVF. That codec appears to have been shut down by Microsoft due to a security flaw (buffer overflow). It's pretty hard to even get the VP8 project setup when you can't even check the results. It at least uses a BSD license scheme and its supposedly unencumbered with patents.
The VP8 SDK has some routines for converting formats, but they are buried in the source tree.
An option not mentioned is the Intel Media SDK, but that locks you to windows.
There is also Theora and Dirac.
X264 has an encoder, but it would be expensive to get a commercial license.
GPLv2 source code is not "free". I don't care what they try to get you to believe.
There is also a project called "Revel - the Really Easy Video Encoding Library". That is a path to getting MPEG-4 part 2 files encoded. H264 is MPEG-4 part 10. H264 is also called AVC. Revel is also GPL'd.
Ffmpeg is a catch all utility that tries to create a wrapper around the various encoders/decoders. If you use the x264 encoder with it, it becomes GPLv2.
The VP8 SDK has documentation and even some sample code
How to save an IPLImage of OpenCV as a Flash file? Maybe there is a library that does that?
If you mean storing your output as a flash video (.flv) just use ffmpeg (libavcodec/libavformat). It is cross platform and supports the .flv format (besides a massive amout of others) and should be quite easy to do. You can embed audio too.
As a note: ffmpeg is partially included in opencv (depending on your build) as a video coder/decoder, i don't know though if you can force it to write as .flv (by choosing the right codec string) from within opencv. Anyways it's not too hard to convert IplImage to a ffmpeg buffer and store from there.
A problem you might have is that latest opencv (2.1) has trouble to build with ffmpeg support or is build against some ffmpeg version you don't want. But as mentioned above you don't need to use ffmpeg via the opencv 2.1 api, since you can use it directly by using the ffmpeg api.
Look for the examples in libavcodec on how to write a video, and check the opencv source on how to convert from IplImage to AVPacket/AVFrame. I've done this before and it was quite
easy to do.
I don't know Flash much, but you can manipulate the data pointer of an IplImage (named char *imageData). Data is accessible as between 1 and 4 bit plans, in a format you surely know. Try writing your Flash file from this data pointer.
lital , Well to my knowledge openCV doesn't support creating flash .
My solution for such a problem is Red5 Server
and as their page says
Red5 is an Open Source Flash Server
written in Java that supports:
Streaming Video (FLV, F4V, MP4)
....
You could dump your images in a sequence of files, say img00000.ppm, img00001.ppm, ..., and then delegate the video encoding to MEncoder, which, according to docs, supports flv.
That's what we usually do in order to prepare videos such as this one.
I'm working in an app in wich we use IMediaDet to get stream lengths. Now we're starting to work with MP4 containers. The problem is, when I try an IMediaDet::put_fileName() with the MP4 file, I get HRESULT = -2147024770 (ERROR_MOD_NOT_FOUND). Using a comercial mp4 demuxer, I see the video stream uses mpg2 encoding.
My questions: How to get the stream length of a stream inside a MP4 container? Is there a way to make IMediaDet accept these files? Is there a way to point what demuxer IMediaDet should use?
Any help would be much appreciated.
Thanks.
Unfortunately, DirectShow does not contain an MP4 parser, even in Windows 7. In Win7, the MP4 functionality was added to media foundation.
So you have a few options. You can buy or build a directshow filter that implements an MP4 demux and associate it with the "mp4" file extension, which should allow IMediaDet to properly demux the file. Or you can use Media Foundation, which should be able to return this info. Or you could use a separate library entirely for MP4 files, like MP4v2. (note you could also implement an MP4 demux filter with MP4v2, if you want to use DirectShow instead of MP4v2 directly)
My application is transforming an AVI video file into another AVI file. I use
the OpenCV library. Unfortunately videos created with OpenCV have no sound as the library does not support audio.
Is there any easy way to copy the audio track from one video file to another? Maybe FFmpeg?
My application is written in Visual C++.
You can use FFmpeg. The easiest way would be to just use the command line tool to extract/reassemble. If you need your application to do it itself, looking into the sources for how they do it should help.
Alternatively, as you mention VC++, why not use DirectShow? It should not be too difficult to sink the audio into a file for extraction and later sink the video/audio mix into a file for composition.
I'm looking for a way to extract the audio part of a FLV file.
I'm recording from the user's microphone and the audio is encoded using the Nellymoser Asao Codec. This is the default codec and there's no way to change this.
ffMpeg is the way to go !
It worked for me with SVN Rev 14277.
The command I used is : ffmpeg -i source.flv -nv -f mp3 destination.mp3
GOTCHA :
If you get this error message : Unsupported audio codec (n),
check the FLV Spec in the Audio Tags section.
ffMpeg can decode n=6 (Nellymoser).
But for n=4 (Nellymoser 8-kHz mono) and n=5 (Nellymoser 16-kHz mono) it doesn't work.
To fix this use the default microphone rate when recording your streams, overwise ffMpeg is unable to decode them.
Hope this helps !
This isn't an exact answer, but some relevant notes I've made from investigating FLV files for a business requirement.
Most FLV audio is encoded in the MP3 format, meaning you can extract it directly from the FLV container. If the FLV was created from someone recording from their microphone, the audio is encoded with the Nellymoser Asao codec, which is proprietary (IIRC).
I'd check out libavcodec, which handles FLV/MP3/Nellymoser natively, and should let you get to the audio.
I'm currently using FFmpeg version SVN-r12665 for this, with no problems (the console version, without any wrapper library). There are some caveats to using console applications from non-console .NET environments, but it's all fairly straightforward. Using the libavcodec DLL directly is much more cumbersome.
I was going to recommend this: http://code.google.com/hosting/takenDown?project=nelly2pcm¬ice=7281.
But its been taken down. Glad I got a copy first :-)