小编Sea*_*ean的帖子

检测ffmpeg中的超时

我正在编写一些广泛使用ffmpeg的软件,它是多线程的,具有多个类实例.

如果网络连接中断,ffmpeg会在读取时挂起.我找到了一个方法来分配一个ffmpeg定期触发的回调,以检查它是否应该中止:

static int interrupt_cb(void *ctx) 
{ 

// do something 
    return 0;
} 

static const libffmpeg::AVIOInterruptCB int_cb = { interrupt_cb, NULL }; 
Run Code Online (Sandbox Code Playgroud)

...

AVFormatContext* formatContext = libffmpeg::avformat_alloc_context( );
formatContext->interrupt_callback = int_cb; 
if ( libffmpeg::avformat_open_input( &formatContext, fileName, NULL, NULL ) !=0 ) {...}
Run Code Online (Sandbox Code Playgroud)

这一切都很好,但在网上无处可以找到*ctx包含的内容以及如何确定回调是否应返回1或0.我无法分配静态"abort"标志,因为该类有许多实例.我也无法调试代码因为某些原因,visual studio拒绝在返回0上设置断点; 声明没有可执行代码与该位置相关联.有任何想法吗?

c++ ffmpeg

8
推荐指数
1
解决办法
9218
查看次数

如何从401服务器错误中获取标头

我正在编写一个端口扫描程序来检测在本地网络上运行的Web服务.其中一些Web服务需要基本身份验证 - 我不知道这些服务的用户名/密码,我只想列出它们,所以我不能在此阶段提供凭据.我正在使用代码:

                    var request = (HttpWebRequest)WebRequest.Create("http://" + req);
                    request.Referer = "";
                    request.Timeout = 3000;
                    request.UserAgent = "Mozilla/5.0";
                    request.AllowAutoRedirect = false;
                    request.Method = WebRequestMethods.Http.Head;

                    HttpWebResponse response = null;

                    try
                    {
                        response = (HttpWebResponse) request.GetResponse();
                        // I want to parse the headers here for the server name but as the exception is thrown the response object is null.

                    }
                    catch (Exception ex)
                    {
                        //401 error is caught here - response is null
                    }
Run Code Online (Sandbox Code Playgroud)

我再从返回的报头解析出服务器的名称 - 我知道他们正在返回,因为我可以看到他们与小提琴手,但HttpWebResponse对象设置为null作为的GetResponse()方法抛出异常.基本上 - 我如何让它不抛出异常但返回标题以及状态代码401.

.net c# httpwebrequest

5
推荐指数
1
解决办法
1917
查看次数

使用FFMPEG编码H264时如何转储缓冲区?

我正在使用c ++库将从网络摄像头捕获的图像写入libx264编码的mp4文件.编码工作正常,但启动时会向缓冲区写入40帧.当我关闭文件时,这些帧没有被刷新,因此大约6秒的视频未被写入(凸轮大约是6fps).

所以我打电话给:

out_size = libffmpeg::avcodec_encode_video( codecContext, data->VideoOutputBuffer,data->VideoOutputBufferSize, data->VideoFrame );

// if zero size, it means the image was buffered
if ( out_size > 0 )
{
//... write to file
}
Run Code Online (Sandbox Code Playgroud)

我看不到访问缓冲区中剩余图像的方法.有任何想法吗?

c++ buffer ffmpeg h.264

4
推荐指数
1
解决办法
4321
查看次数

如何获取正在运行的进程的ExitCode

我正在编写一个应用程序来检查另一个应用程序的退出代码.我正在监视的应用程序可能已在运行,因此我正在使用Process.GetProcessesByName检查它.如果它存在,我在调用WaitForExit后检查退出代码,但是当我这样做时,我得到一个异常:

"此过程未启动过程,因此无法确定所请求的信息."

如果我启动进程(如果它还没有运行)那么它不会给我异常.

(Windows 8.1)

那么当我没有开始这个过程时,如何找出ExitCode是什么?我能想到的唯一选择是在退出时将输出代码写入文本文件并在...中读取它

c# process visual-studio

4
推荐指数
1
解决办法
3194
查看次数

标签 统计

c# ×2

c++ ×2

ffmpeg ×2

.net ×1

buffer ×1

h.264 ×1

httpwebrequest ×1

process ×1

visual-studio ×1