
ffmpeg入门
形形色色的人
这个作者很懒,什么都没留下…
展开
-
FLV 协议
原创 2020-10-15 09:56:36 · 252 阅读 · 0 评论 -
YUV player
#include <stdio.h>#include <string.h>#include <SDL.h>const int bpp=12;#define BLOCK_SIZE 4096000//event message#define REFRESH_EVENT (SDL_USEREVENT + 1)#define QUIT_EVENT (SDL_USEREVENT + 2)int thread_exit=0;int refr...原创 2020-10-13 10:15:09 · 1113 阅读 · 0 评论 -
ffmpeg 常用命令
截取视频片段:ffmpeg -i 1.mp4 -ss 0:0 -t 10 -s 640x480 test.mp4解码为yuv格式:ffmpeg -i test.mp4 -s 640x480 -pix_fmt yuv420p test.yuv制定的格式是yuv420p,也就是rawvideo (I420 / 0x30323449)Input #0, rawvideo, from 'test.yuv': Duration: 00:00:07.20, start: 0.000000,..原创 2020-10-12 19:54:01 · 443 阅读 · 0 评论 -
YUV420格式介绍
参考:https://www.fourcc.org/yuv.php原创 2020-10-12 17:00:46 · 408 阅读 · 0 评论 -
ffmpeg decode resample
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <windows.h>extern "C"{#include <libavutil/frame.h>#include <libavutil/mem.h>#include <libavcodec/avcodec.h>#include <libavformat/av...原创 2020-09-29 17:30:30 · 216 阅读 · 0 评论 -
音频重采样,生成packet格式的PCM数据
1. int64_t src_ch_layout = AV_CH_LAYOUT_MONO; int64_t dst_ch_layout = AV_CH_LAYOUT_STEREO; int src_rate = 16000; int dst_rate = 44100; AVSampleFormat src_fmt = AV_SAMPLE_FMT_S16; AVSampleFormat dst_fmt = AV_SAMPLE_FMT_S16P;对上面的PC...原创 2020-09-25 11:22:40 · 596 阅读 · 0 评论 -
windows 上ffplay 遇到的问题 WASAPI can’t initialize audio client
问题描述:1.ffplay播放没有声音SDL_OpenAudio (2 channels, 44100 Hz): WASAPI can’t initialize audio client解决办法:set SDL_AUDIODRIVER=directsound原创 2020-07-26 20:22:45 · 1420 阅读 · 0 评论 -
FFMPEG 实现音频resample(重采样)
#define __STDC_CONSTANT_MACROS#include <string.h>extern "C"{#include "libavutil/avutil.h"#include "libavdevice/avdevice.h"#include "libavformat/avformat.h"#include "libavcodec/avcodec.h"#include "libswresample/swresample.h"#include "lib...原创 2020-09-14 17:28:43 · 2110 阅读 · 3 评论 -
FFMPEG decode mp4, SDL play
#include <iostream>//Refresh Event#define SFM_REFRESH_EVENT (SDL_USEREVENT + 1)#define SFM_BREAK_EVENT (SDL_USEREVENT + 2)extern "C" { #include <libavformat/avformat.h> #include <libavcodec/avcodec.h> #includ.原创 2020-09-11 17:31:28 · 291 阅读 · 0 评论 -
PCM音频数据
目录什么是PCM? PCM数据格式 FFmpeg支持的PCM数据格式 FFmpeg中Packed和Planar的PCM数据区别 字节序 PCM音频数据的处理 参考1. 什么是PCM?PCM(Pulse Code Modulation,脉冲编码调制)音频数据是未经压缩的音频采样数据裸流,它是由模拟信号经过采样、量化、编码转换成的标准数字音频数据。描述PCM数据的6个参数:Sample Rate : 采样频率。8kHz(电话)、44.1kHz(CD)、48kHz(DVD)。 Sa转载 2020-09-05 21:39:02 · 425 阅读 · 0 评论 -
avcodec_encode_audio2返回-22
错误原因该函数的主要功能:根据音频编码器和音频frame数据编码成音频packt数据。 返回-22主要原因:参数错误,具体如下 音频编码器的参数(声道数,采样率,采样格式,位宽,采样数)和frame的参数不一致。 编码格式对应的采样数和frame的采样数不一致。 只要声道数,采样率,采样格式,位宽,采样数,任何一个参数不一致,都需要进行重采样。 AAC对应的采样数(nb_samples)和frame大小(frame_size)都是1024. AAC对应的采样数(nb_samples)转载 2020-09-04 16:28:01 · 1800 阅读 · 0 评论 -
FFMPEG encode audio
#include <stdint.h>#include <stdio.h>#include <stdlib.h>extern "C"{#include <libavcodec/avcodec.h>#include <libavutil/channel_layout.h>#include <libavutil/common.h>#include <libavutil/frame.h>#inclu...原创 2020-09-04 13:33:13 · 317 阅读 · 1 评论 -
FFMPEG 音频编码
extern "C"{#include "libavformat/avformat.h"#include "libavcodec/avcodec.h"}/* check that a given sample format is supported by the encoder */static int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat sample_fmt){ const enum AVSampleFo..原创 2020-09-03 23:43:47 · 754 阅读 · 1 评论 -
FFMPEG编码元素YUV数据为H264格式
#include <stdio.h>#define __STDC_CONSTANT_MACROS#ifdef _WIN32//Windowsextern "C"{#include "libavutil/opt.h"#include "libavcodec/avcodec.h"#include "libavformat/avformat.h"};#else//Linux...#ifdef __cplusplusextern "C"{#endif#incl...转载 2020-09-03 16:28:59 · 296 阅读 · 0 评论 -
FFMPEG获取摄像头数据,并编码为H264格式
#define __STDC_CONSTANT_MACROS#include <string.h>extern "C"{#include "libavutil/avutil.h"#include "libavdevice/avdevice.h"#include "libavformat/avformat.h"#include "libavcodec/avcodec.h"#include "libswresample/swresample.h"#include "lib...原创 2020-09-03 16:00:41 · 1438 阅读 · 0 评论 -
常用视频像素格式 YUV422 & YUV420
像素格式描述了像素数据存储所用的格式,定义了像素在内存中的编码方式。RGB和YUV为两种经常使用的像素格式。RGB格式一般较为熟悉,RGB图像具有三个通道R、G、B,分别对应红、绿、蓝三个分量,由三个分量的值决定颜色;通常,会给RGB图像加一个通道alpha,即透明度,于是共有四个分量共同控制颜色。YUV格式(YCrCb)是指将亮度参量Y和色度参量U/V分开表示的像素格式,主要用于优化彩色视频信号的传输。YUV像素格式来源于RGB像素格式,通过公式运算,YUV三分量可以还原出RGB,YUV转R转载 2020-08-17 13:46:48 · 5816 阅读 · 0 评论 -
FFMPEG 编程
1. Log#define _CRT_SECURE_NO_WARNINGSextern "C"{#include <libavformat/avformat.h>}int main(){ av_log_set_level(AV_LOG_INFO); av_log(NULL, AV_LOG_PANIC, "1.Hello FFMPEG!\n"); av_log(NULL, AV_LOG_FATAL, "2.Hello FFMPEG!\n"); av_log(NULL,原创 2020-08-22 22:09:40 · 1803 阅读 · 0 评论 -
RTMP传输流程
素材来源于-李超(音视频小白系统入门课)FCPublishStream FC flushCommunicationmetaData 发送音视频的基本信息视频 分辨率 帧率 音频采样大小采样信息 通道数play 播放哪个频道的音视频set buffer size 设置缓冲区大小 让你播放更平滑 不会卡顿Stream Begin 流开始onStatus...原创 2020-08-20 08:55:47 · 713 阅读 · 0 评论 -
H264编码系列之profile & level控制
Sequence Paramater Set(SPS)(序列参数集)(1). profile_idc:标识当前H.264码流的profile。我们知道,H.264中定义了三种常用的档次profile:基准档次:baseline profile; 主要档次:main profile; 扩展档次:extended profile;在H.264的SPS中,第一个字节表示profile_idc,根据profile_idc的值可以确定码流符合哪一种档次。判断规律为:profile_idc = 6转载 2020-08-11 16:34:36 · 4201 阅读 · 0 评论 -
FFMPEG基础-图像的空域和频域变换
(1)图像在空间域上表现为一个个的像素点,而这些像素点对应的也相当于离散的二维信号,所以要将空域转化为频域,需要将离散的二维信号利用二维傅里叶变换转化为二维坐标上的幅值变化。(2)从一维到二维的转化: 在一维上,离散的多个信号组成时域上的函数,那么根据傅里叶可知,一个函数可由多个正余弦函数表示,这样就将时域上的函数分解成多个正余弦函数,通过提取多个正余弦函数的幅值就可以得到频域图像。傅里叶函数相当于光学上的棱镜,我们通过分析频率就可以分析每个正余弦函数。 那么在...转载 2020-07-30 10:51:41 · 902 阅读 · 0 评论 -
FFMPEG H264篇
0. H264压缩比格式YUV420,分辨率640x480,帧率15fps/s计算出码率为1.5x640x480x15x8=55,296,000 约55.3Mb/s建议码率5000kpbsH264压缩比 1%原创 2020-07-29 09:31:29 · 968 阅读 · 0 评论 -
FFMPEG 提取YUV数据
ffmpeg -i ~/Videos/QLED.mp4 -filter_complex "extractplanes=y+u+v[y][u][v]" -map "[y]" y.yuv -map "[u]" u.yuv -map ["v"] v.yuvOutput #0, rawvideo, to 'y.yuv': Metadata: major_brand : isom minor_version : 512 compatible_brands: mp41...原创 2020-07-28 10:45:54 · 1139 阅读 · 0 评论 -
FFMPEG 抓取virtual-audio-capturer 数据
0. 查看本机virtual-audio-capturer录取音频的默认数据。C:\Users\lili>ffmpeg -f dshow -i audio="virtual-audio-capturer" test.aacffmpeg version N-93815-g181031906e Copyright (c) 2000-2019 the FFmpeg developers built with gcc 8.3.1 (GCC) 20190414 configuration: --e..原创 2020-07-26 18:05:15 · 2602 阅读 · 0 评论 -
FFMPEG 录制PCM音频数据
#define __STDC_CONSTANT_MACROS#include <string.h>extern "C"{#include "libavutil/avutil.h"#include "libavdevice/avdevice.h"#include "libavformat/avformat.h"#include "libavcodec/avcodec.h"#include "libswresample/swresample.h"#include "lib...原创 2020-07-24 14:57:18 · 810 阅读 · 0 评论 -
Ffmpeg 采集设备
1.Ubuntu 16.04arecord -l 音频输入设备 arecord -l **** List of CAPTURE Hardware Devices **** card 0: PCH [HDA Intel PCH], device 0: ALC662 rev3 Analog [ALC662 rev3 Analog] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA ..原创 2020-07-21 10:23:42 · 1068 阅读 · 0 评论 -
ffmpeg API 打印音视频信息 media info
#include <libavformat/avformat.h>int main(int argc, char *argv[]){ int err_code; char errors[1024]; AVFormatContext *fmt_ctx = NULL; if(argc < 2){ fprintf(stderr...原创 2020-04-21 23:02:29 · 335 阅读 · 0 评论