Factsheet
Bobby Bingham (libavfilter)
Bobby Bingham (libavfilter)
Videos
You need libavcodec and libavformat. The FAQ tells you:
4.1 Are there examples illustrating how to use the FFmpeg libraries, particularly
libavcodecandlibavformat?Yes. Check the doc/examples directory in the source repository, also available online at: https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples.
Examples are also installed by default, usually in
$PREFIX/share/ffmpeg/examples.Also you may read the Developers Guide of the FFmpeg documentation. Alternatively, examine the source code for one of the many open source projects that already incorporate FFmpeg at (projects.html).
The FFmpeg documentation guide can be found at ffmpeg.org/documentation.html, including the Developer's guide. I suggest looking at libavformat/output-example.c or perhaps the source of the ffmpeg command line utility itself.
If you just wanted to make a call to ffmpeg as function rather than a system call, you can do that pretty easily.
In ffmpeg.c, change:
int main(int argc, char **argv) to int ffmpeg(int argc, char **argv)
Then in your call the ffmpeg function and pass in an array that mimics the command line. To make it even easier use a function to create the argc, argv variables.
static int setargs(char *args, char **argv)
{
int count = 0;
while (isspace(*args)) ++args;
while (*args) {
if (argv) argv[count] = args;
while (*args && !isspace(*args)) ++args;
if (argv && *args) *args++ = '\0';
while (isspace(*args)) ++args;
count++;
}
}
char **parsedargs(char *args, int *argc)
{
char **argv = NULL;
int argn = 0;
if (args && *args
&& (args = strdup(args))
&& (argn = setargs(args,NULL))
&& (argv = malloc((argn+1) * sizeof(char *)))) {
*argv++ = args;
argn = setargs(args,argv);
}
if (args && !argv) free(args);
*argc = argn;
return argv;
}
void freeparsedargs(char **argv)
{
if (argv) {
free(argv[-1]);
free(argv-1);
}
}
return count;
}
int main()
{
char **argv;
char *cmd;
int argc;
cmd = "ffmpeg -i infile outfile";
argv = parsedargs(cmd,&argc);
ffmpeg(argc, argv);
}
I've had many programming problems that I've been told to use FFMPEG for, where high performance is necessary. For example, if I want to decode a single H264 packet, I don't want that to be written to storage for me to use, I want it to be in memory, as reading and writing to a drive is slow. The FFMPEG bindings I've seen in Go and Java use it as command-line tools, is there any FFMPEG library that I could use instead? Something where if I use a function, I get returned an object in memory, rather than having it written out to a file?