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. 329.-io流(字符-练习-复制文本文件二)

    //每次读取的字节长度,一般都是1024的倍数 private static final int BUF_SIZE = 1024; public static void main(String[] a ...

  2. DNN结构构建:NAS网络结构搜索和强化学习、迁移学习

    前言 谷歌推出的NASNet架构,用于大规模图像分类和识别.NASNet架构特点是由两个AutoML设计的Layer组成--Normal Layer and Reduction Layer,这样的效果 ...

  3. CUDA 显存操作:CUDA支持的C++11

    CUDA9的编译器和语言改进 使用CUDA 9,nvcc编译器增加了对C ++ 14的支持,其中包括新功能 通用的lambda表达式,其中使用auto关键字代替参数类型; auto lambda = ...

  4. 从输入URL到网页呈现的过程

    1.域名解析当我们在浏览器中输入一个URL,例如”www.google.com”时,这个地址并不是谷歌网站真正意义上的地址.互联网上每一台计算机的唯一标识是它的IP地址,因此我们输入的网址首先需要先解 ...

  5. 梦想CAD控件网页版搜索图面上的文字

    在网页中查找到CAD控件图纸上的文字.点击此处在线演示. 主要用到函数说明: _DMxDrawX::NewSelectionSet 实例化一个构造选择集进行过滤,该类封装了选择集及其处理函数. _DM ...

  6. js继承的方式

    深入理解继承的实现方式不仅仅有利于自己去造轮子,封装插件,更有利于我们去阅读一些框架的源码, 以下记录几种常见的继承方式 1. 原型链实现继承 function Father(){ this.name ...

  7. 模板—treap

    #include<iostream> #include<cstdio> #include<cstdlib> #define INF 0x7fffffff using ...

  8. [luogu3573 POI2014] RAJ-Rally (拓扑排序 权值线段树)

    传送门 Solution 在DAG中我们可以\(O(n)\)预处理\(Ds(u)\)表示从u表示以s为起点的最长路\(Dt(u)\)表示以u为终点的最长路,那么经过\((u,v)\)的最长路即为\(D ...

  9. 在Java中调用带参数的存储过程

    JDBC调用存储过程: CallableStatement 在Java里面调用存储过程,写法那是相当的固定: Class.forName(.... Connection conn = DriverMa ...

  10. StringBuilder的构造方法

    /* * String和StringBuilder的区别: * String的内容是固定的 * StringBuilder的内容是可变的 * 构造方法: * StringBuilder() * 成员方 ...