FFmpeg 4.3 音视频-多路H265监控录放C++开发十三:将AVFrame转换成AVPacket。视频编码原理.编码相关api
前提:
从前面的学习我们知道 AVFrame中是最原始的 视频数据,这一节开始我们需要将这个最原始的视频数据 压缩成 AVPacket数据,
我们前面,将YUV数据或者 RGBA 数据装进入了 AVFrame里面,并且在SDL中显示。
也就是说:对于安防项目来说,我们将原始从摄像头数据(YUV,RGB)转换成 AVFrame后,可以直接显示出来。但是如果我们将要数据存储,则要将 AVFrame转成 AVPacket.
视频编码 以及原理
从摄像头得到原始数据 ---- > 像素格式转换---->编码 ------>封装
编码的原因很好理解,YUV数据太大了,我们要编码成 h264,h265 等较小的格式
背后的原理是这样,一个YUV视频是由一张一张YUV图片组成的。
帧内压缩:
我们将一张YUV图片,假设是 1280x728大小的,我们将其划分成16x16的大小,总有一些像素点是一样的,或者接近的,例如下图:

帧间压缩:
假设上述图片是YUV 的第一张图片,第二帧图片是师爷 在讲话,那么第二帧图片可能只是嘴巴变化了一下,那么我们参考第一张图片,去存储第二张图片,就只用存储第二章图片 和 第一张图片不同的地方就好。。在还原的时候,参考第一张图片和差异,通过算法还原,这就叫做帧间压缩
我们这一节将 AVFrame转成 AVPacket,实际上就是编码的过程,
AVPacket 重要函数以及重要结构体成员
FFmpeg存放压缩后的音视频数据的结构体:AVPacket简介,结构体,函数-CSDN博客
从avframe 变成 avpacket 也就是编码,编码相关API

1.查找编码器
/**
* Find a registered encoder with a matching codec ID.
*
* @param id AVCodecID of the requested encoder
* @return An encoder if one was found, NULL otherwise.
*/
const AVCodec *avcodec_find_encoder(enum AVCodecID id);
如果参数 是 AVCodecID ,那么对应的值如下,重要的为
AV_CODEC_ID_H264,
#define AV_CODEC_ID_H265 AV_CODEC_ID_HEVC
enum AVCodecID {AV_CODEC_ID_NONE,/* video codecs */AV_CODEC_ID_MPEG1VIDEO,AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decodingAV_CODEC_ID_H261,AV_CODEC_ID_H263,AV_CODE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M,/* various PCM "codecs" */AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecsAV_CODEC_ID_PCM_S16LE = 0x10000,AV_CODEC_ID_PCM_S16BE,AV_CODEC_ID_PCM_U16LE,AV_CODEC_ID_PCM_U16BE,AV_CODEC_ID_PCM_S8,AV_CODEC_ID_PCM_U8,AV_CODEC_ID_PCM_MULAW,AV_CODEC_ID_PCM_ALAW,AV_CODEC_ID_PCM_S32LE,AV_CODEC_ID_PCM_S32BE,AV_CODEC_ID_PCM_U32LE,AV_CODEC_ID_PCM_U32BE,AV_CODEC_ID_PCM_S24LE,AV_CODEC_ID_PCM_S24BE,AV_CODEC_ID_PCM_U24LE,AV_CODEC_ID_PCM_U24BE,AV_CODEC_ID_PCM_S24DAUD,AV_CODEC_ID_PCM_ZORK,AV_CODEC_ID_PCM_S16LE_PLANAR,AV_CODEC_ID_PCM_DVD,AV_CODEC_ID_PCM_F32BE,AV_CODEC_ID_PCM_F32LE,AV_CODEC_ID_PCM_F64BE,AV_CODEC_ID_PCM_F64LE,AV_CODEC_ID_PCM_BLURAY,AV_CODEC_ID_PCM_LXF,AV_CODEC_ID_S302M,AV_CODEC_ID_PCM_S8_PLANAR,AV_CODEC_ID_PCM_S24LE_PLANAR,AV_CODEC_ID_PCM_S32LE_PLANAR,AV_CODEC_ID_PCM_S16BE_PLANAR,AV_CODEC_ID_PCM_S64LE = 0x10800,AV_CODEC_ID_PCM_S64BE,AV_CODEC_ID_PCM_F16LE,AV_CODEC_ID_PCM_F24LE,AV_CODEC_ID_PCM_VIDC,/* various ADPCM codecs */AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,AV_CODEC_ID_ADPCM_IMA_WAV,AV_CODEC_ID_ADPCM_IMA_DK3,AV_CODEC_ID_ADPCM_IMA_DK4,AV_CODEC_ID_ADPCM_IMA_WS,AV_CODEC_ID_ADPCM_IMA_SMJPEG,AV_CODEC_ID_ADPCM_MS,AV_CODEC_ID_ADPCM_4XM,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ODEC_ID_RA_144 = 0x13000,AV_CODEC_ID_RA_288,/* various DPCM codecs */AV_CODEC_ID_ROQ_DPCM = 0x14000,AV_CODEC_ID_INTERPLAY_DPCM,AV_CODEC_ID_XAN_DPCM,AV_CODEC_ID_SOL_DPCM,AV_CODEC_ID_SDX2_DPCM = 0x14800,AV_CODEC_ID_GREMLIN_DPCM,AV_CODEC_ID_DERF_DPCM,/* audio codecs */AV_CODEC_ID_MP2 = 0x15000,AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3AV_CODEC_ID_AAC,AV_CODEC_ID_AC3,AV_CODEC_ID_DTS,AV_CODEC_ID_VORBIS,AV_CODEC_ID_DVAUDIO,AV_CODEC_ID_WMAV1,AV_CODEC_ID_WMAV2,AV_CODEC_ID_MACE3,AV_CODEC_ID_MACE6,AV_CODEC_ID_VMDAUDIO,AV_CODEC_ID_FLAC,AV_CODEC_ID_MP3ADU,AV_CODEC_ID_MP3ON4,AV_CODEC_ID_SHORTEN,AV_CODEC_ID_ALAC,AV_CODEC_ID_WESTWOOD_SND1,AV_CODEC_ID_GSM, ///< as in Berlin toast formatAV_CODEC_ID_QDM2,AV_CODEC_ID_COOK,AV_CODEC_ID_TRUESPEECH,AV_CODEC_ID_TTA,AV_CODEC_ID_SMACKAUDIO,AV_CODEC_ID_QCELP,AV_CODEC_ID_WAVPACK,AV_CODEC_ID_DSICINAUDIO,AV_CODEC_ID_IMC,AV_CODEC_ID_MUSEPACK7,AV_CODEC_ID_MLP,AV_CODEC_ID_GSM_MS, /* as found in WAV */AV_CODEC_ID_ATRAC3,AV_CODEC_ID_APE,AV_CODEC_ID_NELLYMOSER,AV_CODEC_ID_MUSEPACK8,AV_CODEC_ID_SPEEX,AV_CODEC_ID_WMAVOICE,AV_CODEC_ID_WMAPRO,AV_CODEC_ID_WMALOSSLESS,AV_CODEC_ID_ATRAC3P,AV_CODEC_ID_EAC3,AV_CODEC_ID_SIPR,AV_CODEC_ID_MP1,AV_CODEC_ID_TWINVQ,AV_CODEC_ID_TRUEHD,AV_CODEC_ID_MP4ALS,AV_CODEC_ID_ATRAC1,AV_CODEC_ID_BINKAUDIO_RDFT,AV_CODEC_ID_BINKAUDIO_DCT,AV_CODEC_ID_AAC_LATM,AV_CODEC_ID_QDMC,AV_CODEC_ID_CELT,AV_CODEC_ID_G723_1,AV_CODEC_ID_G729,AV_CODEC_ID_8SVX_EXP,AV_CODEC_ID_8SVX_FIB,AV_CODEC_ID_BMV_AUDIO,AV_CODEC_ID_RALF,AV_CODEC_ID_IAC,AV_CODEC_ID_ILBC,AV_CODEC_ID_OPUS,AV_CODEC_ID_COMFORT_NOISE,AV_CODEC_ID_TAK,AV_CODEC_ID_METASOUND,AV_CODEC_ID_PAF_AUDIO,AV_CODEC_ID_ON2AVC,AV_CODEC_ID_DSS_SP,AV_CODEC_ID_CODEC2,AV_CODEC_ID_FFWAVESYNTH = 0x15800,AV_CODEC_ID_SONIC,AV_CODEC_ID_SONIC_LS,AV_CODEC_ID_EVRC,AV_CODEC_ID_SMV,AV_CODEC_ID_DSD_LSBF,AV_CODEC_ID_DSD_MSBF,AV_CODEC_ID_DSD_LSBF_PLANAR,AV_CODEC_ID_DSD_MSBF_PLANAR,AV_CODEC_ID_4GV,AV_CODEC_ID_INTERPLAY_ACM,AV_CODEC_ID_XMA1,AV_CODEC_ID_XMA2,AV_CODEC_ID_DST,AV_CODEC_ID_ATRAC3AL,AV_CODEC_ID_ATRAC3PAL,AV_CODEC_ID_DOLBY_E,AV_CODEC_ID_APTX,AV_CODEC_ID_APTX_HD,AV_CODEC_ID_SBC,AV_CODEC_ID_ATRAC9,AV_CODEC_ID_HCOM,AV_CODEC_ID_ACELP_KELVIN,AV_CODEC_ID_MPEGH_3D_AUDIO,AV_CODEC_ID_SIREN,AV_CODEC_ID_HCA,/* subtitle codecs */AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.AV_CODEC_ID_DVD_SUBTITLE = 0x17000,AV_CODEC_ID_DVB_SUBTITLE,AV_CODEC_ID_TEXT, ///< raw UTF-8 textAV_CODEC_ID_XSUB,AV_CODEC_ID_SSA,AV_CODEC_ID_MOV_TEXT,AV_CODEC_ID_HDMV_PGS_SUBTITLE,AV_CODEC_ID_DVB_TELETEXT,AV_CODEC_ID_SRT,AV_CODEC_ID_MICRODVD = 0x17800,AV_CODEC_ID_EIA_608,AV_CODEC_ID_JACOSUB,AV_CODEC_ID_SAMI,AV_CODEC_ID_REALTEXT,AV_CODEC_ID_STL,AV_CODEC_ID_SUBVIEWER1,AV_CODEC_ID_SUBVIEWER,AV_CODEC_ID_SUBRIP,AV_CODEC_ID_WEBVTT,AV_CODEC_ID_MPL2,AV_CODEC_ID_VPLAYER,AV_CODEC_ID_PJS,AV_CODEC_ID_ASS,AV_CODEC_ID_HDMV_TEXT_SUBTITLE,AV_CODEC_ID_TTML,AV_CODEC_ID_ARIB_CAPTION,/* other specific kind of codecs (generally used for attachments) */AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.AV_CODEC_ID_TTF = 0x18000,AV_CODEC_ID_SCTE_35, ///< Contain timestamp estimated through PCR of program stream.AV_CODEC_ID_EPG,AV_CODEC_ID_BINTEXT = 0x18800,AV_CODEC_ID_XBIN,AV_CODEC_ID_IDF,AV_CODEC_ID_OTF,AV_CODEC_ID_SMPTE_KLV,AV_CODEC_ID_DVD_NAV,AV_CODEC_ID_TIMED_ID3,AV_CODEC_ID_BIN_DATA,AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify itAV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS* stream (only used by libavformat) */AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems* stream (only used by libavformat) */AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket
};
/**
* Find a registered encoder with the specified name.
*
* @param name name of the requested encoder
* @return An encoder if one was found, NULL otherwise.
*/
const AVCodec *avcodec_find_encoder_by_name(const char *name);
如果是通过字符查找对应的编码器/解码器,我们怎么知道这个字符是啥编码器呢?
libavcodec/allcodecs.c中开头定义了很多支编解码结构体;如:
可以查看具体的某一个,当然有些只是定义,ffmpeg并没有实现,如果要实现需要
/** Provide registration of all codecs, parsers and bitstream filters for libavcodec.* Copyright (c) 2002 Fabrice Bellard** 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* Provide registration of all codecs, parsers and bitstream filters for libavcodec.*/#include <stdint.h>
#include <string.h>#include "config.h"
#include "config_components.h"
#include "libavutil/thread.h"
#include "codec.h"
#include "codec_id.h"
#include "codec_internal.h"extern const FFCodec ff_a64multi_encoder;
extern const FFCodec ff_a64multi5_encoder;
extern const FFCodec ff_aasc_decoder;
extern const FFCodec ff_aic_decoder;
extern const FFCodec ff_alias_pix_encoder;
extern const FFCodec ff_alias_pix_decoder;
extern const FFCodec ff_agm_decoder;
extern const FFCodec ff_amv_encoder;
extern const FFCodec ff_amv_decoder;
extern const FFCodec ff_anm_decoder;
extern const FFCodec ff_ansi_decoder;
extern const FFCodec ff_apng_encoder;
extern const FFCodec ff_apng_decoder;
extern const FFCodec ff_arbc_decoder;
extern const FFCodec ff_argo_decoder;
extern const FFCodec ff_asv1_encoder;
extern const FFCodec ff_asv1_decoder;
extern const FFCodec ff_asv2_encoder;
extern const FFCodec ff_asv2_decoder;
extern const FFCodec ff_aura_decoder;
extern const FFCodec ff_aura2_decoder;
extern const FFCodec ff_avrp_encoder;
extern const FFCodec ff_avrp_decoder;
extern const FFCodec ff_avrn_decoder;
extern const FFCodec ff_avs_decoder;
extern const FFCodec ff_avui_encoder;
extern const FFCodec ff_avui_decoder;
#if FF_API_AYUV_CODECID
extern const FFCodec ff_ayuv_encoder;
extern const FFCodec ff_ayuv_decoder;
#endif
extern const FFCodec ff_bethsoftvid_decoder;
extern const FFCodec ff_bfi_decoder;
extern const FFCodec ff_bink_decoder;
extern const FFCodec ff_bitpacked_decoder;
extern const FFCodec ff_bitpacked_encoder;
extern const FFCodec ff_bmp_encoder;
extern const FFCodec ff_bmp_decoder;
extern const FFCodec ff_bmv_video_decoder;
extern const FFCodec ff_brender_pix_decoder;
extern const FFCodec ff_c93_decoder;
extern const FFCodec ff_cavs_decoder;
extern const FFCodec ff_cdgraphics_decoder;
extern const FFCodec ff_cdtoons_decoder;
extern const FFCodec ff_cdxl_decoder;
extern const FFCodec ff_cfhd_encoder;
extern const FFCodec ff_cfhd_decoder;
extern const FFCodec ff_cinepak_encoder;
extern const FFCodec ff_cinepak_decoder;
extern const FFCodec ff_clearvideo_decoder;
extern const FFCodec ff_cljr_encoder;
extern const FFCodec ff_cljr_decoder;
extern const FFCodec ff_cllc_decoder;
extern const FFCodec ff_comfortnoise_encoder;
extern const FFCodec ff_comfortnoise_decoder;
extern const FFCodec ff_cpia_decoder;
extern const FFCodec ff_cri_decoder;
extern const FFCodec ff_cscd_decoder;
extern const FFCodec ff_cyuv_decoder;
extern const FFCodec ff_dds_decoder;
extern const FFCodec ff_dfa_decoder;
extern const FFCodec ff_dirac_decoder;
extern const FFCodec ff_dnxhd_encoder;
extern const FFCodec ff_dnxhd_decoder;
extern const FFCodec ff_dpx_encoder;
extern const FFCodec ff_dpx_decoder;
extern const FFCodec ff_dsicinvideo_decoder;
extern const FFCodec ff_dvaudio_decoder;
extern const FFCodec ff_dvvideo_encoder;
extern const FFCodec ff_dvvideo_decoder;
extern const FFCodec ff_dxa_decoder;
extern const FFCodec ff_dxtory_decoder;
extern const FFCodec ff_dxv_decoder;
extern const FFCodec ff_eacmv_decoder;
extern const FFCodec ff_eamad_decoder;
extern const FFCodec ff_eatgq_decoder;
extern const FFCodec ff_eatgv_decoder;
extern const FFCodec ff_eatqi_decoder;
extern const FFCodec ff_eightbps_decoder;
extern const FFCodec ff_eightsvx_exp_decoder;
extern const FFCodec ff_eightsvx_fib_decoder;
extern const FFCodec ff_escape124_decoder;
extern const FFCodec ff_escape130_decoder;
extern const FFCodec ff_exr_encoder;
extern const FFCodec ff_exr_decoder;
extern const FFCodec ff_ffv1_encoder;
extern const FFCodec ff_ffv1_decoder;
extern const FFCodec ff_ffvhuff_encoder;
extern const FFCodec ff_ffvhuff_decoder;
extern const FFCodec ff_fic_decoder;
extern const FFCodec ff_fits_encoder;
extern const FFCodec ff_fits_decoder;
extern const FFCodec ff_flashsv_encoder;
extern const FFCodec ff_flashsv_decoder;
extern const FFCodec ff_flashsv2_encoder;
extern const FFCodec ff_flashsv2_decoder;
extern const FFCodec ff_flic_decoder;
extern const FFCodec ff_flv_encoder;
extern const FFCodec ff_flv_decoder;
extern const FFCodec ff_fmvc_decoder;
extern const FFCodec ff_fourxm_decoder;
extern const FFCodec ff_fraps_decoder;
extern const FFCodec ff_frwu_decoder;
extern const FFCodec ff_g2m_decoder;
extern const FFCodec ff_gdv_decoder;
extern const FFCodec ff_gem_decoder;
extern const FFCodec ff_gif_encoder;
extern const FFCodec ff_gif_decoder;
extern const FFCodec ff_h261_encoder;
extern const FFCodec ff_h261_decoder;
extern const FFCodec ff_h263_encoder;
extern const FFCodec ff_h263_decoder;
extern const FFCodec ff_h263i_decoder;
extern const FFCodec ff_h263p_encoder;
extern const FFCodec ff_h263p_decoder;
extern const FFCodec ff_h263_v4l2m2m_decoder;
extern const FFCodec ff_h264_decoder;
extern const FFCodec ff_h264_crystalhd_decoder;
extern const FFCodec ff_h264_v4l2m2m_decoder;
extern const FFCodec ff_h264_mediacodec_decoder;
extern const FFCodec ff_h264_mediacodec_encoder;
extern const FFCodec ff_h264_mmal_decoder;
extern const FFCodec ff_h264_qsv_decoder;
extern const FFCodec ff_h264_rkmpp_decoder;
extern const FFCodec ff_hap_encoder;
extern const FFCodec ff_hap_decoder;
extern const FFCodec ff_hevc_decoder;
extern const FFCodec ff_hevc_qsv_decoder;
extern const FFCodec ff_hevc_rkmpp_decoder;
extern const FFCodec ff_hevc_v4l2m2m_decoder;
extern const FFCodec ff_hnm4_video_decoder;
extern const FFCodec ff_hq_hqa_decoder;
extern const FFCodec ff_hqx_decoder;
extern const FFCodec ff_huffyuv_encoder;
extern const FFCodec ff_huffyuv_decoder;
extern const FFCodec ff_hymt_decoder;
extern const FFCodec ff_idcin_decoder;
extern const FFCodec ff_iff_ilbm_decoder;
extern const FFCodec ff_imm4_decoder;
extern const FFCodec ff_imm5_decoder;
extern const FFCodec ff_indeo2_decoder;
extern const FFCodec ff_indeo3_decoder;
extern const FFCodec ff_indeo4_decoder;
extern const FFCodec ff_indeo5_decoder;
extern const FFCodec ff_interplay_video_decoder;
extern const FFCodec ff_ipu_decoder;
extern const FFCodec ff_jpeg2000_encoder;
extern const FFCodec ff_jpeg2000_decoder;
extern const FFCodec ff_jpegls_encoder;
extern const FFCodec ff_jpegls_decoder;
extern const FFCodec ff_jv_decoder;
extern const FFCodec ff_kgv1_decoder;
extern const FFCodec ff_kmvc_decoder;
extern const FFCodec ff_lagarith_decoder;
extern const FFCodec ff_ljpeg_encoder;
extern const FFCodec ff_loco_decoder;
extern const FFCodec ff_lscr_decoder;
extern const FFCodec ff_m101_decoder;
extern const FFCodec ff_magicyuv_encoder;
extern const FFCodec ff_magicyuv_decoder;
extern const FFCodec ff_mdec_decoder;
extern const FFCodec ff_media100_decoder;
extern const FFCodec ff_mimic_decoder;
extern const FFCodec ff_mjpeg_encoder;
extern const FFCodec ff_mjpeg_decoder;
extern const FFCodec ff_mjpegb_decoder;
extern const FFCodec ff_mmvideo_decoder;
extern const FFCodec ff_mobiclip_decoder;
extern const FFCodec ff_motionpixels_decoder;
extern const FFCodec ff_mpeg1video_encoder;
extern const FFCodec ff_mpeg1video_decoder;
extern const FFCodec ff_mpeg2video_encoder;
extern const FFCodec ff_mpeg2video_decoder;
extern const FFCodec ff_mpeg4_encoder;
extern const FFCodec ff_mpeg4_decoder;
extern const FFCodec ff_mpeg4_crystalhd_decoder;
extern const FFCodec ff_mpeg4_v4l2m2m_decoder;
extern const FFCodec ff_mpeg4_mmal_decoder;
extern const FFCodec ff_mpegvideo_decoder;
extern const FFCodec ff_mpeg1_v4l2m2m_decoder;
extern const FFCodec ff_mpeg2_mmal_decoder;
extern const FFCodec ff_mpeg2_crystalhd_decoder;
extern const FFCodec ff_mpeg2_v4l2m2m_decoder;
extern const FFCodec ff_mpeg2_qsv_decoder;
extern const FFCodec ff_mpeg2_mediacodec_decoder;
extern const FFCodec ff_msa1_decoder;
extern const FFCodec ff_mscc_decoder;
extern const FFCodec ff_msmpeg4v1_decoder;
extern const FFCodec ff_msmpeg4v2_encoder;
extern const FFCodec ff_msmpeg4v2_decoder;
extern const FFCodec ff_msmpeg4v3_encoder;
extern const FFCodec ff_msmpeg4v3_decoder;
extern const FFCodec ff_msmpeg4_crystalhd_decoder;
extern const FFCodec ff_msp2_decoder;
extern const FFCodec ff_msrle_decoder;
extern const FFCodec ff_mss1_decoder;
extern const FFCodec ff_mss2_decoder;
extern const FFCodec ff_msvideo1_encoder;
extern const FFCodec ff_msvideo1_decoder;
extern const FFCodec ff_mszh_decoder;
extern const FFCodec ff_mts2_decoder;
extern const FFCodec ff_mv30_decoder;
extern const FFCodec ff_mvc1_decoder;
extern const FFCodec ff_mvc2_decoder;
extern const FFCodec ff_mvdv_decoder;
extern const FFCodec ff_mvha_decoder;
extern const FFCodec ff_mwsc_decoder;
extern const FFCodec ff_mxpeg_decoder;
extern const FFCodec ff_notchlc_decoder;
extern const FFCodec ff_nuv_decoder;
extern const FFCodec ff_paf_video_decoder;
extern const FFCodec ff_pam_encoder;
extern const FFCodec ff_pam_decoder;
extern const FFCodec ff_pbm_encoder;
extern const FFCodec ff_pbm_decoder;
extern const FFCodec ff_pcx_encoder;
extern const FFCodec ff_pcx_decoder;
extern const FFCodec ff_pfm_encoder;
extern const FFCodec ff_pfm_decoder;
extern const FFCodec ff_pgm_encoder;
extern const FFCodec ff_pgm_decoder;
extern const FFCodec ff_pgmyuv_encoder;
extern const FFCodec ff_pgmyuv_decoder;
extern const FFCodec ff_pgx_decoder;
extern const FFCodec ff_phm_encoder;
extern const FFCodec ff_phm_decoder;
extern const FFCodec ff_photocd_decoder;
extern const FFCodec ff_pictor_decoder;
extern const FFCodec ff_pixlet_decoder;
extern const FFCodec ff_png_encoder;
extern const FFCodec ff_png_decoder;
extern const FFCodec ff_ppm_encoder;
extern const FFCodec ff_ppm_decoder;
extern const FFCodec ff_prores_encoder;
extern const FFCodec ff_prores_decoder;
extern const FFCodec ff_prores_aw_encoder;
extern const FFCodec ff_prores_ks_encoder;
extern const FFCodec ff_prosumer_decoder;
extern const FFCodec ff_psd_decoder;
extern const FFCodec ff_ptx_decoder;
extern const FFCodec ff_qdraw_decoder;
extern const FFCodec ff_qoi_encoder;
extern const FFCodec ff_qoi_decoder;
extern const FFCodec ff_qpeg_decoder;
extern const FFCodec ff_qtrle_encoder;
extern const FFCodec ff_qtrle_decoder;
extern const FFCodec ff_r10k_encoder;
extern const FFCodec ff_r10k_decoder;
extern const FFCodec ff_r210_encoder;
extern const FFCodec ff_r210_decoder;
extern const FFCodec ff_rasc_decoder;
extern const FFCodec ff_rawvideo_encoder;
extern const FFCodec ff_rawvideo_decoder;
extern const FFCodec ff_rka_decoder;
extern const FFCodec ff_rl2_decoder;
extern const FFCodec ff_roq_encoder;
extern const FFCodec ff_roq_decoder;
extern const FFCodec ff_rpza_encoder;
extern const FFCodec ff_rpza_decoder;
extern const FFCodec ff_rscc_decoder;
extern const FFCodec ff_rv10_encoder;
extern const FFCodec ff_rv10_decoder;
extern const FFCodec ff_rv20_encoder;
extern const FFCodec ff_rv20_decoder;
extern const FFCodec ff_rv30_decoder;
extern const FFCodec ff_rv40_decoder;
extern const FFCodec ff_s302m_encoder;
extern const FFCodec ff_s302m_decoder;
extern const FFCodec ff_sanm_decoder;
extern const FFCodec ff_scpr_decoder;
extern const FFCodec ff_screenpresso_decoder;
extern const FFCodec ff_sga_decoder;
extern const FFCodec ff_sgi_encoder;
extern const FFCodec ff_sgi_decoder;
extern const FFCodec ff_sgirle_decoder;
extern const FFCodec ff_sheervideo_decoder;
extern const FFCodec ff_simbiosis_imx_decoder;
extern const FFCodec ff_smacker_decoder;
extern const FFCodec ff_smc_encoder;
extern const FFCodec ff_smc_decoder;
extern const FFCodec ff_smvjpeg_decoder;
extern const FFCodec ff_snow_encoder;
extern const FFCodec ff_snow_decoder;
extern const FFCodec ff_sp5x_decoder;
extern const FFCodec ff_speedhq_decoder;
extern const FFCodec ff_speedhq_encoder;
extern const FFCodec ff_speex_decoder;
extern const FFCodec ff_srgc_decoder;
extern const FFCodec ff_sunrast_encoder;
extern const FFCodec ff_sunrast_decoder;
extern const FFCodec ff_svq1_encoder;
extern const FFCodec ff_svq1_decoder;
extern const FFCodec ff_svq3_decoder;
extern const FFCodec ff_targa_encoder;
extern const FFCodec ff_targa_decoder;
extern const FFCodec ff_targa_y216_decoder;
extern const FFCodec ff_tdsc_decoder;
extern const FFCodec ff_theora_decoder;
extern const FFCodec ff_thp_decoder;
extern const FFCodec ff_tiertexseqvideo_decoder;
extern const FFCodec ff_tiff_encoder;
extern const FFCodec ff_tiff_decoder;
extern const FFCodec ff_tmv_decoder;
extern const FFCodec ff_truemotion1_decoder;
extern const FFCodec ff_truemotion2_decoder;
extern const FFCodec ff_truemotion2rt_decoder;
extern const FFCodec ff_tscc_decoder;
extern const FFCodec ff_tscc2_decoder;
extern const FFCodec ff_txd_decoder;
extern const FFCodec ff_ulti_decoder;
extern const FFCodec ff_utvideo_encoder;
extern const FFCodec ff_utvideo_decoder;
extern const FFCodec ff_v210_encoder;
extern const FFCodec ff_v210_decoder;
extern const FFCodec ff_v210x_decoder;
extern const FFCodec ff_v308_encoder;
extern const FFCodec ff_v308_decoder;
extern const FFCodec ff_v408_encoder;
extern const FFCodec ff_v408_decoder;
extern const FFCodec ff_v410_encoder;
extern const FFCodec ff_v410_decoder;
extern const FFCodec ff_vb_decoder;
extern const FFCodec ff_vbn_encoder;
extern const FFCodec ff_vbn_decoder;
extern const FFCodec ff_vble_decoder;
extern const FFCodec ff_vc1_decoder;
extern const FFCodec ff_vc1_crystalhd_decoder;
extern const FFCodec ff_vc1image_decoder;
extern const FFCodec ff_vc1_mmal_decoder;
extern const FFCodec ff_vc1_qsv_decoder;
extern const FFCodec ff_vc1_v4l2m2m_decoder;
extern const FFCodec ff_vc2_encoder;
extern const FFCodec ff_vcr1_decoder;
extern const FFCodec ff_vmdvideo_decoder;
extern const FFCodec ff_vmnc_decoder;
extern const FFCodec ff_vp3_decoder;
extern const FFCodec ff_vp4_decoder;
extern const FFCodec ff_vp5_decoder;
extern const FFCodec ff_vp6_decoder;
extern const FFCodec ff_vp6a_decoder;
extern const FFCodec ff_vp6f_decoder;
extern const FFCodec ff_vp7_decoder;
extern const FFCodec ff_vp8_decoder;
extern const FFCodec ff_vp8_rkmpp_decoder;
extern const FFCodec ff_vp8_v4l2m2m_decoder;
extern const FFCodec ff_vp9_decoder;
extern const FFCodec ff_vp9_rkmpp_decoder;
extern const FFCodec ff_vp9_v4l2m2m_decoder;
extern const FFCodec ff_vqa_decoder;
extern const FFCodec ff_vqc_decoder;
extern const FFCodec ff_wbmp_decoder;
extern const FFCodec ff_wbmp_encoder;
extern const FFCodec ff_webp_decoder;
extern const FFCodec ff_wcmv_decoder;
extern const FFCodec ff_wrapped_avframe_encoder;
extern const FFCodec ff_wrapped_avframe_decoder;
extern const FFCodec ff_wmv1_encoder;
extern const FFCodec ff_wmv1_decoder;
extern const FFCodec ff_wmv2_encoder;
extern const FFCodec ff_wmv2_decoder;
extern const FFCodec ff_wmv3_decoder;
extern const FFCodec ff_wmv3_crystalhd_decoder;
extern const FFCodec ff_wmv3image_decoder;
extern const FFCodec ff_wnv1_decoder;
extern const FFCodec ff_xan_wc3_decoder;
extern const FFCodec ff_xan_wc4_decoder;
extern const FFCodec ff_xbm_encoder;
extern const FFCodec ff_xbm_decoder;
extern const FFCodec ff_xface_encoder;
extern const FFCodec ff_xface_decoder;
extern const FFCodec ff_xl_decoder;
extern const FFCodec ff_xpm_decoder;
extern const FFCodec ff_xwd_encoder;
extern const FFCodec ff_xwd_decoder;
extern const FFCodec ff_y41p_encoder;
extern const FFCodec ff_y41p_decoder;
extern const FFCodec ff_ylc_decoder;
extern const FFCodec ff_yop_decoder;
extern const FFCodec ff_yuv4_encoder;
extern const FFCodec ff_yuv4_decoder;
extern const FFCodec ff_zero12v_decoder;
extern const FFCodec ff_zerocodec_decoder;
extern const FFCodec ff_zlib_encoder;
extern const FFCodec ff_zlib_decoder;
extern const FFCodec ff_zmbv_encoder;
extern const FFCodec ff_zmbv_decoder;/* audio codecs */
extern const FFCodec ff_aac_encoder;
extern const FFCodec ff_aac_decoder;
extern const FFCodec ff_aac_fixed_decoder;
extern const FFCodec ff_aac_latm_decoder;
extern const FFCodec ff_ac3_encoder;
extern const FFCodec ff_ac3_decoder;
extern const FFCodec ff_ac3_fixed_encoder;
extern const FFCodec ff_ac3_fixed_decoder;
extern const FFCodec ff_acelp_kelvin_decoder;
extern const FFCodec ff_alac_encoder;
extern const FFCodec ff_alac_decoder;
extern const FFCodec ff_als_decoder;
extern const FFCodec ff_amrnb_decoder;
extern const FFCodec ff_amrwb_decoder;
extern const FFCodec ff_apac_decoder;
extern const FFCodec ff_ape_decoder;
extern const FFCodec ff_aptx_encoder;
extern const FFCodec ff_aptx_decoder;
extern const FFCodec ff_aptx_hd_encoder;
extern const FFCodec ff_aptx_hd_decoder;
extern const FFCodec ff_atrac1_decoder;
extern const FFCodec ff_atrac3_decoder;
extern const FFCodec ff_atrac3al_decoder;
extern const FFCodec ff_atrac3p_decoder;
extern const FFCodec ff_atrac3pal_decoder;
extern const FFCodec ff_atrac9_decoder;
extern const FFCodec ff_binkaudio_dct_decoder;
extern const FFCodec ff_binkaudio_rdft_decoder;
extern const FFCodec ff_bmv_audio_decoder;
extern const FFCodec ff_bonk_decoder;
extern const FFCodec ff_cook_decoder;
extern const FFCodec ff_dca_encoder;
extern const FFCodec ff_dca_decoder;
extern const FFCodec ff_dfpwm_encoder;
extern const FFCodec ff_dfpwm_decoder;
extern const FFCodec ff_dolby_e_decoder;
extern const FFCodec ff_dsd_lsbf_decoder;
extern const FFCodec ff_dsd_msbf_decoder;
extern const FFCodec ff_dsd_lsbf_planar_decoder;
extern const FFCodec ff_dsd_msbf_planar_decoder;
extern const FFCodec ff_dsicinaudio_decoder;
extern const FFCodec ff_dss_sp_decoder;
extern const FFCodec ff_dst_decoder;
extern const FFCodec ff_eac3_encoder;
extern const FFCodec ff_eac3_decoder;
extern const FFCodec ff_evrc_decoder;
extern const FFCodec ff_fastaudio_decoder;
extern const FFCodec ff_ffwavesynth_decoder;
extern const FFCodec ff_flac_encoder;
extern const FFCodec ff_flac_decoder;
extern const FFCodec ff_ftr_decoder;
extern const FFCodec ff_g723_1_encoder;
extern const FFCodec ff_g723_1_decoder;
extern const FFCodec ff_g729_decoder;
extern const FFCodec ff_gsm_decoder;
extern const FFCodec ff_gsm_ms_decoder;
extern const FFCodec ff_hca_decoder;
extern const FFCodec ff_hcom_decoder;
extern const FFCodec ff_hdr_encoder;
extern const FFCodec ff_hdr_decoder;
extern const FFCodec ff_iac_decoder;
extern const FFCodec ff_ilbc_decoder;
extern const FFCodec ff_imc_decoder;
extern const FFCodec ff_interplay_acm_decoder;
extern const FFCodec ff_mace3_decoder;
extern const FFCodec ff_mace6_decoder;
extern const FFCodec ff_metasound_decoder;
extern const FFCodec ff_misc4_decoder;
extern const FFCodec ff_mlp_encoder;
extern const FFCodec ff_mlp_decoder;
extern const FFCodec ff_mp1_decoder;
extern const FFCodec ff_mp1float_decoder;
extern const FFCodec ff_mp2_encoder;
extern const FFCodec ff_mp2_decoder;
extern const FFCodec ff_mp2float_decoder;
extern const FFCodec ff_mp2fixed_encoder;
extern const FFCodec ff_mp3float_decoder;
extern const FFCodec ff_mp3_decoder;
extern const FFCodec ff_mp3adufloat_decoder;
extern const FFCodec ff_mp3adu_decoder;
extern const FFCodec ff_mp3on4float_decoder;
extern const FFCodec ff_mp3on4_decoder;
extern const FFCodec ff_mpc7_decoder;
extern const FFCodec ff_mpc8_decoder;
extern const FFCodec ff_msnsiren_decoder;
extern const FFCodec ff_nellymoser_encoder;
extern const FFCodec ff_nellymoser_decoder;
extern const FFCodec ff_on2avc_decoder;
extern const FFCodec ff_opus_encoder;
extern const FFCodec ff_opus_decoder;
extern const FFCodec ff_paf_audio_decoder;
extern const FFCodec ff_qcelp_decoder;
extern const FFCodec ff_qdm2_decoder;
extern const FFCodec ff_qdmc_decoder;
extern const FFCodec ff_ra_144_encoder;
extern const FFCodec ff_ra_144_decoder;
extern const FFCodec ff_ra_288_decoder;
extern const FFCodec ff_ralf_decoder;
extern const FFCodec ff_sbc_encoder;
extern const FFCodec ff_sbc_decoder;
extern const FFCodec ff_shorten_decoder;
extern const FFCodec ff_sipr_decoder;
extern const FFCodec ff_siren_decoder;
extern const FFCodec ff_smackaud_decoder;
extern const FFCodec ff_sonic_encoder;
extern const FFCodec ff_sonic_decoder;
extern const FFCodec ff_sonic_ls_encoder;
extern const FFCodec ff_tak_decoder;
extern const FFCodec ff_truehd_encoder;
extern const FFCodec ff_truehd_decoder;
extern const FFCodec ff_truespeech_decoder;
extern const FFCodec ff_tta_encoder;
extern const FFCodec ff_tta_decoder;
extern const FFCodec ff_twinvq_decoder;
extern const FFCodec ff_vmdaudio_decoder;
extern const FFCodec ff_vorbis_encoder;
extern const FFCodec ff_vorbis_decoder;
extern const FFCodec ff_wavarc_decoder;
extern const FFCodec ff_wavpack_encoder;
extern const FFCodec ff_wavpack_decoder;
extern const FFCodec ff_wmalossless_decoder;
extern const FFCodec ff_wmapro_decoder;
extern const FFCodec ff_wmav1_encoder;
extern const FFCodec ff_wmav1_decoder;
extern const FFCodec ff_wmav2_encoder;
extern const FFCodec ff_wmav2_decoder;
extern const FFCodec ff_wmavoice_decoder;
extern const FFCodec ff_ws_snd1_decoder;
extern const FFCodec ff_xma1_decoder;
extern const FFCodec ff_xma2_decoder;/* PCM codecs */
extern const FFCodec ff_pcm_alaw_encoder;
extern const FFCodec ff_pcm_alaw_decoder;
extern const FFCodec ff_pcm_bluray_encoder;
extern const FFCodec ff_pcm_bluray_decoder;
extern const FFCodec ff_pcm_dvd_encoder;
extern const FFCodec ff_pcm_dvd_decoder;
extern const FFCodec ff_pcm_f16le_decoder;
extern const FFCodec ff_pcm_f24le_decoder;
extern const FFCodec ff_pcm_f32be_encoder;
extern const FFCodec ff_pcm_f32be_decoder;
extern const FFCodec ff_pcm_f32le_encoder;
extern const FFCodec ff_pcm_f32le_decoder;
extern const FFCodec ff_pcm_f64be_encoder;
extern const FFCodec ff_pcm_f64be_decoder;
extern const FFCodec ff_pcm_f64le_encoder;
extern const FFCodec ff_pcm_f64le_decoder;
extern const FFCodec ff_pcm_lxf_decoder;
extern const FFCodec ff_pcm_mulaw_encoder;
extern const FFCodec ff_pcm_mulaw_decoder;
extern const FFCodec ff_pcm_s8_encoder;
extern const FFCodec ff_pcm_s8_decoder;
extern const FFCodec ff_pcm_s8_planar_encoder;
extern const FFCodec ff_pcm_s8_planar_decoder;
extern const FFCodec ff_pcm_s16be_encoder;
extern const FFCodec ff_pcm_s16be_decoder;
extern const FFCodec ff_pcm_s16be_planar_encoder;
extern const FFCodec ff_pcm_s16be_planar_decoder;
extern const FFCodec ff_pcm_s16le_encoder;
extern const FFCodec ff_pcm_s16le_decoder;
extern const FFCodec ff_pcm_s16le_planar_encoder;
extern const FFCodec ff_pcm_s16le_planar_decoder;
extern const FFCodec ff_pcm_s24be_encoder;
extern const FFCodec ff_pcm_s24be_decoder;
extern const FFCodec ff_pcm_s24daud_encoder;
extern const FFCodec ff_pcm_s24daud_decoder;
extern const FFCodec ff_pcm_s24le_encoder;
extern const FFCodec ff_pcm_s24le_decoder;
extern const FFCodec ff_pcm_s24le_planar_encoder;
extern const FFCodec ff_pcm_s24le_planar_decoder;
extern const FFCodec ff_pcm_s32be_encoder;
extern const FFCodec ff_pcm_s32be_decoder;
extern const FFCodec ff_pcm_s32le_encoder;
extern const FFCodec ff_pcm_s32le_decoder;
extern const FFCodec ff_pcm_s32le_planar_encoder;
extern const FFCodec ff_pcm_s32le_planar_decoder;
extern const FFCodec ff_pcm_s64be_encoder;
extern const FFCodec ff_pcm_s64be_decoder;
extern const FFCodec ff_pcm_s64le_encoder;
extern const FFCodec ff_pcm_s64le_decoder;
extern const FFCodec ff_pcm_sga_decoder;
extern const FFCodec ff_pcm_u8_encoder;
extern const FFCodec ff_pcm_u8_decoder;
extern const FFCodec ff_pcm_u16be_encoder;
extern const FFCodec ff_pcm_u16be_decoder;
extern const FFCodec ff_pcm_u16le_encoder;
extern const FFCodec ff_pcm_u16le_decoder;
extern const FFCodec ff_pcm_u24be_encoder;
extern const FFCodec ff_pcm_u24be_decoder;
extern const FFCodec ff_pcm_u24le_encoder;
extern const FFCodec ff_pcm_u24le_decoder;
extern const FFCodec ff_pcm_u32be_encoder;
extern const FFCodec ff_pcm_u32be_decoder;
extern const FFCodec ff_pcm_u32le_encoder;
extern const FFCodec ff_pcm_u32le_decoder;
extern const FFCodec ff_pcm_vidc_encoder;
extern const FFCodec ff_pcm_vidc_decoder;/* DPCM codecs */
extern const FFCodec ff_cbd2_dpcm_decoder;
extern const FFCodec ff_derf_dpcm_decoder;
extern const FFCodec ff_gremlin_dpcm_decoder;
extern const FFCodec ff_interplay_dpcm_decoder;
extern const FFCodec ff_roq_dpcm_encoder;
extern const FFCodec ff_roq_dpcm_decoder;
extern const FFCodec ff_sdx2_dpcm_decoder;
extern const FFCodec ff_sol_dpcm_decoder;
extern const FFCodec ff_xan_dpcm_decoder;
extern const FFCodec ff_wady_dpcm_decoder;/* ADPCM codecs */
extern const FFCodec ff_adpcm_4xm_decoder;
extern const FFCodec ff_adpcm_adx_encoder;
extern const FFCodec ff_adpcm_adx_decoder;
extern const FFCodec ff_adpcm_afc_decoder;
extern const FFCodec ff_adpcm_agm_decoder;
extern const FFCodec ff_adpcm_aica_decoder;
extern const FFCodec ff_adpcm_argo_decoder;
extern const FFCodec ff_adpcm_argo_encoder;
extern const FFCodec ff_adpcm_ct_decoder;
extern const FFCodec ff_adpcm_dtk_decoder;
extern const FFCodec ff_adpcm_ea_decoder;
extern const FFCodec ff_adpcm_ea_maxis_xa_decoder;
extern const FFCodec ff_adpcm_ea_r1_decoder;
extern const FFCodec ff_adpcm_ea_r2_decoder;
extern const FFCodec ff_adpcm_ea_r3_decoder;
extern const FFCodec ff_adpcm_ea_xas_decoder;
extern const FFCodec ff_adpcm_g722_encoder;
extern const FFCodec ff_adpcm_g722_decoder;
extern const FFCodec ff_adpcm_g726_encoder;
extern const FFCodec ff_adpcm_g726_decoder;
extern const FFCodec ff_adpcm_g726le_encoder;
extern const FFCodec ff_adpcm_g726le_decoder;
extern const FFCodec ff_adpcm_ima_acorn_decoder;
extern const FFCodec ff_adpcm_ima_amv_decoder;
extern const FFCodec ff_adpcm_ima_amv_encoder;
extern const FFCodec ff_adpcm_ima_alp_decoder;
extern const FFCodec ff_adpcm_ima_alp_encoder;
extern const FFCodec ff_adpcm_ima_apc_decoder;
extern const FFCodec ff_adpcm_ima_apm_decoder;
extern const FFCodec ff_adpcm_ima_apm_encoder;
extern const FFCodec ff_adpcm_ima_cunning_decoder;
extern const FFCodec ff_adpcm_ima_dat4_decoder;
extern const FFCodec ff_adpcm_ima_dk3_decoder;
extern const FFCodec ff_adpcm_ima_dk4_decoder;
extern const FFCodec ff_adpcm_ima_ea_eacs_decoder;
extern const FFCodec ff_adpcm_ima_ea_sead_decoder;
extern const FFCodec ff_adpcm_ima_iss_decoder;
extern const FFCodec ff_adpcm_ima_moflex_decoder;
extern const FFCodec ff_adpcm_ima_mtf_decoder;
extern const FFCodec ff_adpcm_ima_oki_decoder;
extern const FFCodec ff_adpcm_ima_qt_encoder;
extern const FFCodec ff_adpcm_ima_qt_decoder;
extern const FFCodec ff_adpcm_ima_rad_decoder;
extern const FFCodec ff_adpcm_ima_ssi_decoder;
extern const FFCodec ff_adpcm_ima_ssi_encoder;
extern const FFCodec ff_adpcm_ima_smjpeg_decoder;
extern const FFCodec ff_adpcm_ima_wav_encoder;
extern const FFCodec ff_adpcm_ima_wav_decoder;
extern const FFCodec ff_adpcm_ima_ws_encoder;
extern const FFCodec ff_adpcm_ima_ws_decoder;
extern const FFCodec ff_adpcm_ms_encoder;
extern const FFCodec ff_adpcm_ms_decoder;
extern const FFCodec ff_adpcm_mtaf_decoder;
extern const FFCodec ff_adpcm_psx_decoder;
extern const FFCodec ff_adpcm_sbpro_2_decoder;
extern const FFCodec ff_adpcm_sbpro_3_decoder;
extern const FFCodec ff_adpcm_sbpro_4_decoder;
extern const FFCodec ff_adpcm_swf_encoder;
extern const FFCodec ff_adpcm_swf_decoder;
extern const FFCodec ff_adpcm_thp_decoder;
extern const FFCodec ff_adpcm_thp_le_decoder;
extern const FFCodec ff_adpcm_vima_decoder;
extern const FFCodec ff_adpcm_xa_decoder;
extern const FFCodec ff_adpcm_xmd_decoder;
extern const FFCodec ff_adpcm_yamaha_encoder;
extern const FFCodec ff_adpcm_yamaha_decoder;
extern const FFCodec ff_adpcm_zork_decoder;/* subtitles */
extern const FFCodec ff_ssa_encoder;
extern const FFCodec ff_ssa_decoder;
extern const FFCodec ff_ass_encoder;
extern const FFCodec ff_ass_decoder;
extern const FFCodec ff_ccaption_decoder;
extern const FFCodec ff_dvbsub_encoder;
extern const FFCodec ff_dvbsub_decoder;
extern const FFCodec ff_dvdsub_encoder;
extern const FFCodec ff_dvdsub_decoder;
extern const FFCodec ff_jacosub_decoder;
extern const FFCodec ff_microdvd_decoder;
extern const FFCodec ff_movtext_encoder;
extern const FFCodec ff_movtext_decoder;
extern const FFCodec ff_mpl2_decoder;
extern const FFCodec ff_pgssub_decoder;
extern const FFCodec ff_pjs_decoder;
extern const FFCodec ff_realtext_decoder;
extern const FFCodec ff_sami_decoder;
extern const FFCodec ff_srt_encoder;
extern const FFCodec ff_srt_decoder;
extern const FFCodec ff_stl_decoder;
extern const FFCodec ff_subrip_encoder;
extern const FFCodec ff_subrip_decoder;
extern const FFCodec ff_subviewer_decoder;
extern const FFCodec ff_subviewer1_decoder;
extern const FFCodec ff_text_encoder;
extern const FFCodec ff_text_decoder;
extern const FFCodec ff_ttml_encoder;
extern const FFCodec ff_vplayer_decoder;
extern const FFCodec ff_webvtt_encoder;
extern const FFCodec ff_webvtt_decoder;
extern const FFCodec ff_xsub_encoder;
extern const FFCodec ff_xsub_decoder;/* external libraries */
extern const FFCodec ff_aac_at_encoder;
extern const FFCodec ff_aac_at_decoder;
extern const FFCodec ff_ac3_at_decoder;
extern const FFCodec ff_adpcm_ima_qt_at_decoder;
extern const FFCodec ff_alac_at_encoder;
extern const FFCodec ff_alac_at_decoder;
extern const FFCodec ff_amr_nb_at_decoder;
extern const FFCodec ff_eac3_at_decoder;
extern const FFCodec ff_gsm_ms_at_decoder;
extern const FFCodec ff_ilbc_at_encoder;
extern const FFCodec ff_ilbc_at_decoder;
extern const FFCodec ff_mp1_at_decoder;
extern const FFCodec ff_mp2_at_decoder;
extern const FFCodec ff_mp3_at_decoder;
extern const FFCodec ff_pcm_alaw_at_encoder;
extern const FFCodec ff_pcm_alaw_at_decoder;
extern const FFCodec ff_pcm_mulaw_at_encoder;
extern const FFCodec ff_pcm_mulaw_at_decoder;
extern const FFCodec ff_qdmc_at_decoder;
extern const FFCodec ff_qdm2_at_decoder;
extern FFCodec ff_libaom_av1_encoder;
extern const FFCodec ff_libaribb24_decoder;
extern const FFCodec ff_libcelt_decoder;
extern const FFCodec ff_libcodec2_encoder;
extern const FFCodec ff_libcodec2_decoder;
extern const FFCodec ff_libdav1d_decoder;
extern const FFCodec ff_libdavs2_decoder;
extern const FFCodec ff_libfdk_aac_encoder;
extern const FFCodec ff_libfdk_aac_decoder;
extern const FFCodec ff_libgsm_encoder;
extern const FFCodec ff_libgsm_decoder;
extern const FFCodec ff_libgsm_ms_encoder;
extern const FFCodec ff_libgsm_ms_decoder;
extern const FFCodec ff_libilbc_encoder;
extern const FFCodec ff_libilbc_decoder;
extern const FFCodec ff_libjxl_decoder;
extern const FFCodec ff_libjxl_encoder;
extern const FFCodec ff_libmp3lame_encoder;
extern const FFCodec ff_libopencore_amrnb_encoder;
extern const FFCodec ff_libopencore_amrnb_decoder;
extern const FFCodec ff_libopencore_amrwb_decoder;
extern const FFCodec ff_libopenjpeg_encoder;
extern const FFCodec ff_libopenjpeg_decoder;
extern const FFCodec ff_libopus_encoder;
extern const FFCodec ff_libopus_decoder;
extern const FFCodec ff_librav1e_encoder;
extern const FFCodec ff_librsvg_decoder;
extern const FFCodec ff_libshine_encoder;
extern const FFCodec ff_libspeex_encoder;
extern const FFCodec ff_libspeex_decoder;
extern const FFCodec ff_libsvtav1_encoder;
extern const FFCodec ff_libtheora_encoder;
extern const FFCodec ff_libtwolame_encoder;
extern const FFCodec ff_libuavs3d_decoder;
extern const FFCodec ff_libvo_amrwbenc_encoder;
extern const FFCodec ff_libvorbis_encoder;
extern const FFCodec ff_libvorbis_decoder;
extern const FFCodec ff_libvpx_vp8_encoder;
extern const FFCodec ff_libvpx_vp8_decoder;
extern FFCodec ff_libvpx_vp9_encoder;
extern FFCodec ff_libvpx_vp9_decoder;
/* preferred over libwebp */
extern const FFCodec ff_libwebp_anim_encoder;
extern const FFCodec ff_libwebp_encoder;
extern const FFCodec ff_libx262_encoder;
#if CONFIG_LIBX264_ENCODER
#include <x264.h>
#if X264_BUILD < 153
#define LIBX264_CONST
#else
#define LIBX264_CONST const
#endif
extern LIBX264_CONST FFCodec ff_libx264_encoder;
#endif
extern const FFCodec ff_libx264rgb_encoder;
extern FFCodec ff_libx265_encoder;
extern const FFCodec ff_libxavs_encoder;
extern const FFCodec ff_libxavs2_encoder;
extern const FFCodec ff_libxvid_encoder;
extern const FFCodec ff_libzvbi_teletext_decoder;/* text */
extern const FFCodec ff_bintext_decoder;
extern const FFCodec ff_xbin_decoder;
extern const FFCodec ff_idf_decoder;/* external libraries, that shouldn't be used by default if one of the* above is available */
extern const FFCodec ff_aac_mf_encoder;
extern const FFCodec ff_ac3_mf_encoder;
extern const FFCodec ff_h263_v4l2m2m_encoder;
extern const FFCodec ff_libaom_av1_decoder;
/* hwaccel hooks only, so prefer external decoders */
extern const FFCodec ff_av1_decoder;
extern const FFCodec ff_av1_cuvid_decoder;
extern const FFCodec ff_av1_mediacodec_decoder;
extern const FFCodec ff_av1_nvenc_encoder;
extern const FFCodec ff_av1_qsv_decoder;
extern const FFCodec ff_av1_qsv_encoder;
extern const FFCodec ff_av1_amf_encoder;
extern const FFCodec ff_libopenh264_encoder;
extern const FFCodec ff_libopenh264_decoder;
extern const FFCodec ff_h264_amf_encoder;
extern const FFCodec ff_h264_cuvid_decoder;
extern const FFCodec ff_h264_mf_encoder;
extern const FFCodec ff_h264_nvenc_encoder;
extern const FFCodec ff_h264_omx_encoder;
extern const FFCodec ff_h264_qsv_encoder;
extern const FFCodec ff_h264_v4l2m2m_encoder;
extern const FFCodec ff_h264_vaapi_encoder;
extern const FFCodec ff_h264_videotoolbox_encoder;
extern const FFCodec ff_hevc_amf_encoder;
extern const FFCodec ff_hevc_cuvid_decoder;
extern const FFCodec ff_hevc_mediacodec_decoder;
extern const FFCodec ff_hevc_mediacodec_encoder;
extern const FFCodec ff_hevc_mf_encoder;
extern const FFCodec ff_hevc_nvenc_encoder;
extern const FFCodec ff_hevc_qsv_encoder;
extern const FFCodec ff_hevc_v4l2m2m_encoder;
extern const FFCodec ff_hevc_vaapi_encoder;
extern const FFCodec ff_hevc_videotoolbox_encoder;
extern const FFCodec ff_libkvazaar_encoder;
extern const FFCodec ff_mjpeg_cuvid_decoder;
extern const FFCodec ff_mjpeg_qsv_encoder;
extern const FFCodec ff_mjpeg_qsv_decoder;
extern const FFCodec ff_mjpeg_vaapi_encoder;
extern const FFCodec ff_mp3_mf_encoder;
extern const FFCodec ff_mpeg1_cuvid_decoder;
extern const FFCodec ff_mpeg2_cuvid_decoder;
extern const FFCodec ff_mpeg2_qsv_encoder;
extern const FFCodec ff_mpeg2_vaapi_encoder;
extern const FFCodec ff_mpeg4_cuvid_decoder;
extern const FFCodec ff_mpeg4_mediacodec_decoder;
extern const FFCodec ff_mpeg4_omx_encoder;
extern const FFCodec ff_mpeg4_v4l2m2m_encoder;
extern const FFCodec ff_prores_videotoolbox_encoder;
extern const FFCodec ff_vc1_cuvid_decoder;
extern const FFCodec ff_vp8_cuvid_decoder;
extern const FFCodec ff_vp8_mediacodec_decoder;
extern const FFCodec ff_vp8_qsv_decoder;
extern const FFCodec ff_vp8_v4l2m2m_encoder;
extern const FFCodec ff_vp8_vaapi_encoder;
extern const FFCodec ff_vp9_cuvid_decoder;
extern const FFCodec ff_vp9_mediacodec_decoder;
extern const FFCodec ff_vp9_qsv_decoder;
extern const FFCodec ff_vp9_vaapi_encoder;
extern const FFCodec ff_vp9_qsv_encoder;// null codecs
extern const FFCodec ff_vnull_decoder;
extern const FFCodec ff_vnull_encoder;
extern const FFCodec ff_anull_decoder;
extern const FFCodec ff_anull_encoder;// The iterate API is not usable with ossfuzz due to the excessive size of binaries created
#if CONFIG_OSSFUZZ
const FFCodec * codec_list[] = {NULL,NULL,NULL
};
#else
#include "libavcodec/codec_list.c"
#endifstatic AVOnce av_codec_static_init = AV_ONCE_INIT;
static void av_codec_init_static(void)
{for (int i = 0; codec_list[i]; i++) {if (codec_list[i]->init_static_data)codec_list[i]->init_static_data((FFCodec*)codec_list[i]);}
}const AVCodec *av_codec_iterate(void **opaque)
{uintptr_t i = (uintptr_t)*opaque;const FFCodec *c = codec_list[i];ff_thread_once(&av_codec_static_init, av_codec_init_static);if (c) {*opaque = (void*)(i + 1);return &c->p;}return NULL;
}static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id)
{switch(id){//This is for future deprecatec codec ids, its empty since//last major bump but will fill up again over time, please don't remove itdefault : return id;}
}static const AVCodec *find_codec(enum AVCodecID id, int (*x)(const AVCodec *))
{const AVCodec *p, *experimental = NULL;void *i = 0;id = remap_deprecated_codec_id(id);while ((p = av_codec_iterate(&i))) {if (!x(p))continue;if (p->id == id) {if (p->capabilities & AV_CODEC_CAP_EXPERIMENTAL && !experimental) {experimental = p;} elsereturn p;}}return experimental;
}const AVCodec *avcodec_find_encoder(enum AVCodecID id)
{return find_codec(id, av_codec_is_encoder);
}const AVCodec *avcodec_find_decoder(enum AVCodecID id)
{return find_codec(id, av_codec_is_decoder);
}static const AVCodec *find_codec_by_name(const char *name, int (*x)(const AVCodec *))
{void *i = 0;const AVCodec *p;if (!name)return NULL;while ((p = av_codec_iterate(&i))) {if (!x(p))continue;if (strcmp(name, p->name) == 0)return p;}return NULL;
}const AVCodec *avcodec_find_encoder_by_name(const char *name)
{return find_codec_by_name(name, av_codec_is_encoder);
}const AVCodec *avcodec_find_decoder_by_name(const char *name)
{return find_codec_by_name(name, av_codec_is_decoder);
}
2.通过编码器得到编码器上下文
AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
/*** Allocate an AVCodecContext and set its fields to default values. The* resulting struct should be freed with avcodec_free_context().** @param codec if non-NULL, allocate private data and initialize defaults* for the given codec. It is illegal to then call avcodec_open2()* with a different codec.* If NULL, then the codec-specific defaults won't be initialized,* which may result in suboptimal default settings (this is* important mainly for encoders, e.g. libx264).** @return An AVCodecContext filled with default values or NULL on failure.*/
AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
3.通过编码器上下文 打开编码器
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
参数:
AVCodecContext *avctx:传递的编码器上下文
const AVCodec *codec:如果我们在 创建编码器的时候,传递的是nullptr,那么这时候就要传递具体的codec
AVDictionary **options:一个包含AVCodecContext和编解码器私有选项的字典。返回时,此对象将填充未找到的选项。(这个红色部分的翻译很二,完全看不懂啥意思,),
重新翻译:(可选)一个包含编解码器特定选项的字符串。 这是一个以key=value形式的选项列表,用,分隔。如果不需要额外的选项,可以直接传递NULL。关于 AVDictionary,很显然,这个AVDictionary是为了AVCodecContext 用的,也就是我们指定的编码器(例如h264)有一些参数需要设置,可以通过AVDictionary设置。
我们有两个疑问在这里:
注意的是通过AVDictionary设置的是 特定编码器特定的参数,如果是通用的参数,avcodec中是有key的,通过avcodec设置就好。
1.怎么知道特定的编码器有哪些参数要设置(例如h264编码器有哪些特殊的参数)
从这里看出,如果要设置这些参数,首先要明白h264的原理,文件结构,因此这里也很有必要学习x264。 另外这里可以参考如何知道x264的参数,了解x265的参数。
2.如何使用 AVDictionary 设定这些特定的参数
核心就是 使用 av_dict_set 一系列方法。
这里注意的是:如果有特定的参数,设定到AVDictionary后,才能使用 open。
3.还有一种方法是通过 av_opt_set 设定这些特殊的参数
核心是使用 av_opt_set 一系列方法。
例如
/// 恒定速率因子(CRF)av_opt_set_int(c->priv_data, "crf", 23, 0);
/*** Initialize the AVCodecContext to use the given AVCodec. Prior to using this* function the context has to be allocated with avcodec_alloc_context3().** The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),* avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for* retrieving a codec.** @note Always call this function before using decoding routines (such as* @ref avcodec_receive_frame()).** @code* av_dict_set(&opts, "b", "2.5M", 0);* codec = avcodec_find_decoder(AV_CODEC_ID_H264);* if (!codec)* exit(1);** context = avcodec_alloc_context3(codec);** if (avcodec_open2(context, codec, opts) < 0)* exit(1);* @endcode** @param avctx The context to initialize.* @param codec The codec to open this context for. If a non-NULL codec has been* previously passed to avcodec_alloc_context3() or* for this context, then this parameter MUST be either NULL or* equal to the previously passed codec.* @param options A dictionary filled with AVCodecContext and codec-private options.* On return this object will be filled with options that were not found.** @return zero on success, a negative value on error* @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),* av_dict_set(), av_opt_find().*/
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
4. 将avframe数据发送给 编码器上下文
int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame);
当然发送前,avframe里面是要有数据的。
/*** Supply a raw video or audio frame to the encoder. Use avcodec_receive_packet()* to retrieve buffered output packets.** @param avctx codec context* @param[in] frame AVFrame containing the raw audio or video frame to be encoded.* Ownership of the frame remains with the caller, and the* encoder will not write to the frame. The encoder may create* a reference to the frame data (or copy it if the frame is* not reference-counted).* It can be NULL, in which case it is considered a flush* packet. This signals the end of the stream. If the encoder* still has packets buffered, it will return them after this* call. Once flushing mode has been entered, additional flush* packets are ignored, and sending frames will return* AVERROR_EOF.** For audio:* If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame* can have any number of samples.* If it is not set, frame->nb_samples must be equal to* avctx->frame_size for all frames except the last.* The final frame may be smaller than avctx->frame_size.* @retval 0 success* @retval AVERROR(EAGAIN) input is not accepted in the current state - user must* read output with avcodec_receive_packet() (once all* output is read, the packet should be resent, and the* call will not fail with EAGAIN).* @retval AVERROR_EOF the encoder has been flushed, and no new frames can* be sent to it* @retval AVERROR(EINVAL) codec not opened, it is a decoder, or requires flush* @retval AVERROR(ENOMEM) failed to add packet to internal queue, or similar* @retval "another negative error code" legitimate encoding errors*/
int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame);
5.从编码器上下文获得 avpacket
int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);
当然在avpacket 的时候,avpacket的空间是需要分配好的。
注意的是1:一帧avframe发送到 解码器上下文,有可能有好几帧avpacket 被解码器上下文 发送出来。
因此在 avcodec_send_frame 调用后,avcodec_receive_packet需要在一个循环中接受 解码器上下文发送出来的 avpacket。循环结束的条件是:avcodec_receive_packet的返回值,注意的是,这个返回值有好几种情况,要分开处理。
注意的是2:另外,循环结束后,还需要通过 avcodec_send_frame 的第二个参数为null,再刷新一下 编码器上下文的缓存。
注意的是3:在循环中,每次通过 avcodec_receive_packet 获得avpacket之后,还应该将avpacket通过 av_packet_unref 将avpacket的引用计数-1,防止内存泄漏。
/*** Read encoded data from the encoder.** @param avctx codec context* @param avpkt This will be set to a reference-counted packet allocated by the* encoder. Note that the function will always call* av_packet_unref(avpkt) before doing anything else.* @retval 0 success* @retval AVERROR(EAGAIN) output is not available in the current state - user must* try to send input* @retval AVERROR_EOF the encoder has been fully flushed, and there will be no* more output packets* @retval AVERROR(EINVAL) codec not opened, or it is a decoder* @retval "another negative error code" legitimate encoding errors*/
int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);
6 代码
相关文章:
FFmpeg 4.3 音视频-多路H265监控录放C++开发十三:将AVFrame转换成AVPacket。视频编码原理.编码相关api
前提: 从前面的学习我们知道 AVFrame中是最原始的 视频数据,这一节开始我们需要将这个最原始的视频数据 压缩成 AVPacket数据, 我们前面,将YUV数据或者 RGBA 数据装进入了 AVFrame里面,并且在SDL中显示。 也就是说&…...
算法——移除元素(leetcode27)
对于移除元素这道题来讲,我首先想到的还是双指针,根据题目要求我们需要在给定的一组数组中找出与目标值不同的元素数量并且将与目标值不同的元素全部移至数组左边右边则不需关注数组元素的大小,我们利用两个指针一个指向数组首部位置(左指针&…...
『OpenCV-Python』安装以及图像的读取、显示、保存
点赞 + 关注 + 收藏 = 学会了 OpenCV 是一个开源的计算机视觉库,广泛应用于图像处理、机器学习和实时计算机视觉应用。比如图像和视频的滤镜和降噪、物体检测、人脸识别、证件号识别、车牌识别等应用。当然,也有其他工具可以对这些领域做支持,但本专栏是介绍 OpenCV 的,所…...
python开发桌面应用(跨平台) 全流程
前言 之前开发一些软件,亚马逊商品分析相关软件,但是基本上是通过程序猿控制台命令启动,同时在启动之前,还要进行程序依赖包,这对于非开发人员而言,简直是一种灾难, 为了让软件对于小白更加易用, 打算将其封装成应用程序(跨平台), 下面带大家一起完成python开发桌面应用的三步…...
el-table-column prop值根据数组获取
方法一: 可以给el-table-column添加一个属性:formatter,代码如下: 这里是因为多个列都需要同样的计算,所以使用column.property获取属性,不然可以直接row.属性 方法二: 直接在template scope …...
MySQL_聚合函数分组查询
上篇复习: 设计数据库时的三大范式1.第一范式,一行数据中每一列不可再分 关系型数据库必须要满足第一范式,设计表的时候,如果每一列都可以用SQL规定的数据类型描述,就天然满足第一范式. 2.第二范式,在第一…...
PPT 制作神器!Markdown 轻松变幻灯片!
做过幻灯片的朋友们都知道,PPT 的制作常常是费时费力的工作。尤其是需要不断调整布局和设计的时候。 而现在,GitHub 上有一款开源免费的 PPT 制作工具 moffee,能够极大地简化这一过程。你只需通过简单的 Markdown 编写内容,即可快…...
一七八、Node.js PM2使用介绍
PM2 是一个强大的生产级 Node.js 进程管理器,提供了自动重启、负载均衡和进程监控等功能。适用于开发和生产环境,简化了 Node.js 应用程序的管理和维护。 PM2 安装 1. 使用 npm 安装 PM2 npm i -g pm2latest-g:全局安装。latest:…...
基于CSU18M92芯片的蓝牙体重秤方案
传统体重秤只有一个数据的显示功能,将需称重物体放置在体重秤上,体重秤显示当前物体的数据,物体移开,数据消失,体重秤没有数据记录、存储、分析功能。智能体重秤与传统体重秤相比,可通过低功耗蓝牙与手机AP…...
深度学习经典模型之VGGNet
1 VGGNet 1.1 模型介绍 VGGNet是由牛津大学视觉几何小组(Visual Geometry Group, VGG)提出的一种深层卷积网络结构,他们以7.32%的错误率赢得了2014年ILSVRC分类任务的亚军(冠军由GoogLeNet以6.65%的错误率夺得)和…...
Axure网络短剧APP端原型图,竖屏微剧视频模版40页
作品概况 页面数量:共 40 页 使用软件:Axure RP 9 及以上,非软件无源码 适用领域:短剧、微短剧、竖屏视频 作品特色 本作品为网络短剧APP的Axure原型设计图,定位属于免费短剧软件,类似红果短剧、河马剧场…...
ES + SkyWalking + Spring Boot:日志分析与服务监控(三)
目录 一、搭建SkyWalking 1.1 版本选择 1.2 下载安装 1.3 配置启动 1.4 SkyWalking UI介绍 二、Springboot项目使用 2.1 Agent下载 2.2 Agent配置skywalking oap地址 2.3 IDEA配置Agent地址 2.4 生成的ES索引介绍 三、在kibana上查看日志 四、问题和解决 3.1 日志…...
php 如何将数组转成对象数组
1. 使用 (object) 操作符: “php $array [‘name’ > ‘John’, ‘age’ > 25]; $object (object) $array; // 访问对象属性 echo $object->name; // 输出: John echo $object->age; // 输出: 25 “ 2. 使用 (stdClass): “php $array …...
HTB:Photobomb[WriteUP]
目录 连接至HTB服务器并启动靶机 使用nmap对靶机进行端口开放扫描 再次使用nmap对靶机开放端口进行脚本、服务扫描 使用ffuf进行简单的子域名扫描 使用浏览器直接访问该域名 选取一个照片进行下载,使用Yakit进行抓包 USER_FLAG:a9afd9220ae2b5731…...
图文组合-pytorch实现
在图文组合任务中,常见的图文融合方式有多种,比如简单的拼接、加权求和、注意力机制、跨模态Transformer等。为了让图片充分补充文本的语义信息,我们可以使用一种简单且有效的图文融合方法,比如通过注意力机制。 我们可以让文本特…...
CentOS AppStream 8 手动更新 yum源
由于CentOS 8的官方支持已在2021年12月31日结束,官方镜像中的CentOS 8包已被移除。因此,如果您仍然需要运行CentOS 8并更新其yum源,您可以考虑使用以下步骤来配置一个可用的yum源,例如阿里云的镜像源。 https://mirrors.aliyun.co…...
虚拟化环境中香港服务器内存如何分配与管理?
虚拟化技术通过创建抽象层来模拟硬件资源,使得可以在单一硬件上运行多个操作系统实例。这通常涉及两个主要组件:管理程序(Hypervisor)和虚拟机监控器(VMM)。管理程序直接安装在物理硬件上,负责创建和管理虚拟机,而VMM则用于监控和…...
Android源码中如何编译出fastboot.exe和adb.exe程序
1、方案背景说明 在进行android项目开发时,如果通用的fastboot工具无法满足项目的定制话的需求时,就需要对fastboot工具的源码进行自定义修改,并编译成新的fastboot和adb工具。 由于安卓源码的的编译通常使用的是ubuntu系统,默认…...
C++ 参数传递 笔记
目录 1、输入参数的传递方式-选择传值还是传引用? 处理用户信息 处理坐标 处理配置 处理ID 2、对于需要修改的参数,使用非const引用传递 有趣的例外:警惕表象的迷惑 需要警惕的陷阱 “糟糕”的update方法: “完美”的set_name与set…...
【Linux】注释和配置文件的介绍
目录 一、help vim-modes指令 二、vim命令模式下的注释 1、直接注释: 2、快捷键注释(比较麻烦,了解即可) 三、vim的配置文件 .vimrc 四、sudo指令的相关问题 一、help vim-modes指令 在底行模式输入该指令可以用于查看vim的十…...
为什么需要建设工程项目管理?工程项目管理有哪些亮点功能?
在建筑行业,项目管理的重要性不言而喻。随着工程规模的扩大、技术复杂度的提升,传统的管理模式已经难以满足现代工程的需求。过去,许多企业依赖手工记录、口头沟通和分散的信息管理,导致效率低下、成本失控、风险频发。例如&#…...
Python实现prophet 理论及参数优化
文章目录 Prophet理论及模型参数介绍Python代码完整实现prophet 添加外部数据进行模型优化 之前初步学习prophet的时候,写过一篇简单实现,后期随着对该模型的深入研究,本次记录涉及到prophet 的公式以及参数调优,从公式可以更直观…...
将对透视变换后的图像使用Otsu进行阈值化,来分离黑色和白色像素。这句话中的Otsu是什么意思?
Otsu 是一种自动阈值化方法,用于将图像分割为前景和背景。它通过最小化图像的类内方差或等价地最大化类间方差来选择最佳阈值。这种方法特别适用于图像的二值化处理,能够自动确定一个阈值,将图像中的像素分为黑色和白色两类。 Otsu 方法的原…...
OkHttp 中实现断点续传 demo
在 OkHttp 中实现断点续传主要通过以下步骤完成,核心是利用 HTTP 协议的 Range 请求头指定下载范围: 实现原理 Range 请求头:向服务器请求文件的特定字节范围(如 Range: bytes1024-) 本地文件记录:保存已…...
Psychopy音频的使用
Psychopy音频的使用 本文主要解决以下问题: 指定音频引擎与设备;播放音频文件 本文所使用的环境: Python3.10 numpy2.2.6 psychopy2025.1.1 psychtoolbox3.0.19.14 一、音频配置 Psychopy文档链接为Sound - for audio playback — Psy…...
VTK如何让部分单位不可见
最近遇到一个需求,需要让一个vtkDataSet中的部分单元不可见,查阅了一些资料大概有以下几种方式 1.通过颜色映射表来进行,是最正规的做法 vtkNew<vtkLookupTable> lut; //值为0不显示,主要是最后一个参数,透明度…...
WordPress插件:AI多语言写作与智能配图、免费AI模型、SEO文章生成
厌倦手动写WordPress文章?AI自动生成,效率提升10倍! 支持多语言、自动配图、定时发布,让内容创作更轻松! AI内容生成 → 不想每天写文章?AI一键生成高质量内容!多语言支持 → 跨境电商必备&am…...
Python如何给视频添加音频和字幕
在Python中,给视频添加音频和字幕可以使用电影文件处理库MoviePy和字幕处理库Subtitles。下面将详细介绍如何使用这些库来实现视频的音频和字幕添加,包括必要的代码示例和详细解释。 环境准备 在开始之前,需要安装以下Python库:…...
【学习笔记】深入理解Java虚拟机学习笔记——第4章 虚拟机性能监控,故障处理工具
第2章 虚拟机性能监控,故障处理工具 4.1 概述 略 4.2 基础故障处理工具 4.2.1 jps:虚拟机进程状况工具 命令:jps [options] [hostid] 功能:本地虚拟机进程显示进程ID(与ps相同),可同时显示主类&#x…...
Maven 概述、安装、配置、仓库、私服详解
目录 1、Maven 概述 1.1 Maven 的定义 1.2 Maven 解决的问题 1.3 Maven 的核心特性与优势 2、Maven 安装 2.1 下载 Maven 2.2 安装配置 Maven 2.3 测试安装 2.4 修改 Maven 本地仓库的默认路径 3、Maven 配置 3.1 配置本地仓库 3.2 配置 JDK 3.3 IDEA 配置本地 Ma…...
