av_strerror returns "Error number -22 occurred" ?

For the developers that use FFmpeg in their software.
Post Reply
Posts: 1
Joined: Thu Jul 12, 2012 1:37 pm

av_strerror returns "Error number -22 occurred" ?

Post by ErikKo »


I'm currently trying to use ffmpeg for on-the-fly transcoding for a upnp media server. However, I can not get ffmpeg to work. Relevant code has been posted below.

I first create tmpBuf using av_malloc, and read the first part of the file to tmpBuf. (buflen = 1024*1024). After this I create the AVFormatContext and AVIOContext as the API tells me to. Next I put the AVIOContext in the AVFormatContext (s->pb = io;). When I run avformat_open_input on the AVFormatContext, it returns the code '-22' in ret. When I run av_strerror on it, I get the message "Error number -22 occurred", which is obviously no help. Googling the exact error message is no help either. Any clue as to what I'm doing wrong or what the error means?

Code: Select all


unsigned char* tmpBuf = (unsigned char*)av_malloc(sizeof(unsigned char)*(buflen));
_read(file->detail.local.mediafd, tmpBuf, buflen);

AVFormatContext *s = avformat_alloc_context();
if (!s)
AVIOContext *io = avio_alloc_context(tmpBuf, buflen, 1, (void*)file, dummyCallbackRead, NULL, dummyCallbackSeek);
if (!io)
s->pb = io;

int ret = avformat_open_input(&s, "dummyfile", NULL, NULL);
char* error = (char*)malloc(1024);
wchar_t error2[1024];
if (ret < 0)
	av_strerror(ret, error, 1024);
	printf("%s\n", error);
	wprintf(L"%s\n", error2);

Code: Select all

int dummyCallbackRead(void* opaque, unsigned char* buf, int buflen)
	struct web_file_t *file = (struct web_file_t *) opaque;
	_read(file->detail.local.mediafd, buf, buflen);
	return 0;

Posts: 1881
Joined: Fri Aug 05, 2011 9:56 pm

Re: av_strerror returns "Error number -22 occurred" ?

Post by rogerdpack »

I'd ping the libav-user group...

Post Reply