avformat_open_input导致RTP流打开时出现异常

时间:2014-02-07 14:06:06

标签: c++ visual-studio-2010 ffmpeg

我正在尝试编写RTP流的视频播放器。我正在使用visual studio 2010.执行avformat_open_input命令时会生成异常(ntdll.dll!774b70f4())。它适用于来自磁盘的普通文件(test.avi)。

#include "stdafx.h"
#include <stdio.h>

//zeranoe headers and libraries(DLLs also from zeranoe)
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}

#pragma comment(lib, "avcodec.lib")
#pragma comment(lib, "avformat.lib")

int _tmain(int argc, _TCHAR* argv[])
{
    AVFormatContext *pFormatCtx=NULL;
    //char* Filename="c:\\test.avi"; //if I use this there is no crash
    char* Filename="rtp://239.255.42.42:5004";//if I use rtp I receive exception
    int videoStream,i;
    AVCodec         *pCodec=NULL;
    AVCodecContext  *pCodecCtx=NULL;

    avcodec_register_all(); 
    av_register_all();
    avformat_network_init();

    unsigned int _expTime = 5000;
    static const AVIOInterruptCB int_cb = {interrupt_cb, &_expTime};


    // Open video file
    if(avformat_open_input(&pFormatCtx, Filename , NULL,NULL)!=0)//ntdll.dll exception when I try to open rtp stream
    return -1; // Couldn't open file

有人能帮助我吗?

1 个答案:

答案 0 :(得分:-1)

在avformat_open_input

之前尝试此操作

pFormatCtx = avformat_alloc_context();