资源简介
ffmpeg转码为hls的代码,里面涉及具体的转码流程以及参数设置.ffmpeg转码为hls的代码,里面涉及具体的转码流程以及参数设置
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define BUF_SIZE_20K 2048000
#define BUF_SIZE_1K 1024000
static AVFormatContext *ifmt_ctx;
static AVFormatContext *ofmt_ctx;
static SwrContext* pSwrCtx = NULL;
AVBitStreamFilterContext* aacbsfc = NULL;
void initSwr(int audio_index)
{
if (ofmt_ctx->streams[0]->codec->channels != ifmt_ctx->streams[audio_index]->codec->channels
|| ofmt_ctx->streams[0]->codec->sample_rate != ifmt_ctx->streams[audio_index]->codec->sample_rate
|| ofmt_ctx->streams[0]->codec->sample_fmt != ifmt_ctx->streams[audio_index]->codec->sample_fmt)
{
if ( NULL == pSwrCtx )
{
pSwrCtx = swr_alloc();
}
// #if LIBSWRESAMPLE_VERSION_MINOR >= 17 // 根据版本不同,选用适当函数
// av_opt_set_int(pSwrCtx “ich“ ifmt_ctx->streams[audio_index]->codec->channels 0);
// av_opt_set_int(pSwrCtx “och“ ofmt_ctx->streams[audio_index]->codec->channels 0);
// av_opt_set_int(pSwrCtx “in_sample_rate“ ifmt_ctx->streams[audio_index]->codec->sample_rate 0);
// av_opt_set_int(pSwrCtx “out_sample_rate“ ofmt_ctx->streams[audio_index]->codec->sample_rate 0);
// av_opt_set_sample_fmt(pSwrCtx “in_sample_fmt“ ifmt_ctx->streams[audio_index]->codec->sample_fmt 0);
// av_opt_set_sample_fmt(pSwrCtx “out_sample_fmt“ ofmt_ctx->streams[audio_index]->codec->sample_fmt 0);
// #else
pSwrCtx = swr_alloc_set_opts(NULL
ofmt_ctx->streams[audio_index]->codec->channel_layout
ofmt_ctx->streams[audio_index]->codec->sample_fmt
ofmt_ctx->streams[audio_index]->codec->sample_rate
ifmt_ctx->streams[audio_index]->codec->channel_layout
ifmt_ctx->streams[audio_index]->codec->sample_fmt
ifmt_ctx->streams[audio_index]->codec->sample_rate
0 NULL);
// #endif
swr_init(pSwrCtx);
}
}
//setup_array函数摘自ffmpeg例程
static void setup_array(uint8_t* out[32] AVframe* in_frame int format int samples)
{
if (av_sample_fmt_is_planar(format))
{
int i;
int plane_size = av_get_bytes_per_sample((format & 0xFF)) * samples;
format &= 0xFF;
//从decoder出来的frame中的data数据不是连续分布的,所以不能这样写:
in_frame->data[0]+i*plane_size;
for (i = 0; i < in_frame->channels; i++)
{
out[i] = in_frame->data[i];
}
}
else
{
out[0] = in_frame->data[0];
}
}
int TransSample(AVframe *in_frame AVframe *out_frame int audio_index)
{
int ret;
int max_dst_nb_samples = 4096;
相关资源
- nginx-rtmp-win32-master.rar
- onvif协议视频转码推流网页播放
- FFMEPG实现h264解码
- ffmpegh265rtmp.zip
- ffserver(windows下编译32位)
- qt_ffmpeg_mp4_export_and_import.zip
- 最简单的基于FFmpeg的推流器 1.2
- 简单的ffmpeg推流demo
- FFmpeg和SDL,读内存中的视频流,进行
- ffmpeg之pcm转AAC
- ffmpeg-2.8.14.tar.gz
- 利用ffmpeg的filter混音
- vs2010 ffmpeg实时解码h264码流
- ffmpeg 音视频转码代码
- windows上自己编译的最新的ffmpeg库
- Qt基于FFmpeg播放本地 H.264H264文件
- 从ffmpeg中抽取的h264解码器,可用于
- ffplay源代码
- 最简单的基于FFmpeg的推流器以推送R
- DVD文件VOB的生成代码
- FFmpeg 采集摄像头输出rtmp直播流媒体,
- 基于ffmpeg将avi视频转换为mp4视频
- (补充)修改output-example,将H.264AAC帧
- ffmpeg-win64位库
- X264实时编码,FFmpeg实时解码
- FFmpeg API读取视音频文件信息的一个工
- 使用FFmpeg采集摄像头图像和麦克风音
- opencv_ffmpeg249.dll
- FFmpeg-3.1 windows vs2013编译动态库静态库
- 基于FFmpeg4.0.2的AAC编码器
评论
共有 条评论