/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* simple audio converter
*
* @example transcode_aac.c
* Convert an input audio file to AAC in an MP4 container using FFmpeg.
* @author Andreas Unterweger (dustsigns@gmail.com)
*/
#include <stdio.h>
#include "libavformat/avformat.h"
#include "libavformat/avio.h"
#include "libavcodec/avcodec.h"
#include "libavutil/audio_fifo.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/frame.h"
#include "libavutil/opt.h"
#include "libswresample/swresample.h"
/** The output bit rate in kbit/s */
#define OUTPUT_BIT_RATE 96000
/** The number of output channels */
#define OUTPUT_CHANNELS 2
/** Open an input file and the required decoder. */
static int open_input_file(const char *filename,
AVFormatContext **input_format_context,
AVCodecContext **input_codec_context)
{
AVCodecContext *avctx;
AVCodec *input_codec;
int error;
/** Open the input file to read from it. */
if ((error = avformat_open_input(input_format_context, filename, NULL,
NULL)) < 0) {
fprintf(stderr, "Could not open input file '%s' (error '%s')\n",
filename, av_err2str(error));
*input_format_context = NULL;
return error;
}
/** Get information on the input file (number of streams etc.). */
if ((error = avformat_find_stream_info(*input_format_context, NULL)) < 0) {
fprintf(stderr, "Could not open find stream info (error '%s')\n",
av_err2str(error));
avformat_close_input(input_format_context);
return error;
}
/** Make sure that there is only one stream in the input file. */
if ((*input_format_context)->nb_streams != 1) {
fprintf(stderr, "Expected one audio input stream, but found %d\n",
(*input_format_context)->nb_streams);
avformat_close_input(input_format_context);
return AVERROR_EXIT;
}
/** Find a decoder for the audio stream. */
if (!(input_codec = avcodec_find_decoder((*input_format_context)->streams[0]->codecpar->codec_id))) {
fprintf(stderr, "Could not find input codec\n");
avformat_close_input(input_format_context);
return AVERROR_EXIT;
}
/** allocate a new decoding context */
avctx = avcodec_alloc_context3(input_codec);
if (!avctx) {
fprintf(stderr, "Could not allocate a decoding context\n");
avformat_close_input(input_format_context);
return AVERROR(ENOMEM);
}
/** initialize the stream parameters with demuxer information */
error = avcodec_parameters_to_context(avctx, (*input_format_context)->streams[0]->codecpar);
if (error < 0) {
avformat_close_input(input_format_context);
avcodec_free_context(&avctx);
return error;
}
/** Open the decoder for the audio stream to use it later. */
if ((error = avcodec_open2(avctx, input_codec, NULL)) < 0) {
fprintf(stderr, "Could not open input codec (error '%s')\n",
av_err2str(error));
avcodec_free_context(&avctx);
avformat_close_input(input_format_context);
return error;
}
/** Save the decoder context for easier access later. */
*input_codec_context = avctx;
return 0;
}
/**
* Open an output file and the required encoder.
* Also set some basic encoder parameters.
* Some of these parameters are based on the input file's parameters.
*/
static int open_output_file(const char *filename,
AVCodecContext *input_codec_context,
AVFormatContext **output_format_context,
AVCodecContext **output_codec_context)
{
AVCodecContext *avctx = NULL;
AVIOContext *output_io_context = NULL;
AVStream *stream = NULL;
AVCodec *output_codec = NULL;
int error;
/** Open the output file to write to it. */
if ((error = avio_open(&output_io_context, filename,
AVIO_FLAG_WRITE)) < 0) {
fprintf(stderr, "Could not open output file '%s' (error '%s')\n",
filename, av_err2str(error));
return error;
}
/** Create a new format context for the output container format. */
if (!(*output_format_context = avformat_alloc_context())) {
fprintf(stderr, "Could not allocate output format context\n");
return AVERROR(ENOMEM);
}
/** Associate the output file (pointer) with the container format context. */
(*output_format_context)->pb = output_io_context;
/** Guess the desired container format based on the file extension. */
if (!((*output_format_context)->oformat = av_guess_format(NULL, filename,
NULL))) {
fprintf(stderr, "Could not find output file format\n");
goto cleanup;
}
av_strlcpy((*output_format_context)->filename, filename,
sizeof((*output_format_context)->filename));
/** Find the encoder to be used by its name. */
if (!(output_codec = avcodec_find_encoder(AV_CODEC_ID_AAC))) {
fprintf(stderr, "Could not find an AAC encoder.\n");
goto cleanup;
}
/** Create a new audio stream in the output file container. */
if (!(stream = avformat_new_stream(*output_format_context, NULL))) {
fprintf(stderr, "Could not create new stream\n");
error = AVERROR(ENOMEM);
goto cleanup;
}
avctx = avcodec_alloc_context3(output_codec);
if (!avctx) {
fprintf(stderr, "Could not allocate an encoding context\n");
error = AVERROR(ENOMEM);
goto cleanup;
}
/**
* Set the basic encoder parameters.
* The input file's sample rate is used to avoid a sample rate conversion.
*/
avctx->channels = OUTPUT_CHANNELS;
avctx->channel_layout = av_get_default_channel_layout(OUTPUT_CHANNELS);
avctx->sample_rate = input_codec_context->sample_rate;
avctx->sample_fmt = output_codec->sample_fmts[0];
avctx->bit_rate = OUTPUT_BIT_RATE;
/** Allow the use of the experimental AAC encoder */
avctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
/** Set the sample rate for the container. */
stream->time_base.den = input_codec_context->sample_rate;
stream->time_base.num = 1;
/**
* Some container formats (like MP4) require global headers to be present
* Mark the encoder so that it behaves accordingly.
*/
if ((*output_format_context)->oformat->flags & AVFMT_GLOBALHEADER)
avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
/** Open the encoder for the audio stream to use it later. */
if ((error = avcodec_open2(avctx, output_codec, NULL)) < 0) {
fprintf(stderr, "Could not open output codec (error '%s')\n",
av_err2str(error));
goto cleanup;
}
error = avcodec_parameters_from_context(stream->codecpar, avctx);
if (error < 0) {
fprintf(stderr, "Could not initialize stream parameters\n");
goto cleanup;
}
/** Save the encoder context for easier access later. */
*output_codec_co
没有合适的资源?快使用搜索试试~ 我知道了~
qt整合ffmpeg实现点击按钮调用ffmpeg解码视频转成一张张的图片
共233个文件
h:111个
html:31个
c:21个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 182 浏览量
2022-04-18
16:06:28
上传
评论 1
收藏 10.96MB ZIP 举报
温馨提示
qt整合ffmpeg实现点击按钮调用ffmpeg解码视频转成一张张的图片
资源推荐
资源详情
资源评论
收起资源包目录
qt整合ffmpeg实现点击按钮调用ffmpeg解码视频转成一张张的图片 (233个子文件)
ffmpeg-all.1 1.08MB
ffserver-all.1 1.04MB
ffprobe-all.1 867KB
ffplay-all.1 855KB
ffmpeg-filters.1 586KB
ffmpeg-codecs.1 155KB
ffmpeg-formats.1 120KB
ffmpeg.1 95KB
ffmpeg-devices.1 67KB
ffserver.1 53KB
ffmpeg-protocols.1 52KB
ffprobe.1 42KB
ffmpeg-utils.1 36KB
ffplay.1 30KB
ffmpeg-bitstream-filters.1 14KB
ffmpeg-resampler.1 14KB
ffmpeg-scaler.1 8KB
libavcodec.so.57.89.100 12.39MB
libavfilter.so.6.82.100 2.39MB
libavformat.so.57.71.100 2.13MB
libswscale.so.4.6.100 506KB
libavutil.so.55.58.100 431KB
libpostproc.so.54.5.100 126KB
libswresample.so.2.7.100 118KB
libavdevice.so.57.6.100 107KB
libswresample.so.2 24B
libswresample.3 6KB
libswscale.3 5KB
libavutil.3 5KB
libavcodec.3 5KB
libavformat.3 5KB
libavdevice.3 5KB
libavfilter.3 5KB
libswscale.so.4 21B
libpostproc.so.54 23B
libavutil.so.55 22B
libavformat.so.57 24B
libavdevice.so.57 23B
libavcodec.so.57 23B
libavfilter.so.6 23B
transcode_aac.c 28KB
transcoding.c 22KB
muxing.c 21KB
demuxing_decoding.c 14KB
qsvdec.c 14KB
filter_audio.c 12KB
ff.c 11KB
filtering_audio.c 10KB
filtering_video.c 10KB
resampling_audio.c 8KB
encode_audio.c 6KB
remuxing.c 6KB
extract_mvs.c 6KB
decode_video.c 6KB
avio_dir_cmd.c 6KB
encode_video.c 5KB
http_multiclient.c 5KB
scaling_video.c 5KB
decode_audio.c 4KB
avio_reading.c 4KB
metadata.c 2KB
mainwindow.cpp 348B
main.cpp 172B
ff.cpp 0B
libvpx-720p.ffpreset 227B
libvpx-1080p.ffpreset 227B
libvpx-1080p50_60.ffpreset 227B
libvpx-720p50_60.ffpreset 227B
libvpx-360p.ffpreset 219B
avcodec.h 210KB
avformat.h 113KB
avfilter.h 42KB
opt.h 35KB
pixfmt.h 32KB
avio.h 30KB
frame.h 23KB
mem.h 23KB
swresample.h 21KB
hwcontext.h 20KB
intreadwrite.h 18KB
avdevice.h 17KB
common.h 15KB
pixdesc.h 14KB
avstring.h 14KB
swscale.h 12KB
log.h 11KB
buffer.h 10KB
samplefmt.h 10KB
imgutils.h 10KB
channel_layout.h 9KB
avutil.h 9KB
hash.h 8KB
dict.h 8KB
version.h 8KB
spherical.h 8KB
mathematics.h 8KB
vdpau.h 8KB
bprint.h 8KB
parseutils.h 7KB
buffersrc.h 6KB
共 233 条
- 1
- 2
- 3
资源评论
- narutalplastic2022-09-15这个资源对我启发很大,受益匪浅,学到了很多,谢谢分享~
reg183
- 粉丝: 1811
- 资源: 1万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- ### 词向量的介绍、使用技巧和优缺点的文章
- 基于STM32F103CBT6单片机GC65+MP2625+CC1101 GPSTrack模块板硬件(原理图+PCB)工程文件
- ### 通道处理过程模拟概念、优缺点和使用技巧
- ### MyBatis动态SQL介绍说明、使用技巧和优缺点
- 上传下载仿163网盘无刷新文件上传 for Jsp-fileupload-jsp.rar
- VMware Workstation业界非常稳定且安全的桌面虚拟机软件-计算机上运行多个操作系统,支持Windows、DOS等
- 基于STM8L101F3P6单片机+LY2508A33P+CC1100遥控器硬件(原理图+PCB)工程文件.zip
- 上传下载WAP图铃下载系统-unimg.rar
- YTX-0.1.0-Win
- 上传下载ExtJS 2.2 开源网络硬盘系统-dogdisk.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功