cpp_weekly icon indicating copy to clipboard operation
cpp_weekly copied to clipboard

Tutorial on how setup, use and run FFMPEG in a program

Open Gadamatik opened this issue 2 years ago • 4 comments

Channel

"C++Weekly"

Topics

How to setup, use and run ffmpeg in a program. It's really challenging for newbies 😊😊😊like me. Thanks

If it can be in many episode that will be fine.

Length

10-20 minutes

Gadamatik avatar Feb 01 '23 15:02 Gadamatik

@Gadamatik I do not want to be a gatekeeper here, however, I think ffmpeg has one of the most complete man pages of all, it explains step by step what the program does and it also has examples. You can read it here: https://www.manpagez.com/man/1/ffmpeg/

Also most things that you might want to do using ffmpeg, you can search for them and you might find a tutorial/forum that explains how to do that.

I'll write a more less comprehensive “Getting started” guide so you can understand better the manual:

ffmpeg [reading/decoding_options...] -i input_file [writing/encoding_options...] output_file

Before dong something with any file, you might want to see what is inside (a video usually is a bundle of streams of audio, vision and subtitles), so for that, you only do:

ffmpeg -i input_file

This will tell you enumerate the file streams and will tell you some details.

If you want to manipulate the streams of multiple files you might check them with:

ffmpeg -i input_file1 -i input_file2

You will notice that the streams have an indexing of the form n:m that means the n'th file, the m'th stream

You may manipulate the first stream of the first file with the option -map 0:0

Now, the important thing here that for each stream, you will se the info of how it was encoded, so then you can use the:

ffmpeg -codecs

To see which would be the best codecs to decode the streams (some uses gpu's some are only available with some specific non-gpl-friendly compilations, etc). same for how you want to encode them. if you don't want to modify the stream there is always the self-explanatory copy codec (useful if you are only trimming files, for example).

If you understand this, the man pages should be easier. After reading this and checking the manual, if you still have a more specific question, ask that in a forum.

fcolecumberri avatar Feb 02 '23 16:02 fcolecumberri

Hello @fcolecumberri ,

Thanks for your kind reply and I really appreciate it. I already install it and I know some point (obviously not like you), even if I'm beginner. But I'm looking for a way on how to use the ffmep library itself in program to take advantage of.

I already tried to read the "famous" tutorial on Dranger . But I quickly understand that it is outdated. I got a bunch of undefined reference when linking with my hello ffmpeg program. And so far, I'm aware of how to link a library.

So to not be long on this comment, that's why I asked for help and I know whatever passed under the hands of @lefticus, it become clear for anybody.

Best Regards

Gadamatik avatar Feb 05 '23 14:02 Gadamatik

Looks like the man page is for cli and I think @Gadamatik want's the c++ api? Some resources to get you started are:

  • https://github.com/leandromoreira/ffmpeg-libav-tutorial#chapter-0---the-infamous-hello-world
  • https://github.com/denesik/ffmpeg_video_encoder
  • https://www.youtube.com/watch?v=HVkcdhqWp5s

JonathanHiggs avatar Feb 13 '23 17:02 JonathanHiggs

Happy new year 2024.

@JonathanHiggs are completly right, It's that I want... But with the touch of @lefticus on it...

Gadamatik avatar Jan 03 '24 07:01 Gadamatik