Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg avformat_open_input always returns "Protocol not found" rv=(-1330794744)

Trying to get ffmpeg working in Visual Studio 2010. So far all ffmpeg headers and libs are loaded, no error or warning occurs.

avcodec_register_all();
AVFormatContext *pFormatCtx = NULL;
char errbuf[256];
pFormatCtx = avformat_alloc_context();
int rv = avformat_open_input(&pFormatCtx, "myfile.ext", NULL, NULL);
if (rv!=0){                              
    av_strerror(rv, errbuf, sizeof(errbuf));
}

The problem is, avformat_open_input always returning -1330794744 (errbuf="Protocol not found"). Tried x86 & x64 headers and libs on 32bit XP and 64bit W7. Whatever I put for "myfile.ext" (tried "file1.avi", "file=c:\file1.avi", "http://www.someweb.com/file1.avi", and even empty char* "") response is always "Protocol not found". Any ideas?

like image 716
bzivkovic Avatar asked Feb 16 '13 20:02

bzivkovic


2 Answers

I was having the same problem. The correct initialization is

av_register_all();
like image 192
discomurray Avatar answered Oct 16 '22 17:10

discomurray


I hope that his can help someone. Since I had the same problem where my code worked on Android and Linux but not on macOS and since av_register_all is now deprecated (for FFMpeg version > 4.0) the answer from discomurray didn't solve the problem for me.

The reason why it didn't work in my case was that I already had libavformat installed on my system which was under /usr/local/lib/ and unfortunately it was not configured correctly for my case (or mismatched the version compared to one I compiled myself).

What I did is, I added the path to my build to DYLD_LIBRARY_PATH (macOS) before executing the command:

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Users/xxx/projects/FFmpeg/libavformat

On linux you can do the same with LD_LIBRARY_PATH

like image 1
Dimitri Podborski Avatar answered Oct 16 '22 17:10

Dimitri Podborski