当前位置:网站首页>Ffmpeg one / more pictures synthetic video
Ffmpeg one / more pictures synthetic video
2022-07-03 03:28:00 【Water W】
Catalog
ffmpeg Synthesize a picture into a video , And set the video duration
ffmpeg And opencv Combined Multi picture composite video
ffmpeg Synthesize a picture into a video , And set the video duration
(1) Execute code ,
Complete code :
import subprocess
import os
# Synthesize a picture into a video , Set the video duration
cmdLine = "ffmpeg -r 25 -loop 1 -i images/img1.png -pix_fmt yuv420p -vcodec libx264 -b:v 600k -r:v 25 -preset medium -crf 30 -s 720x576 -vframes 250 -r 25 -t 10 a.mp4"
subprocess.call(cmdLine, shell=True)
(2) Running results :

ffmpeg And opencv Combined Multi picture composite video
Be careful : Attention should be paid to the selection of parameters and image size
img_root: yes jpg The way to store the pictures
out_root: yes avi The path to save the video
string = img_root + 'img' + str(im_name) + '.jpg': Is the storage path of the picture . My picture here is in images Under the folder ,
fps: Is the frame rate , It will directly cause the frame number and duration of the video to be different
Parameters

(1) You can modify some variables and parameters in the code according to your own needs ,
(2) Execute code ,
My complete code :
import cv2
from cv2 import VideoWriter, VideoWriter_fourcc, imread, resize
import os
from subprocess import call
img_root = 'images/'
out_root = 'pig.avi'
fps = 1
fourcc = VideoWriter_fourcc(*"MJPG") # Support jpg
videoWriter = cv2.VideoWriter(out_root, fourcc, fps, (640, 480))
im_names = os.listdir(img_root)
print(len(im_names))
for im_name in range(1, 4):
string = img_root + 'img' + str(im_name) + '.jpg'
print(string)
frame = cv2.imread(string)
frame = cv2.resize(frame, (640, 480))
videoWriter.write(frame)
videoWriter.release()
# Change the output video into mp4 Format or compress
dir = out_root.strip(".avi")
command = "ffmpeg -i %s.avi %s.mp4" % (dir, dir)
call(command.split())(3) In the process of execution , We can see that a total of 3 A picture ,

Wait for the code to run ,

(4) Execution results : Two video files will be generated ,avi Video files and mp4 Video file ,



边栏推荐
- The idea setting code is in UTF-8 idea Properties configuration file Chinese garbled
- softmax的近似之NCE详解
- 900W+ 数据,从 17s 到 300ms,如何操作
- Yolov5 project based on QT
- Limit of one question per day
- Basic information of Promethus (I)
- 基于Qt的yolov5工程
- 简易版 微信小程序开发之页面跳转、数据绑定、获取用户信息、获取用户位置信息
- Mongodb master profile
- MongoDB安装 & 部署
猜你喜欢

Idea format code idea set shortcut key format code

Elsevier latex 提交文章 pdftex.def Error: File `thumbnails/cas-email.jpeg‘ not found: using draf

Summary of determinant knowledge points in Chapter 1 of Linear Algebra (Jeff's self perception)

Application of derivative in daily question

900w+ data, from 17s to 300ms, how to operate

Pytorch配置

小程序获取用户头像和昵称

Gavin teacher's perception of transformer live class - rasa project's actual banking financial BOT Intelligent Business Dialogue robot architecture, process and phenomenon decryption through rasa inte
![MySQL practice 45 lecture [row lock]](/img/71/344daddee537a96f0d38241e6896e1.png)
MySQL practice 45 lecture [row lock]

Introduction to mongodb
随机推荐
二进制流转换成字节数组
MongoDB基本操作【增、删、改、查】
Vs 2019 configuration tensorrt
3D drawing example
[MySQL] the difference between left join, right join and join
Latest version of NPM: the "NPM" item cannot be recognized as the name of a cmdlet, function, script file, or runnable program. Please check
Gavin teacher's perception of transformer live class - rasa project's actual banking financial BOT Intelligent Business Dialogue robot architecture, process and phenomenon decryption through rasa inte
403 error displayed when vs cloning
Application of derivative in daily question
Summary of electromagnetic spectrum
C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 05 data input and output
Hi3536c v100r001c02spc040 cross compiler installation
[algebraic structure] group (definition of group | basic properties of group | proof method of group | commutative group)
Mysql Mac版下载安装教程
Vs 2019 configuration du moteur de génération de tensorrt
文件重命名
User value is the last word in the competition of mobile phone market
[combinatorics] basic counting principle (addition principle | multiplication principle)
程序员新人上午使用 isXxx 形式定义布尔类型,下午就被劝退?
QT based tensorrt accelerated yolov5
