Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ffmpeg convert a file from one format to another

I'm new to ffmpeg and I was trying to find out how to convert a audio or video file from one format to another. I don't want to use CLI, I just want to know if I can use ffmpeg as a library and call a function to convert a file from one format to another. I went through the documentation and found functions avcodec_encode_audio and avcodec_encode_video but its not clear how I can use this to convert. A tutorial or an example will be very helpful.

like image 707
Pannu Avatar asked Nov 10 '11 07:11

Pannu


1 Answers

usually i do this by command line

ffmpeg -i input.mp4 -vcodec copy -acodec copy out.mkv

here i/p file is input.mp4 which will be converted into out.mkv with having same codec of all elementary stream

NOTE: upper command will only work when the input.mp4 's all codec will be supported by .mkv container.

and if you are not concern with codec then use

 ffmpeg -i input.mp4 out.mkv

this will convert mp4 to mkv (if necessary it will also change codec of output format)

like image 189
Jeegar Patel Avatar answered Oct 26 '22 20:10

Jeegar Patel