Question

I want to use ffmpeg (in its c library form) to split a video in more parts, recompose them and encode the final result. Something basic. But it's very difficult to find documentation or hints about this. Where should I look/ask for advice?

Was it helpful?

Solution

You can learn a great deal from the source of the command-line utilities maintained by the FFmpeg project.

In ffplay.c, the main() will show you how to get the library initialized. stream_component_open() demonstrates matching codecs to streams in the media, and get_video_frame() shows how to decode a packet and get its PTS (presentation time stamp). You'll need that to time your splits correctly.

That should get you started on the decode side. On the encode side, look at ffmpeg.c. It's larger and more complicated than ffplay, but the process of encoding a frame nearly mirrors the process of decoding it, so once you have decoding working, it should make more sense.

OTHER TIPS

i was searching for a FFmpeg tutorial and php but i found the following are the best places to learn it with any language a book i think it's the only book about FFmpeg FFmpeg Basics: Multimedia handling with a fast audio and video encoder

http://www.amazon.com/FFmpeg-Basics-Multimedia-handling-encoder/dp/1479327832/ref=sr_1_12?ie=UTF8&qid=1357356672&sr=8-12&keywords=ffmpeg

enter image description here

and the scond place is http://ffmpeg.org/documentation.html

I was also looking for a good c/c++ FFmpeg tutorial for a while, and this c/c++ ffmpeg-libav-tutorial is definitely the best I found so far. It explains how to use the FFmpeg as a library and before that gives a clear overview about video key words (like encoding, decoding, transconding, muxing exc.) which is very helpful for people who are not that familiar with videos.

In addition, this tutorial is great to understand the concept of video, so for those who are not familiar enough with the video world, I suggest to start with this, and only then to continue with the c/c++ ffmpeg-libav-tutorial.

TLDR;

https://github.com/ShootingKing-AM/ffmpeg-pseudocode-tutorial - A broad workflow understanding of ffmpeg-cli through loose pseudocode.


The best way as per FFmpeg devs is to read thorugh source of ffmpeg libav and/or ffmpeg-cli.

The goal of understanding ffmpeg-cli is to be able to to integrate FFmpeg into our projects without having to call the ffmpeg-cli in background to do multimedia operation. This is important because,

  • Starting up an external executable tends to be blocked by antivirus software and can cause issues with users.
  • Optimize your project specific libav usage and skip unnecessary code from ffmpeg-cli Also, ffmpeg official documentation being vague at best, the only option for developers looking to implement ffmpeg's libraries (libav) functionality into their code is to read the command line interface's source code.

But, Reading ffmpeg-cli's source code is very hard, because its not meant to be used as a study material for understanding how to use libav but as a optimized multimedia tool. Hence, i tried to straighten out its source code into simple pseudocode function highlighting when and where to call important(almost all) libav's functions, for an overall broader picture of ffmpeg workflow. For information regarding how to call a libav function call, one can refer to the doxygen documentation and ffmpeg-cli-source files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top