pygame save that Stream as video output.
python - how to save pygame camera as video output - Stack Overflow https://stackoverflow.com/questions/28410565/how-to-save-pygame-camera-as-video-output
Pygame's multimedia output capabilities are severily limited: It can only save uncompressed BMP images, and there is no way it can save a video format.
You have to make use of another library which to feed image frames, to render the video - or save frame by frame in a folder, numbering the file names in crescent order, and convert the result to a video with an utility later.
This project seens to feature a class to call libffmpeg to encode videos, passing frame by frame in a Python call: https://github.com/kanryu/pipeffmpeg - you will just need a way to convert the pygame Surface object to the expected "frameraw" attribute of ffmpeg.
https://github.com/kanryu/pipeffmpeg/blob/master/pipeffmpeg.py
background_image_filename = 'sushiplate.jpg'
sprite_image_filename = 'fugu.png' import pygame
from pygame.locals import *
from sys import exit pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) background = pygame.image.load(background_image_filename).convert()
sprite = pygame.image.load(sprite_image_filename).convert_alpha() clock = pygame.time.Clock() x, y = 100., 100.
speed_x, speed_y = 133., 170. for event in pygame.event.get():
if event.type == QUIT:
exit() screen.blit(background, (0, 0))
screen.blit(sprite, (x, y)) time_passed = clock.tick(30)
time_passed_seconds = time_passed / 1000.0 x += speed_x * time_passed_seconds
y += speed_y * time_passed_seconds # 到达边界则把速度反向
if x > 640 - sprite.get_width():
speed_x = -speed_x
x = 640 - sprite.get_width()
elif x < 0:
speed_x = -speed_x
x = 0. if y > 480 - sprite.get_height():
speed_y = -speed_y
y = 480 - sprite.get_height()
elif y < 0:
speed_y = -speed_y
y = 0 pygame.image.save(screen, "screenshot.png") pygame.display.update()



pygame save that Stream as video output.的更多相关文章
- Using Live555 to Stream Live Video from an IP camera connected to an H264 encoder
		
http://stackoverflow.com/questions/27279161/using-live555-to-stream-live-video-from-an-ip-camera-con ...
 - (转)V4L2 Video overlay, Video output, Video output overlay的区别
		
原文地址:http://blog.csdn.net/kickxxx/article/details/7755127 三者都是V4L2定义的接口,英文原文参见 http://v4l2spec.bytes ...
 - ffmpeg打开视频解码器失败:Could not find codec parameters for stream 0 (Video: h264): unspecified size
		
在使用ffmpeg进行拉流分离音视频数据再解码播放操作的时候: 有时候经常会报错: Could not find codec parameters for stream 0 (Video: h264) ...
 - Video for Linux Two API Specification Revision 2.6.32【转】
		
转自:https://www.linuxtv.org/downloads/legacy/video4linux/API/V4L2_API/spec-single/v4l2.html Video for ...
 - Video for Linux Two API Specification revision0.24【转】
		
转自:http://blog.csdn.net/jmq_0000/article/details/7536805#t136 Video for Linux Two API Specification ...
 - Batch: Display & Redirect Output
		
Batch How To ... Display & Redirect Output http://www.robvanderwoude.com/battech_redirection.php ...
 - with ffmpeg to encode video for live streaming and for recording to files for on-demand playback
		
We've been doing some experimentation with ffmpeg to encode video for live streaming and for recordi ...
 - LibVLC video controls
		
原文 http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__video.html VLC 3.0.0-git ...
 - pygame学习
		
http://eyehere.net/2011/python-pygame-novice-professional-3/ http://www.pygame.org/docs/ref/event.ht ...
 
随机推荐
- Spring注解的步骤
			
Spring框架提供DI(属性注解)和IOC(类/Bean的注解)注解. 注解:标注.注入和解析.解释;标注和解释一部分代码的作用在框架中:就是配置文件的另外一种实现方式@Type.@Taget;减少 ...
 - 使用脚本快速线程转储及列出高cpu线程
			
jstack `ps -ef | grep java | grep bocai.jar | awk '{print $2}'` > cpu_high.logtop -b -n1 -Hp `ps ...
 - Windows提高_2.2第二部分:用户区同步
			
第二部分:用户区同步 同步和互斥 同步:就是按照一定的顺序执行不同的线程 互斥:当一个线程访问某一资源的时候,其它线程不能同时访问 多线程产生的问题 #include <stdio.h> ...
 - ArrayList经典Demo
			
import java.util.ArrayList; import java.util.Iterator; public class ArrayListDemo { public static vo ...
 - UVA12118 Inspector's Dilemma(欧拉路径)
			
题目: 某个国家有V(V≤1000)个城市,每两个城市之间都有一条双向道路直接相连,长度为T(每条边的长度都是T).你的任务是找一条最短的道路(起点和终点任意), 使得该道路经过E条指定的边.输出这条 ...
 - 线性DP LIS浅谈
			
LIS问题 什么是LIS? 百度百科 最长上升子序列(Longest Increasing Subsequence,LIS),在计算机科学上是指一个序列中最长的单调递增的子序列. 怎么求LIS? O( ...
 - IN语句改写EXISTS
			
-- IN SELECT T1.* FROM role_menu T1 WHERE T1.ROLEUUID IN ( SELECT T2.uuid FROM role T2 WHERE T2.UUID ...
 - vue-cli中src/main.js 的作用
			
// The Vue build version to load with the `import` command // (runtime-only or standalone) has been ...
 - 斯特林公式 hdu1018
			
杭电上面1018>>点击测试<< 思路:当问到阶乘的值时候,用万进制来写:但是问阶乘值的位数的时候,就可以用斯特林公式了 log10(2*pi*n)/2+n*log10(n/e ...
 - Java基础学习总结(78)——Java main方法深入研究学习
			
1.不用main方法如何定义一个类? 不行,没有main方法我们不能运行Java类. 在Java 7之前,你可以通过使用静态初始化运行Java类.但是,从Java 7开始就行不通了. 2.main() ...