21.FFmpeg学习笔记 - 无编码的视频复用器(mux)

本篇文章的视频复用器是不带编码的。程序输入两个文件,从其中一个文件挑出视频流,从另一个文件挑出音频流,然后合成为某种视频格式(如mp4/ts/flv等),输出成文件。

其中视频流所在的文件,可以是mp4/ts/flv等格式的视频文件,也可以是h264等纯视频编码文件。音频流所在文件可以是mp4/ts/flv等格式的视频文件,也可以是aac等纯音频编码的文件。

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

#include <libavutil/avassert.h>
#include <libavutil/channel_layout.h>
#include <libavutil/opt.h>
#include <libavutil/mathematics.h>
#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <libswresample/swresample.h>


static int in_videoindex = -1, in_audioindex = -1, out_videoindex = -1, out_audioindex = -1;
static AVFormatContext *ifmt_ctx_v = NULL, *ifmt_ctx_a = NULL, *ofmt_ctx = NULL;
static int frame_index = 0;

static void mux_without_encode()
{
    const char *in_filename_v = "/Users/zhw/Desktop/resource/sintel_h264_aac.ts";
    const char *in_filename_a = "/Users/zhw/Desktop/resource/sintel_h264_aac.ts";
    const char *out_filename = "/Users/zhw/Desktop/result.mp4";
    int ret;
    AVOutputFormat *ofmt;
    
    ret = avformat_open_input(&ifmt_ctx_v, in_filename_v, NULL, NULL);
    if (ret < 0) {
        printf("avformat_open_input %s fail\n", in_filename_v);
        exit(1);
    }
    ret = avforma
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值