I'd like to add video conversion capabilities to a program I'm writing. FFmpeg's command line interface for doing this is simply ffmpeg -i InputFile OutputFile
, but is there a way to make use of it as a library, so I can do something like ffmpeg_convert(InputFile, OutputFile)
?
I'm hoping I won't have to use libavcodec directly, as I imagine it will be far more complex than a one-line function to convert between formats. If FFmpeg can't be easily retrofitted to do this, is there perhaps another library based on it that does? I've heard of libvlc, but that seems to only expose a video playing API, not video conversion.
Thanks.
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:
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.
You need
libavcodec
andlibavformat
. The FAQ tells you: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 theffmpeg
command line utility itself.Yes you have to use libavcodec and libavformat. I think you should read about ffplay.c inside ffmpeg source code. I think it would be easier for you to start with that file. Anyway I have made some application using those library, check it out at rtstegvideo.sourceforge.net.
Hope this help...