ffmpeg - 得到各种音频格式支持的参数
来源:互联网 发布:手机淘宝刷到单流程图 编辑:程序博客网 时间:2024/06/06 17:46
这个小程序可以得到ffmpeg音频编码器所支持的参数,AAC,MP2,MP3,AC3等等。
直接上代码:
#ifndef _UTIL_H_ #define _UTIL_H_#include <stdint.h>extern "C" {#include <libavutil/opt.h>#include <libavcodec/avcodec.h>#include <libavutil/channel_layout.h>#include <libavutil/common.h>#include <libavutil/imgutils.h>#include <libavutil/mathematics.h>#include <libavutil/samplefmt.h>#include <libavformat/avformat.h>#include <libavfilter/buffersink.h>#include <libavfilter/buffersrc.h>#include <libavfilter/avfiltergraph.h>#include <libavutil/pixdesc.h>};namespace unil{enum AVSampleFormat_t{AV_SAMPLE_FMT_NONE_t = -1,AV_SAMPLE_FMT_U8_t, ///< unsigned 8 bits AV_SAMPLE_FMT_S16_t, ///< signed 16 bits AV_SAMPLE_FMT_S32_t, ///< signed 32 bits AV_SAMPLE_FMT_FLT_t, ///< float AV_SAMPLE_FMT_DBL_t, ///< double AV_SAMPLE_FMT_U8P_t, ///< unsigned 8 bits, planar AV_SAMPLE_FMT_S16P_t, ///< signed 16 bits, planar AV_SAMPLE_FMT_S32P_t, ///< signed 32 bits, planar AV_SAMPLE_FMT_FLTP_t, ///< float, planar AV_SAMPLE_FMT_DBLP_t, ///< double, planar AV_SAMPLE_FMT_NB_t ///< Number of sample formats. DO NOT USE if linking dynamically };typedef signed char int8_t;typedef short int16_t;typedef int int32_t;typedef long long int64_t;typedef unsigned char uint8_t;typedef unsigned short uint16_t;typedef unsigned int uint32_t;typedef unsigned long long uint64_t;const int AV_IO_BUFF_SIZE = 1024;/* just pick the highest supported samplerate */static int select_sample_rate(AVCodec *codec){const int *p;int best_samplerate = 0;if (!codec->supported_samplerates)return 44100;p = codec->supported_samplerates;while (*p) {best_samplerate = FFMAX(*p, best_samplerate);p++;}return best_samplerate;}/* select layout with the highest channel count */static uint64_t select_channel_layout(AVCodec *codec){const uint64_t *p;uint64_t best_ch_layout = 0;int best_nb_channels = 0;if (!codec->channel_layouts)return AV_CH_LAYOUT_STEREO;p = codec->channel_layouts;while (*p) {int nb_channels = av_get_channel_layout_nb_channels(*p);if (nb_channels > best_nb_channels) {best_ch_layout = *p;best_nb_channels = nb_channels;}p++;}return best_ch_layout;}};#endif
#include "unil.h"#include <iostream>using namespace std;void print_sample_rate(AVCodec *codec){if (!codec->supported_samplerates){cout << "!supported samplerates";return;}const int *p = codec->supported_samplerates;while (*p) {cout << *p << endl;p++;}cout << endl;}void print_channel_layout(AVCodec *codec){uint64_t best_ch_layout = 0;int best_nb_channels = 0;if (!codec->channel_layouts) {cout << "AV_CH_LAYOUT_STEREO" << endl;return;}const uint64_t *p = codec->channel_layouts;while (*p) {int nb_channels = av_get_channel_layout_nb_channels(*p);cout <<"channel_layouts: " <<*p <<" nb_channels: "<<nb_channels << endl;p++;}}void print_sample_fmt(AVCodec *codec){const enum AVSampleFormat *p = codec->sample_fmts;while (*p != AV_SAMPLE_FMT_NONE) {cout << *p << endl;p++;}}void printFormatMsg(AVCodecID id) {AVCodec* codec = avcodec_find_encoder(id);if (codec){const AVCodecDescriptor* descriptor = avcodec_descriptor_get(id);cout << "id: " << id << " name: " << descriptor->long_name << endl;cout << "print_sample_rate: " << endl;print_sample_rate(codec);cout << "print_channel_layout: " << endl;print_channel_layout(codec);cout << "print_sample_fmt: " << endl;print_sample_fmt(codec);}elsecout << "no codec" << endl;cout << endl;}void printformat() {av_register_all();cout << "print AV_CODEC_ID_AAC : ";printFormatMsg(AVCodecID::AV_CODEC_ID_AAC);cout << "print AV_CODEC_ID_MP2 : ";printFormatMsg(AVCodecID::AV_CODEC_ID_MP2);cout << "print AV_CODEC_ID_MP3 : ";printFormatMsg(AVCodecID::AV_CODEC_ID_MP3);cout << "print AV_CODEC_ID_MP1 : ";printFormatMsg(AVCodecID::AV_CODEC_ID_MP1);cout << "print AV_CODEC_ID_PCM_S16LE : ";printFormatMsg(AVCodecID::AV_CODEC_ID_PCM_S16LE);}void main(int argc, char *argv[]){av_register_all();for (int i = 1; i < argc;++i){AVCodecID id = (AVCodecID)atoi(argv[i]);printFormatMsg(id);cout << endl;}}
编译后,在BAT中写
Codec.exe 86019 86018 86017 86016 86020
pause
运行BAT文件
0 0
- ffmpeg - 得到各种音频格式支持的参数
- ffmpeg音频格式转换参数
- Android支持的音频格式
- Android支持的音频格式
- Android支持的音频格式
- android 原生支持的音频格式
- Android、iOS支持的音频格式
- 各个浏览器支持的音频格式列表
- ios硬编码支持的音频格式
- ffmpeg中音频格式与解码器的对应关系
- 各种音频格式详解
- 音频格式及浏览器支持
- 在不同平台下CocosDenshion支持的音频格式
- FFmpeg学习4:音频格式转换
- FFmpeg学习4:音频格式转换
- ffmpeg 的各种数据结构
- ffmpeg支持的codec
- ffmpeg支持的pix_format
- Eclipse下报错 An internal error occurred during: "C/C++ Indexer". java.lang.NullPointerException
- 把hadoop源码导入到eclpse的java工程
- ReactiveCocoa框架菜鸟入门(二)——MVVM架构与ReactiveCocoa框架
- mac修改eclipse的内存配置
- 逻辑表达式字符串
- ffmpeg - 得到各种音频格式支持的参数
- 【NOIP模拟】Osu
- transact和onTransact的区别
- iOS开发 适配iOS10以及Xcode8
- java中的单例模式与静态类
- 5.NameServer
- Reac官网Top-Level API翻译
- java中的事物
- java线程池的使用