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 ...
随机推荐
- HTML meta信息含义
<meta name="viewport" content="width=device-width,initial-scale=1.0"> cont ...
- python爬虫(房天下)
房天下 import requests res = requests.get('http://esf.sz.fang.com/') #res.text from bs4 import Beautifu ...
- dutacm.club_1085_Water Problem_(矩阵快速幂)
1085: Water Problem Time Limit:3000/1000 MS (Java/Others) Memory Limit:163840/131072 KB (Java/Othe ...
- 梦想CAD控件安卓文字样式
增加文字样式 用户可以增加文字样式到数据库,并设置其字体等属性,具体实现代码如下: // 增加文字样式 //getCurrentDatabase()返回当前数据库对象 //getTextstyle() ...
- Spring事物不回滚
今天发现个自己的bug,仔细排查后,发现根本原因我在service方法中抛出的异常被控制层的方法捕获了,所以后台页面也只是出现个错误提示,而数据却没有回滚. 解决方式:对自己抛出的异常使用try ca ...
- bzoj 4026 dC Loves Number Theory 主席树+欧拉函数
题目描述 dC 在秒了BZOJ 上所有的数论题后,感觉萌萌哒,想出了这么一道水题,来拯救日益枯竭的水题资源.给定一个长度为 n的正整数序列A,有q次询问,每次询问一段区间内所有元素乘积的φ(φ(n)代 ...
- python re模块与正则
1. re模块 1.1 转义符 正则表达式中的转义符在python的字符串中也刚好有转移的作用,但是正则表达式中的转义符和字符串中的转义符并没关系,且还容易有冲突. 为了避免这种冲突,我们所有的正则都 ...
- 洛谷 2471 BZOJ 1067 [SCOI2007]降雨量
[题解] 用线段树维护区间最大值(因为没有修改,St表也可以),然后由于x,y可能是降雨量未知的年份,需要进行分类讨论. #include<cstdio> #include<algo ...
- 设置idea快速生成doc comment
在eclipse中快速生成方法的doc comment快捷键是Alt+Shift+J, 而在idea中没有对应的快捷键,但是能实现相似的功能. 1.在方法上面输入/** 然后回车就可以生成注释了. 2 ...
- FreeMarker-简单示例
以下是简单的FreeMarker示例,直接采用模板 + 数据模型 = 输出的方式.示例中是Application的项目,主要用于展示模板输出HTML文件的功能. 示例: 1.引入POM依赖 <! ...