SwiftFFmpeg: Sample code, "Invalid data found when processing input" and av_register_all
Hello,
I am now trying SwiftFFmpeg as a replacement for VLCkit. I am at the very beginning of the integration, so I just integrated the sample code from README.md.
It gave me an “Invalid data found when processing input” error on the very first line (try AVFormatContext(url: input)), for any video file (correctly played with ffplay).
After some difficult research, if found this tutorial : http://dranger.com/ffmpeg/tutorial01.html, which gave me the solution : av_register_all() should be called before any operation.
So I made this :
import CFFmpeg
class FfmpegUtils
{
static func registerAll()
{av_register_all()}
}
and then
//...
FfmpegUtils.registerAll()
let fmtCtx = try AVFormatContext(url: url.relativePath)
//...
which makes the sample code work.
However, av_register_all() triggers a deprecation warning, as FF_API_NEXT is defined :
In avformat.h :
#if FF_API_NEXT
/**
* Initialize libavformat and register all the muxers, demuxers and
* protocols. If you do not call this function, then you can select
* exactly which formats you want to support.
*
* @see av_register_input_format()
* @see av_register_output_format()
*/
attribute_deprecated
void av_register_all(void);
attribute_deprecated
void av_register_input_format(AVInputFormat *format);
attribute_deprecated
void av_register_output_format(AVOutputFormat *format);
#endif
What is the correct way to do this ? Should the sample code or the lib be corrected to work right away ?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (5 by maintainers)
Yep. This is a success !
I could also, as planned, remove the
av_register_all()command.I am really disappointed I could not find this phantom instance of ffmpeg inside VLCkit despite all the efforts I made to locate it. The difficulty was increased due to the fact that during development, the IDE pointed to the version 4.3.1 headers…
Anyway, thank you very much for all your help, and I can then happily close this issue, that is not due to SwiftFFmpeg.