I have an application that successfully streams video using rtp. I have found
that on certain computers the function av_open_input_file() fails with return
value -22 EINVAL (invalid argument). I have created a very simple test app
(below) which demonstrates this. It runs on some windows machines and not on
others (e.g. 2 XP machines are fine, 1 XP laptop not, 1 Win7 32bit laptop fine
another not).
Does anyone have any insight into what the problem may be?
Also note if I replace filename with the path to an avi file it always works on
any machine. So it seems some machines don’t like the sdp file.
Thanks.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Required to use libs on windows
#define __STDC_CONSTANT_MACROS
#define inline _inline
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
extern "C"
{
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
//#include "libswscale/swscale.h"
}
bool CreateSdpFile();
AVFormatContext* pFormatCtx = NULL;
bool CreateSdpFile()
{
FILE *pFile = fopen ("C:\\FFMpegTest\\MP4.sdp","w");
if (pFile)
{
fprintf (pFile, "v=0\n");
fprintf (pFile, "o=- 0 0 IN IP4 127.0.0.1\n");
fprintf (pFile, "s=No Name\n");
fprintf (pFile, "c=IN IP4 192.168.123.26\n");
fprintf (pFile, "t=0 0\n");
fprintf (pFile, "a=tool:libavformat 52.104.0\n");
fprintf (pFile, "m=video 5004 RTP/AVP 96\n");
fprintf (pFile, "b=AS:1228\n");
fprintf (pFile, "a=rtpmap:96 MP4V-ES/90000\n");
fprintf (pFile, "a=fmtp:96 profile-level-id=1\n");
if (fclose (pFile) != 0)
{
printf("dp close failed\n");
// AfxMessageBox("sdp close failed",MB_OK| MB_ICONSTOP);
}
}
return true;
}
#undef exit
int main()
{
CreateSdpFile();
AVCodec *pCodec;
int numBytes;
int avError;
char* filename = "C:\\FFMpegTest\\MP4.sdp";
//char* filename = "C:\\ABTmp\\vid.avi";
av_register_all();
avError = av_open_input_file(&pFormatCtx, filename, NULL, 0, NULL);
if(avError)
{
printf("Stream init error, could not open input file, %d\n", avError);
}
}
_______________________________________________
libav-api mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-api