FFMPEG读取内存中的h264数据进行推流

 序言

    本实例是通过将本地的h264文件数据读取到内存中,再将该内存中h264数据进行rtmp推流。

 

#include <stdio.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C"
{
#endif

#include "libavformat/avformat.h"
#include "libavutil/mathematics.h"
#include "libavutil/time.h"
#include "libavutil/mathematics.h"

#ifdef __cplusplus

};
#endif
#define BUF_SIZE 3110400
FILE* pfile;

int read_packet(void *opaque,uint8_t *buf,int buf_size)
{
    printf("in read_packet\n");
    if(!feof(pfile)){
        int n = fread(buf,1,buf_size,pfile);
        printf("n= %d\n",n);
        return n;
    }
    else
    {
        printf("read failed\n");
        return -1;
    }
}

static double r2d(AVRational r)
{
    return r.num == 0 || r.den == 0 ? 0. : (double)r.num/(double)r.den;
}

int main()
{
    av_register_all();
    avformat_network_init();
    
    pfile
  • 3
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值