标签: libavformat

FFmpeg:av_interleaved_write_frame未检测到TLS输出失败

我如何可以检测从失败av_interleaved_write_frame/ av_write_frame时的输出使用TLS和连接失败?目标变为不可用后,这两个函数将继续返回0.当不使用TLS时,函数立即检测到故障并返回-ve返回码.

TLS输出:

av_interleaved_write_frame st.tb=90000, result=0
Run Code Online (Sandbox Code Playgroud)

非TLS输出:

av_interleaved_write_frame failed result=-32 - Broken pipe
Run Code Online (Sandbox Code Playgroud)

也可以使用命令行工具演示此行为.

普通连接的预期结果 - 连接失败终止程序:

$ ffmpeg -rtsp_transport tcp -i rtsp://<rtsp_source>:554... -vcodec copy -an -f rtsp "rtsp://<rtsp_dest>:1935..."
ffmpeg version N-68044-g9f9440b Copyright (c) 2000-2014 the FFmpeg developers
  built on Nov 27 2014 03:13:44 with gcc 4.9.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora …
Run Code Online (Sandbox Code Playgroud)

ffmpeg libavcodec libavformat

9
推荐指数
0
解决办法
725
查看次数

在.NET中是否有一组用于FFMpeg,libavutil,libavformat和libavcodec的工作P/Invoke声明?

我目前正在寻求从.NET访问libavutil,libavformat和libavcodec(FFMpeg的所有部分).

目前,我正在 Windows 32位每晚执行的共享FFMpeg程序包的自动构建中获取.

我也在使用ffmpeg-sharp项目中的代码.在该项目中,我删除了许多未编译的类(它们是包装类而不是P/Invoke声明).

代码编译得很好,但我遇到了一些问题.

首先,似乎av*.dll的构建使用cdecl调用约定,因为我PInvokeStackImbalanceException在尝试调用时收到了一些av_open_input_file.这很容易改变以使其正常工作.该AVFormatContext结构已填充.

之后,我想调用av_find_stream_info以获取有关文件中的流的信息.但是,当从调用中AVFormatContext检索到调用时av_open_input_file,AccessViolationException会抛出一个指示我正在尝试从受保护的内存中读取或写入的内容.

有没有人使用P/Invoke通过P/Invoke访问libavutil,libavformat和libavcodec dll库并使其工作?

我应该提到使用FFMpeg的命令行版本,虽然解决方案在这种情况下不是可行的解决方案,但是需要通过库进行访问.这样做的原因是我不得不把磁盘方式过多地做我需要做的事情(我必须对一些非常高清晰度的视频进行逐帧分析)并且我想避免磁盘越多越好.

.net ffmpeg libavcodec libavformat

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

使用libavcodec解码音频并使用libAO播放?

我使用以下代码片段来解码音频文件(使用MP3,WAV,WMV测试).

但是当它播放音频时,它只是给出静态声音和时间崩溃.我在这里做错了什么提示?

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>


extern "C" {
#include "libavutil/mathematics.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include <ao/ao.h>

}

void die(const char *msg)
{
    fprintf(stderr,"%s\n",msg);
    exit(1);
}

int main(int argc, char **argv)
{

    const char* input_filename=argv[1];

    //avcodec_register_all();
    av_register_all();
    //av_ini

    AVFormatContext* container=avformat_alloc_context();
    if(avformat_open_input(&container,input_filename,NULL,NULL)<0){
        die("Could not open file");
    }

    if(av_find_stream_info(container)<0){
        die("Could not find file info");
    }
    av_dump_format(container,0,input_filename,false);

    int stream_id=-1;
    int i;
    for(i=0;i<container->nb_streams;i++){
        if(container->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO){
            stream_id=i;
            break;
        }
    }
    if(stream_id==-1){
        die("Could not find Audio Stream");
    }

    AVDictionary *metadata=container->metadata;

    AVCodecContext *ctx=container->streams[stream_id]->codec;
    AVCodec …
Run Code Online (Sandbox Code Playgroud)

c++ ffmpeg libavcodec libav libavformat

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

无法将libavformat/ffmpeg与x264和RTP同步

我一直在研究一些流媒体软件,它使用H.264通过网络从各种摄像机和流中获取实时信息.为了实现这一点,我直接使用x264编码器(带有"zerolatency"预设)并提供NAL,因为它们可用于libavformat以打包到RTP(最终是RTSP).理想情况下,此应用程序应尽可能实时.在大多数情况下,这一直运作良好.

然而不幸的是,存在某种同步问题:客户端上的任何视频回放似乎都显示了一些平滑帧,然后是短暂停顿,然后是更多帧; 重复.此外,似乎有大约4秒的延迟.我尝试过的每一个视频播放器都会出现这种情况:Totem,VLC和基本的gstreamer管道.

我把它煮成了一个小小的测试用例:

#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <x264.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>

#define WIDTH       640
#define HEIGHT      480
#define FPS         30
#define BITRATE     400000
#define RTP_ADDRESS "127.0.0.1"
#define RTP_PORT    49990

struct AVFormatContext* avctx;
struct x264_t* encoder;
struct SwsContext* imgctx;

uint8_t test = 0x80;


void create_sample_picture(x264_picture_t* picture)
{
    // create a frame to store in
    x264_picture_alloc(picture, X264_CSP_I420, WIDTH, HEIGHT);

    // fake image generation
    // disregard how wrong this is; just writing a quick test
    int strides = …
Run Code Online (Sandbox Code Playgroud)

c ffmpeg rtp x264 libavformat

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

如何获取DVD中的标题和章节信息?

我发现很多关于使用ffmpeg创建DVD菜单的问题,但我没有发现任何关于以编程方式访问DVD结构信息的问题.当我使用libav(或FFmpeg)库时,我可以打开DVD映像(iso文件)并访问视频,音频和字幕流.但我找不到任何API.

我可以使用VLC播放器(以及libvlc库)播放视频和查找信息.但我需要在程序上对音频和字幕流进行一些处理.我不想使用像SmartRipper这样的工具拆分VOB,然后才进行处理.

libav(ffmpeg)是否包含用于处理DVD菜单的任何API?如果没有,您能否推荐任何其他库,可用于获取有关标题(章节)开始和结束时间的信息,一帧(样本,AVPacket)准确度?

我听说过libdvdnav库,但我不知道它是否适合我.我是libav和DVD格式内部的新手.

ffmpeg libavcodec libav libavformat

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

解码MP3,然后增加音量,然后编码新音频

我想首先解码MP3音频文件,然后增加音频的音量,然后再将其编码为新的MP3文件.我想为此使用libavformat或libavcodec.你能帮我解决这个问题吗?任何例子?

ffmpeg libavcodec libav libavformat

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

av_register_all()与avcodec_register()

而不是调用av_register_all(),是否有一个选择使用单个解码器的例子?我想我必须调用avcodec_register(),av_register_codec_parser()等...

问题是,应该调用哪些函数,因为如果我不使用av_register_all(),av_open_input_file()将失败-2.

libavcodec libavformat

7
推荐指数
1
解决办法
5916
查看次数

使用 libavcodec 编码视频时比特率极高

我正在尝试捕获相机输出并使用 libavcodec 制作视频。作为如何完成此操作的示例,我使用了ffmpeg muxing 示例

问题是 4 秒视频的大小为 ~15mb,比特率为 ~30000 kb/s,尽管我已将 AVCodecContext 上的比特率设置为 400000(我认为该值以比特/秒为单位,而不是 kb/s) .

我还尝试从命令行使用 ffmpeg 录制视频,它的比特率约为 700 kb/s。

有人知道为什么不保留比特率从而导致生成的文件非常大吗?我用来初始化编解码器上下文的代码如下:

初始化部分:

avformat_alloc_output_context2(&m_formatContext, NULL, NULL, filename);
outputFormat = m_formatContext->oformat;

codec = avcodec_find_encoder(outputFormat->video_codec);

m_videoStream = avformat_new_stream(m_formatContext, codec);

m_videoStream->id = m_formatContext->nb_streams - 1;

codecContext = m_videoStream->codec;

codecContext->codec_id = outputFormat->video_codec;

codecContext->width = m_videoResolution.width();
codecContext->height = m_videoResolution.height();

int m_bitRate = 400000;
codecContext->bit_rate = m_bitRate;
codecContext->rc_min_rate = m_bitRate;
codecContext->rc_max_rate = m_bitRate;
codecContext->bit_rate_tolerance = 0;

codecContext->time_base.den = 20;
codecContext->time_base.num = 1;

codecContext->pix_fmt = …
Run Code Online (Sandbox Code Playgroud)

ffmpeg libavcodec libav libavformat

7
推荐指数
1
解决办法
2310
查看次数

未定义的avcodec_alloc_context参考但ffmpeg链接器顺序是否正确?

我想构建静态链接到libavcodec和libavformat的静态链接可执行文件.静态ffmpeg库是用以下代码构建的:

./configure --enable-static --enable-gpl --enable-nonfree --disable-vaapi 
     --disable-libopus --prefix=myBuild --disable-swresample
Run Code Online (Sandbox Code Playgroud)

接头设置如下:

g++ -O2 -static -o myBin myBin-myBin.o someotherlibraries.a 
     -L/ffmpeg/myBuild/lib -lavformat -lavcodec -lavutil  -lrt -lm -lpthread -lz
Run Code Online (Sandbox Code Playgroud)

编译时,我收到一条错误消息>: - /

src/ffmpeg/myProgram.cpp:115: error: undefined reference to 'avcodec_alloc_context'
Run Code Online (Sandbox Code Playgroud)

输出nm /ffmpeg/myBuild/lib/libavcodec.a | grep avcodec_alloc_context:

         U avcodec_alloc_context3
         U avcodec_alloc_context3
000003c0 T avcodec_alloc_context3
         U avcodec_alloc_context3
Run Code Online (Sandbox Code Playgroud)

我包含带有extern"C"{}的libavcodec.h,我相信我的静态链接器顺序是正确的.为什么我会收到此错误?是因为这个方法已被弃用了吗?我怎么解决这个问题?

解:

不要用

avCtx = avcodec_alloc_context()
Run Code Online (Sandbox Code Playgroud)

从可能较旧的代码片段,但使用

codec = avcodec_find_decoder(CODEC_ID_XYZ);//for completeness but should be the same as before
avCtx = avcodec_alloc_context3(codec)
Run Code Online (Sandbox Code Playgroud)

c++ ffmpeg static-linking libavcodec libavformat

7
推荐指数
1
解决办法
5871
查看次数

是否有适用于Linux的MS-DRM客户端库?

我已经使用库(libavformat和libavcodec)来解码一些MMS流媒体网址.但其中一些受DRM保护.当我尝试解码它们时,库会警告它

在libavformat/asfdec.c中:

if (!s->keylen) {
    if (!guidcmp(&g, &ff_asf_content_encryption)) {
        av_log(s, AV_LOG_WARNING, "DRM protected stream detected, decoding will likely fail!\n");
    } else if (!guidcmp(&g, &ff_asf_ext_content_encryption)) {
        av_log(s, AV_LOG_WARNING, "Ext DRM protected stream detected, decoding will likely fail!\n");
    } else if (!guidcmp(&g, &ff_asf_digital_signature)) {
        av_log(s, AV_LOG_WARNING, "Digital signature detected, decoding will likely fail!\n");
    }
}
Run Code Online (Sandbox Code Playgroud)

变量s是struct AVFormatContext.我的问题是从哪里拿到钥匙?它似乎用DRM密钥解码它.


我查看ASF规范,并尝试修补asfdec.c.现在,我有获取许可证URL和密钥ID.问题可以改写为"是否有适用于Linux的MS-DRM客户端库?" (旧:如何通过ffmpeg解码带有DRM的MMS流媒体网址?)

是否可以使用许可证URL和密钥ID来获取内容密钥?

drm ffmpeg mms libavformat

6
推荐指数
1
解决办法
2994
查看次数

标签 统计

libavformat ×10

ffmpeg ×9

libavcodec ×8

libav ×4

c++ ×2

.net ×1

c ×1

drm ×1

mms ×1

rtp ×1

static-linking ×1

x264 ×1