ffmpeg使用笔记:image to video

隗高旻
2023-12-01

1 常用参数

常用参数含义参考:https://www.cnblogs.com/wainiwann/p/4128154.html

2 丢帧问题

丢帧问题参考:https://superuser.com/questions/452542/ffmpeg-drops-frames-when-encoding-a-png-image-sequence-into-an-x264-mp4-video
图像序列转换成视频时出现丢帧问题,主要是输入帧率参数没有进行配置(默认是-r=25fps),所以只需要设置输入帧率-r=1即可解决

3 序列图像image转video

1080p脚本bat

set path_i=G:\xxx
set path_o=G:\ts
set fmrate=1
set pix_wh=1920x1080
ffmpeg -f image2 -start_number 0 -r %fmrate% -i "%path_i%\%%05d.bmp" -b:v 8000k -maxrate 10000k -vcodec libx264 -r %fmrate% -pix_fmt yuv420p -s %pix_wh%  %path_o%\xxx_%pix_wh%_%fmrate%Hz_420p.ts

UHD脚本bat

set path_i=G:\xxx
set path_o=G:\ts
set fmrate=1
set pix_wh=3840x2160
ffmpeg -report -f image2 -start_number 0 -r %fmrate% -i "%path_i%\%%05d.bmp" -b:v 25000k -maxrate 30000k -vcodec libx265 -r %fmrate% -pix_fmt yuv420p -s %pix_wh% %path_o%\xxx_%pix_wh%_%fmrate%Hz_420p.ts

参考1:https://github.com/stoyanovgeorge/ffmpeg/wiki/Video-Encoding-width-FFMEPG 重点
参考2:https://github.com/stoyanovgeorge/ffmpeg/wiki 重点
1080p cdn标准压缩

set path_i=G:\xxx
set path_o=G:\ts
set fmrate=25
set pix_wh=1920x1080
ffmpeg -report -f image2 -start_number 0 -r %fmrate% -i "%path_i%\%%05d.bmp" -c:v libx264 -x264-params nal-hrd=cbr -b:v 8M -minrate:v 8M -maxrate:v 8M -bufsize:v 8M -r %fmrate% -pix_fmt yuv420p -s %pix_wh% %path_o%\xxx_%pix_wh%_%fmrate%Hz_420p.ts
//-c:v libx264 h264编码器
//-b:v...  8M码率
//-x264-params nal-hrd=cbr      cbr模式编码

4K cdn标准压缩

set path_i=G:\xxx
set path_o=G:\ts
set fmrate=25
set pix_wh=3840x2160
ffmpeg -report -f image2 -start_number 0 -r %fmrate% -i "%path_i%\%%06d.bmp" -c:v libx265 -b:v 25M -x265-params strict-cbr=1:vbv-bufsize=25000:vbv-maxrate=25000 -r %fmrate% -pix_fmt yuv420p -s %pix_wh% %path_o%\xxx_%pix_wh%_%fmrate%Hz_420p.ts
//-c:v libx265 h265编码器
//-b:v 25M 25M码率
//-x265-params strict-cbr=1:vbv-bufsize=25000:vbv-maxrate=25000      cbr模式编码

5 video转序列图像image

set fmrate=25
set path_i=G:\pattern
set path_o=G:\pattern
set fname=xxx.ts
mkdir subpath=%path_o%\%fname%_0
ffmpeg.exe -ss 00:00:00 -t 00:00:02 -i %path_i%\%fname%    -f image2 %subpath%\%%05d.bmp

6 YUV序列转序列图像image

使用ffmpeg进行图片转换:
ffmpeg  -i a.bmp -pix_fmt yuv420p -y a.yuv
ffmpeg -pix_fmt yuv420p -video_size 352x288 -i a.yuv  -y b.bmp
查看ffmpeg支持的-pix_fmt:
ffmpeg -pix_fmt lis
 类似资料: