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. dutacm.club_1087_Common Substrings_(KMP)_(结合此题通俗理解kmp的next数组)

    1087: Common Substrings Time Limit:3000/1000 MS (Java/Others)   Memory Limit:163840/131072 KB (Java/ ...

  2. Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout

    automaticallyAdjustsScrollViewInsets:在导航栏透明时用到 In your viewDidLoad method, add if([self respondsToSe ...

  3. vba txt读写的几种方式

    四种方式写txt 1.这种写出来的是ANSI格式的txt Dim TextExportFile As String TextExportFile = ThisWorkbook.Path & & ...

  4. flex 三列布局

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  5. Linux 安装 JDK 详解

    安装 JDK 说明:Linux 系统中安装软件需在 root 用户下进行. (1) 首先下载 jdk-8u131-linux-x64.rpm (2)将用户切换至 root,在 opt 文件夹下新建 s ...

  6. ROW_NUM

    SELECT  *  FROM ( (SELECT ROW_NUMBER() OVER (PARTITION BY  字段1,字段2  ORDER BY 字段3   DESC) AS  TMPID), ...

  7. java 十四周总结

  8. hibernate的QBC查询之Criteria用法

    //return (DeliverCost) super.getSession().createCriteria(getMyClass()).add(Restrictions.eq("isd ...

  9. Python学习笔记 (2)变量、常量和数据类型

    变量 顾名思义,变量就是一个会变的量,用一个变量名表示,指向内存中一片区域,而指向的区域存的是什么,这个变量就是什么数据类型,和C/C++挺不一样的.变量数据类型可以通过赋值变来变去(这就叫动态语言, ...

  10. 20170613NOIP模拟赛

    共3道题目,时间3小时 题目非原创,仅限校内交流使用 题目名称 Graph Incr Permutation 文件名 graph incr permutation 输入文件 graph.in incr ...