当前位置:网站首页>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 ,
边栏推荐
- Vs 2019 configure tensorrt to generate engine
- The calculation of stripe, kernel and padding in CNN
- Open Visual Studio 2010 hangs when opening a SQL file sql file
- Advanced redis applications [password protection, data persistence, master-slave synchronization, sentinel mode, transactions] [not completed yet (semi-finished products)]
- Stepping on pits and solutions when using inputfilter to limit EditText
- MongoDB复制集【主从复制】
- The idea cannot be loaded, and the market solution can be applied (pro test)
- Limit of one question per day
- MongoDB安装 & 部署
- MySQL practice 45 lecture [row lock]
猜你喜欢
Summary of matrix knowledge points in Chapter 2 of Linear Algebra (Jeff's self perception)
UMI route interception (simple and rough)
Limit of one question per day
MySQL practice 45 [global lock and table lock]
Latest version of NPM: the "NPM" item cannot be recognized as the name of a cmdlet, function, script file, or runnable program. Please check
QQ小程序开发之 一些前期准备:预约开发账号、下载安装开发者工具、创建qq小程序
Mongodb installation & Deployment
45 lectures on MySQL [index]
ffmpeg下载安装教程及介绍
Elsevier latex submitted the article pdftex def Error: File `thumbnails/cas-email. jpeg‘ not found: using draf
随机推荐
Compare float with 0
Stepping on pits and solutions when using inputfilter to limit EditText
Vs 2019 installation and configuration opencv
【AI实战】应用xgboost.XGBRegressor搭建空气质量预测模型(一)
Small guide for rapid formation of manipulator (VIII): kinematic modeling (standard DH method)
The difference between static web pages and dynamic web pages & the difference between Web1.0 and Web2.0 & the difference between get and post
Introduction à mongodb
C # webrequest post mode, based on "basic auth" password authentication mode, uploads files and submits other data using multipart / form data mode
Open Visual Studio 2010 hangs when opening a SQL file sql file
45 lectures on MySQL [index]
Unity3d RPG implementation (medium)
Yolov5 project based on QT
Node start server
The XML file generated by labelimg is converted to VOC format
Summary of determinant knowledge points in Chapter 1 of Linear Algebra (Jeff's self perception)
MySQL practice 45 lecture [transaction isolation]
Avec trois. JS fait une scène 3D simple
QQ小程序开发之 一些前期准备:预约开发账号、下载安装开发者工具、创建qq小程序
静态网页 和 动态网页的区别 & WEB1.0和WEB2.0的区别 & GET 和 POST 的区别
Use of El tree search method