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

 
 
 
i´m not at home now but my workarround is take the pygame surface and convert to numpy array and write with opencv to mp4 movie.
 
 
 
 python - How to capture pygame screen? - Stack Overflow https://stackoverflow.com/questions/6087484/how-to-capture-pygame-screen
 
 
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.的更多相关文章

  1. 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 ...

  2. (转)V4L2 Video overlay, Video output, Video output overlay的区别

    原文地址:http://blog.csdn.net/kickxxx/article/details/7755127 三者都是V4L2定义的接口,英文原文参见 http://v4l2spec.bytes ...

  3. ffmpeg打开视频解码器失败:Could not find codec parameters for stream 0 (Video: h264): unspecified size

    在使用ffmpeg进行拉流分离音视频数据再解码播放操作的时候: 有时候经常会报错: Could not find codec parameters for stream 0 (Video: h264) ...

  4. 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 ...

  5. Video for Linux Two API Specification revision0.24【转】

    转自:http://blog.csdn.net/jmq_0000/article/details/7536805#t136 Video for Linux Two API Specification ...

  6. Batch: Display & Redirect Output

    Batch How To ... Display & Redirect Output http://www.robvanderwoude.com/battech_redirection.php ...

  7. 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 ...

  8. LibVLC video controls

    原文 http://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__video.html VLC  3.0.0-git ...

  9. pygame学习

    http://eyehere.net/2011/python-pygame-novice-professional-3/ http://www.pygame.org/docs/ref/event.ht ...

随机推荐

  1. 三维CNN:收集一些最近的3d卷积网络PointNet++

    PointNet++是在PointNet上做出了改进,考虑了点云局部特征提取,从而更好地进行点云分类和分割. 先简要说一下PointNet: PointNet,其本质就是一种网络结构,按一定的规则输入 ...

  2. C/C++ struct定义、声明、对齐方式

    一.定义/声明方式 第一种:仅有结构体名,不定义/声明变量 struct MyStruct {  int i:     char a[10];     double b; }:第二种:有结构体名,并声 ...

  3. Spring框架系列(七)--Spring常用注解

    Spring部分: 1.声明bean的注解: @Component:组件,没有明确的角色 @Service:在业务逻辑层使用(service层) @Repository:在数据访问层使用(dao层) ...

  4. 一天搞定jQuery(三)——使用jQuery完成复选框的全选和全不选

    还记得之前我使用JavaScript来实现复选框的全选和全不选效果吗?如果读者初次翻阅本文,可记得看看教你一天玩转JavaScript(七)——使用JavaScript完成复选框的全选和全不选的效果! ...

  5. 小程序wx:key = “{{*this}}”报错

    解决方案:改为 wx:key = "*this"

  6. Stuts2学习——HelloWorld

    这两天从对Struts一窍不通到成功运行HelloWorld,在SSH这条路上迈出了第一步. 下面我把我的第一个Struts程序放上来: 一.新建web project,配置文件等准备工作 1. 新建 ...

  7. notepad++使用NppFTP连接linux,编写shell脚本无法保存上传的问题

    下载安装NppFTP插件之后,重启打开notepad++连接到linux主机,之后进行编辑shell脚本,出现无法保存上传至linux主机的问题. 分析的原因:可能的原因是Windows防火墙阻止了应 ...

  8. buf.readDoubleBE()

    buf.readDoubleBE(offset[, noAssert]) buf.readDoubleLE(offset[, noAssert]) offset {Number} 0 <= of ...

  9. Android 找不到资源的问题

    偶尔会遇到R.layout.***或R.id.***找不到资源的问题,明明在文件夹中有啊,那为什么嘞? 结合我自己遇到的情况和网上的资料,总结出以下几点可能的原因: 导入了android.R.这个是最 ...

  10. Python生成随机不重复姓名昵称

    姓采用百家姓,名字从常用名字高频字选取两个汉字,再和当前时间戳组合,估计应该是不会重复了,代码如下: # -*- coding:utf-8 -*- import random import time ...