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.
Using ffmpeg convert a file from one format to another
Asked Answered
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)
hey man nice answer.. however i'm not sure how to address this codec thingie.. usually i don't specify the codec format (ie i just do
ffmpeg -i inputFile outputFile
, however now that i'm converting from mp4 to mp3.. I'm getting this error: Encoder (codec none) not found for output stream #0:0
.. see full command and error log here –
Rifle @Rifle thanks man.. Its been 2 years since i have worked on ffmpeg. so do not know much now in detail but it seems that your outputFile's container format supported codec's encoder library is not installed or not supported in your ffmpeg so need to install that or give supported codec's name to encode stream by CLI –
Kat
© 2022 - 2024 — McMap. All rights reserved.
CLI
Command Line Interface way of converting ;) I'm planning to call a function defined inffmpeg
library from my program if possible. – Elma