FFMPEG错误,avformat_open_input返回-135 [英] FFMPEG error with avformat_open_input returning -135

查看:3032
本文介绍了FFMPEG错误,avformat_open_input返回-135的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DLL,我的应用程序使用从RTSP摄像机接收视频。在引擎盖下,DLL使用此版本zip的FFMPEG库:

  ffmpeg-20141022-git-6dc99fd-win64-shared。 7z 

我们在家里有各种各样的相机,大多数工作很好。但是,在一个特定的Pelco型号:IXE20DN-OCP,我无法连接。我在VLC上测试了摄像机和rtsp连接字符串,它连接到摄像机。



我在这里找到了连接字符串: http://www.ispyconnect.com/man.aspx?n=Pelco

  rtsp:// IPADDRESS:554/1 / stream1 

奇怪的是,即使我离开VLC端口,它连接,所以我猜它的默认RTSP端口或VLC尝试各种各样的事情,基于您的输入。



在任何情况下,当我尝试连接,我从av_format_open_input错误。它返回一个-135的代码。当我看错误代码列表我没有看到列出。为了良好的测量,我打印出所有错误error.h只是为了看看他们的值是什么。

  DumpErrorCodes  - 错误代码:AVERROR_BSF_NOT_FOUND = -1179861752 
DumpErrorCodes - 错误代码:AVERROR_BUG = -558323010
DumpErrorCodes - 错误代码:AVERROR_BUFFER_TOO_SMALL = -1397118274
DumpErrorCodes - 错误代码:AVERROR_DECODER_NOT_FOUND = -1128613112
DumpErrorCodes - 错误代码:AVERROR_DEMUXER_NOT_FOUND = -1296385272
DumpErrorCodes - 错误代码:AVERROR_ENCODER_NOT_FOUND = -1129203192
DumpErrorCodes - 错误代码:AVERROR_EOF = -541478725
DumpErrorCodes - 错误代码:AVERROR_EXIT = -1414092869
DumpErrorCodes - 错误代码:AVERROR_EXTERNAL = -542398533
DumpErrorCodes - 错误代码:AVERROR_FILTER_NOT_FOUND = -1279870712
DumpErrorCodes - 错误代码:AVERROR_INVALIDDATA = -1094995529
DumpErrorCodes - 错误代码:AVERROR_MUXER_NOT_FOUND = -1481985528
DumpErrorCodes - 错误代码:AVERROR_OPTION_NOT_FOUND = -1414549496
DumpErrorCodes - 错误代码:AVERROR_PATCHWELCOME = -1163346256
DumpErrorCodes - 错误代码:AVERROR_PROTOCOL_NOT_FOUND = -1330794744
DumpErrorCodes - 错误代码:AVERROR_STREAM_NOT_FOUND = -1381258232
DumpErrorCodes - 错误代码:AVERROR_BUG2 = -541545794
DumpErrorCodes - 错误代码:AVERROR_UNKNOWN = -1313558101
DumpErrorCodes - 错误代码:AVERROR_EXPERIMENTAL = -733130664
DumpErrorCodes - 错误代码:AVERROR_INPUT_CHANGED = -1668179713
DumpErrorCodes - 错误代码:AVERROR_OUTPUT_CHANGED = -1668179714
DumpErrorCodes - 错误代码:AVERROR_HTTP_BAD_REQUEST = -808465656
DumpErrorCodes - 错误代码:AVERROR_HTTP_UNAUTHORIZED = -825242872
DumpErrorCodes - 错误代码: AVERROR_HTTP_FORBIDDEN = -858797304
DumpErrorCodes - 错误代码:AVERROR_HTTP_NOT_FOUND = -875574520
DumpErrorCodes - 错误代码:AVERROR_HTTP_OTHER_4XX = -1482175736
DumpErrorCodes - 错误代码:AVERROR_HTTP_SERVER_ERROR = -1482175992

甚至没有接近-135。我发现这个错误,堆栈溢出,这里运行时在qt creator中链接ffmpeg库时出现错误,其中作者声称它是一个DLL加载问题错误。我不知道是什么导致他认为,但我遵循的建议,并使用依赖者步行者( http:// www .dependencywalker.com / )来检查它认为我的DLL需要什么依赖。它列出了一些,但它们已经在我的安装包中提供。



为了确保它被拾起,我手动删除它们从安装和观察到一个激进程序行为的改变(这是我的DLL没有加载并开始运行)。



所以,我有一些init代码:

  void FfmpegInitialize()
{
av_lockmgr_register(& LockManagerCb);
av_register_all();
LOG_DEBUG0(av_register_all returned\\\
);
}

然后我有我的主要开放连接例程...

  int RTSPConnect(const char * URL,int width,int height,frameReceived callbackFunction)
{

int errCode = 0;
if((errCode = avformat_network_init())!= 0)
{
LOG_ERROR1(avformat_network_init returned error code%d\\\
,errCode);
}
LOG_DEBUG0(avformat_network_init returned\\\
);
//分配空间并设置用于存储此连接所需的所有信息的对象
fContextReadFrame = avformat_alloc_context(); //在Close方法中释放

if(fContextReadFrame == 0)
{
LOG_ERROR1(无法设置rtsp_transport选项,错误代码=%d\\\
,errCode);
return FFMPEG_OPTION_SET_FAILURE;
}

LOG_DEBUG1(avformat_alloc_context returned%p \\\
,fContextReadFrame);

AVDictionary * opts = 0;
if((errCode = av_dict_set(& opts,rtsp_transport,tcp,0))< 0)
{
LOG_ERROR1(无法设置rtsp_transport选项。 =%d\\\
,errCode);
return FFMPEG_OPTION_SET_FAILURE;
}
LOG_DEBUG1(av_dict_set returned%d\\\
,errCode);

//打开rtsp
DumpErrorCodes();
if((errCode = avformat_open_input(& fContextReadFrame,URL,NULL,& opts))< 0)
{
LOG_ERROR2(无法打开avFormat RF输入,URL = s,and Error code =%d\\\
,URL,errCode);
LOG_ERROR2(错误代码%d =%s\\\
,errCode,errMsg(errCode));
//注意上下文在失败时是免费的。
return FFMPEG_FORMAT_OPEN_FAILURE;
}
...

为了确保我没有误解错误代码我打印了来自ffmpeg的错误消息,但未找到错误,并返回我的预设错误消息。



我的下一步将要挂接wireshark在我的连接尝试和VLC连接尝试,并试图找出什么区别(如果有)是导致问题,我可以做什么ffmpeg使其工作。正如我所说,我有十几个其他相机在内部使用RTSP和他们使用我的DLL。有些利用用户名/密码/等(所以我知道这不是问题)。



此外,我的运行日志:

  FfmpegInitialize  -  av_register_all返回
打开 - 打开调用。指针有效,传递控制。
Rtsp :: RtspInterface :: Open - Rtsp :: RtspInterface :: Open called
Rtsp :: RtspInterface :: Open - VideoSourceString(35)= rtsp://192.168.14.60:554/1 / stream1
Rtsp :: RtspInterface :: Open - Base URL =(192.168.14.60:554/1/stream1)
Rtsp :: RtspInterface :: Open - 尝试打开(rtsp://192.168.14.60: 554/1 / stream1)用于WxH(320x240)视频
RTSPSetFormatH264 - RTSPSetFormatH264
RTSPConnect - 调用
LockManagerCb - 为操作1调用的LockManagerCb
LockManagerCb - LockManagerCb为op 2 $ b调用$ b RTSPConnect - avformat_network_init返回
RTSPConnect - avformat_alloc_context返回019E6000
RTSPConnect - av_dict_set返回0
DumpErrorCodes - 错误代码:AVERROR_BSF_NOT_FOUND = -1179861752
...
DumpErrorCodes - 错误代码:AVERROR_HTTP_SERVER_ERROR = -1482175992
RTSPConnect - 无法打开avFormat RF输入。 URL = rtsp://192.168.14.60:554/1 / stream1和错误代码= -135
RTSPConnect - 错误代码-135 =没有错误消息可用
pre>

我要继续使用wireshark,但想知道ffmpeg的-135错误代码的来源。当我看看代码,如果'ret'被设置为-135,它必须发生作为来自辅助方法的返回代码的结果,而不是直接在 avformat_open_input 方法。



https://www.ffmpeg .org / doxygen / 2.5 / libavformat_2utils_8c_source.html#l00398



升级到最新的每日ffmpeg版本后,我收到了wireshark上的数据。实时流协议:

 请求:SETUP rtsp://192.168.14.60/stream1/track1 RTSP / 1.0\r\\ \\ n 
方法:SETUP
URL:rtsp://192.168.14.60/stream1/track1
传输:RTP / AVP / TCP; unicast; interleaved = 0-1
CSeq :3\r\\\

User-Agent:Lavf56.31.100\r\\\

\r\\\

对此的响应是我在启动中可以检测到的第一个错误。

 响应:RTSP / 1.0 461不支持的传输\r\\\

状态:461
CSeq:3 \r\\\

日期:Sun,Jan 04 1970 16:03:05 GMT\r\\\

\r\\\

我要猜测...这意味着我们选择的运输不受支持。我快速检查代码揭示我选择'tcp'。查看对DESCRIBE命令的回复,它出现:

 媒体协议:RTP / AVP 

此外,当ffmpeg发出SETUP时,它指定:

 传输:RTP / AVP / TCP; unicast; interleaved = 0-1 

我要尝试,失败这里选择另一种传输类型,看看它是如何工作的。仍然不知道-135来自哪里。

解决方案

解决方案原来是这个特定的相机没有支持通过TCP传输的RTSP。它想要UDP。



我更新到代码尝试TCP,如果失败,使用一组备用的选项为UDP和另一个调用尝试打开的东西。

  if((errCode = av_dict_set(& opts,rtsp_transport,udp,0))< 0)

像一个魅力。仍然关注的是-135和-22错误代码的原因,没有出现在error.h文件中。可能是一个ffmpeg错误,允许通过错误错误代码。


I have a DLL one of my applications uses to receive video from RTSP cameras. Under the hood, the DLL uses FFMPEG libs from this release zip :

ffmpeg-20141022-git-6dc99fd-win64-shared.7z

We have a wide variety of cameras in house and most of them work just fine. However, on one particular Pelco Model Number: IXE20DN-OCP, I am unable to connect. I tested the camera and rtsp connection string on VLC and it connects to the camera just fine.

I found the connection string here : http://www.ispyconnect.com/man.aspx?n=Pelco

rtsp://IPADDRESS:554/1/stream1

Oddly, even if I leave the port off of VLC, it connects, so I'm guessing its the default RTSP port or that VLC tries a variety of things based on your input.

In any case, when I attempt to connect, I get an error from av_format_open_input. It returns a code of -135. When I looked in the error code list I didn't see that listed. For good measure, I printed out all the errors in error.h just to see what their values were.

DumpErrorCodes - Error Code : AVERROR_BSF_NOT_FOUND = -1179861752
DumpErrorCodes - Error Code : AVERROR_BUG = -558323010
DumpErrorCodes - Error Code : AVERROR_BUFFER_TOO_SMALL = -1397118274
DumpErrorCodes - Error Code : AVERROR_DECODER_NOT_FOUND = -1128613112
DumpErrorCodes - Error Code : AVERROR_DEMUXER_NOT_FOUND = -1296385272
DumpErrorCodes - Error Code : AVERROR_ENCODER_NOT_FOUND = -1129203192
DumpErrorCodes - Error Code : AVERROR_EOF = -541478725
DumpErrorCodes - Error Code : AVERROR_EXIT = -1414092869
DumpErrorCodes - Error Code : AVERROR_EXTERNAL = -542398533
DumpErrorCodes - Error Code : AVERROR_FILTER_NOT_FOUND = -1279870712
DumpErrorCodes - Error Code : AVERROR_INVALIDDATA = -1094995529
DumpErrorCodes - Error Code : AVERROR_MUXER_NOT_FOUND = -1481985528
DumpErrorCodes - Error Code : AVERROR_OPTION_NOT_FOUND = -1414549496
DumpErrorCodes - Error Code : AVERROR_PATCHWELCOME = -1163346256
DumpErrorCodes - Error Code : AVERROR_PROTOCOL_NOT_FOUND = -1330794744
DumpErrorCodes - Error Code : AVERROR_STREAM_NOT_FOUND = -1381258232
DumpErrorCodes - Error Code : AVERROR_BUG2 = -541545794
DumpErrorCodes - Error Code : AVERROR_UNKNOWN = -1313558101
DumpErrorCodes - Error Code : AVERROR_EXPERIMENTAL = -733130664
DumpErrorCodes - Error Code : AVERROR_INPUT_CHANGED = -1668179713
DumpErrorCodes - Error Code : AVERROR_OUTPUT_CHANGED = -1668179714
DumpErrorCodes - Error Code : AVERROR_HTTP_BAD_REQUEST = -808465656
DumpErrorCodes - Error Code : AVERROR_HTTP_UNAUTHORIZED = -825242872
DumpErrorCodes - Error Code : AVERROR_HTTP_FORBIDDEN = -858797304
DumpErrorCodes - Error Code : AVERROR_HTTP_NOT_FOUND = -875574520
DumpErrorCodes - Error Code : AVERROR_HTTP_OTHER_4XX = -1482175736
DumpErrorCodes - Error Code : AVERROR_HTTP_SERVER_ERROR = -1482175992

Nothing even close to -135. I did find this error, sort of on stack overflow, here runtime error when linking ffmpeg libraries in qt creator where the author claims it is a DLL loading problem error. I'm not sure what led him to think that, but I followed the advice and used the dependency walker (http://www.dependencywalker.com/) to checkout what dependencies it thought my DLL needed. It listed a few, but they were already provided in my install package.

To make sure it was picking them up, I manually removed them from the install and observed a radical change in program behavior(that being my DLL didn't load and start to run at all).

So, I've got a bit of init code :

void FfmpegInitialize()
{
 av_lockmgr_register(&LockManagerCb);
 av_register_all();
 LOG_DEBUG0("av_register_all returned\n");
}

Then I've got my main open connection routine ...

int RTSPConnect(const char *URL, int width, int height, frameReceived callbackFunction)
{

    int errCode =0;
    if ((errCode = avformat_network_init()) != 0)
    {
        LOG_ERROR1("avformat_network_init returned error code %d\n", errCode);  
    }
    LOG_DEBUG0("avformat_network_init returned\n");
    //Allocate space and setup the the object to be used for storing all info needed for this connection
    fContextReadFrame = avformat_alloc_context(); // free'd in the Close method

    if (fContextReadFrame == 0)
    {
        LOG_ERROR1("Unable to set rtsp_transport options.   Error code = %d\n", errCode);
        return FFMPEG_OPTION_SET_FAILURE;
    }

    LOG_DEBUG1("avformat_alloc_context returned %p\n", fContextReadFrame);

    AVDictionary *opts = 0;
    if ((errCode = av_dict_set(&opts, "rtsp_transport", "tcp", 0)) < 0)
    {
        LOG_ERROR1("Unable to set rtsp_transport options.   Error code = %d\n", errCode);
        return FFMPEG_OPTION_SET_FAILURE;
    }
    LOG_DEBUG1("av_dict_set returned %d\n", errCode);

    //open rtsp
    DumpErrorCodes();
    if ((errCode = avformat_open_input(&fContextReadFrame, URL, NULL, &opts)) < 0)
    {
        LOG_ERROR2("Unable to open avFormat RF inputs.   URL = %s, and Error code = %d\n", URL, errCode);       
        LOG_ERROR2("Error Code %d = %s\n", errCode, errMsg(errCode));       
        // NOTE context is free'd on failure.
        return FFMPEG_FORMAT_OPEN_FAILURE;
    }
...

To be sure I didn't misunderstand the error code I printed the error message from ffmpeg but the error isn't found and my canned error message is returned instead.

My next step was going to be hooking up wireshark on my connection attempt and on the VLC connection attempt and trying to figure out what differences(if any) are causing the problem and what I can do to ffmpeg to make it work. As I said, I've got a dozen other cameras in house that use RTSP and they work with my DLL. Some utilize usernames/passwords/etc as well(so I know that isn't the problem).

Also, my run logs :

FfmpegInitialize - av_register_all returned
Open - Open called.  Pointers valid, passing control.
Rtsp::RtspInterface::Open - Rtsp::RtspInterface::Open called
Rtsp::RtspInterface::Open - VideoSourceString(35) = rtsp://192.168.14.60:554/1/stream1
Rtsp::RtspInterface::Open - Base URL = (192.168.14.60:554/1/stream1)
Rtsp::RtspInterface::Open - Attempting to open (rtsp://192.168.14.60:554/1/stream1) for WxH(320x240) video
RTSPSetFormatH264 - RTSPSetFormatH264
RTSPConnect - Called
LockManagerCb - LockManagerCb invoked for op 1
LockManagerCb - LockManagerCb invoked for op 2
RTSPConnect - avformat_network_init returned
RTSPConnect - avformat_alloc_context returned 019E6000
RTSPConnect - av_dict_set returned 0
DumpErrorCodes - Error Code : AVERROR_BSF_NOT_FOUND = -1179861752
...
DumpErrorCodes - Error Code : AVERROR_HTTP_SERVER_ERROR = -1482175992
RTSPConnect - Unable to open avFormat RF inputs.   URL = rtsp://192.168.14.60:554/1/stream1, and Error code = -135
RTSPConnect - Error Code -135 = No Error Message Available

I'm going to move forward with wireshark but would like to know the origin of the -135 error code from ffmpeg. When I look at the code if 'ret' is getting set to -135, it must be happening as a result of the return code from a helper method and not directly in the avformat_open_input method.

https://www.ffmpeg.org/doxygen/2.5/libavformat_2utils_8c_source.html#l00398

After upgrading to the latest daily ffmpeg build, I get data on wireshark. Real Time Streaming Protocol :

Request: SETUP rtsp://192.168.14.60/stream1/track1 RTSP/1.0\r\n
Method: SETUP
URL: rtsp://192.168.14.60/stream1/track1
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
CSeq: 3\r\n
User-Agent: Lavf56.31.100\r\n
\r\n

The response to that is the first 'error' that I can detect in the initiation.

Response: RTSP/1.0 461 Unsupported Transport\r\n
Status: 461
CSeq: 3\r\n
Date: Sun, Jan 04 1970 16:03:05 GMT\r\n
\r\n

I'm going to guess that... it means the transport we selected was unsupported. I quick check of the code reveals I picked 'tcp'. Looking through the reply to the DESCRIBE command, it appears :

Media Protocol: RTP/AVP

Further, when SETUP is issued by ffmpeg, it specifies :

Transport: RTP/AVP/TCP;unicast;interleaved=0-1

I'm going to try, on failure here to pick another transport type and see how that works. Still don't know where the -135 comes from.

解决方案

The solution turned out to be that this particular camera didn't support RTSP over TCP transport. It wanted UDP.

I updated to code to try TCP and if that failed, to use an alternate set of options for UDP and another call to try an open things up.

if ((errCode = av_dict_set(&opts, "rtsp_transport", "udp", 0)) < 0)

Works like a charm. Still concerned about the origin of the -135 and -22 error codes which don't appear in the error.h file. Maybe an ffmpeg bug where a stray error code is allowed through.

这篇关于FFMPEG错误,avformat_open_input返回-135的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆