Python Forum
how can we record a video file from our program output (moving object)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how can we record a video file from our program output (moving object)
#1
Hi everybody. I've created a moving object and now I need to record it as a video to use it in another website. I looked youtube videos but I couldn't find anything. I appreciate it a lot if anybody here can help me.
Here is my code:
import pygame

pygame.init()
screen=pygame.display.set_mode((1000,1000)) 

pygame.display.set_caption('visual rhythm')
icon=pygame.image.load("song.png")
pygame.display.set_icon(icon)

playerImg=pygame.image.load('spaceship.png')
playerX=370
playerY=400
def player(x,y):
    screen.blit(playerImg,(int(x),int(y)))

speed=[4000, -2000 , 2000 , -1000 , 1333 , -4000]
count=0
count2=0
clock=pygame.time.Clock()
while count2<len(speed):
    screen.fill((0,255,0))
    milli=clock.tick()
    seconds=milli/1000.0
    dm=seconds*speed[count]
    playerY+=dm
    player(playerX,playerY)
    pygame.display.update()
    if playerY>=946 or playerY<1:
        count+=1
        count2+=1
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Last record in file doesn't write to newline gonksoup 3 364 Jan-22-2024, 12:56 PM
Last Post: deanhystad
  How do I stream and record at the same time with arducam? traderjoe 0 430 Oct-23-2023, 12:01 AM
Last Post: traderjoe
  What is the fastest way to get all the frames from a video file? glorsh66 3 992 May-26-2023, 04:41 AM
Last Post: Gribouillis
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,046 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  How to output Python in Spout or any other video sharing network? buzzdarkyear 4 2,073 Jan-11-2022, 11:37 AM
Last Post: buzzdarkyear
  Functions to consider for file renaming and moving around directories cubangt 2 1,699 Jan-07-2022, 02:16 PM
Last Post: cubangt
  Only getting last record saved...Why Milfredo 10 4,275 Sep-10-2020, 03:00 AM
Last Post: Milfredo
  waiting for barcode scanner output, while main program continues to run lightframe109 3 4,581 Sep-03-2020, 02:19 PM
Last Post: DeaD_EyE
  How to get program output from subprocess.Popen? glestwid 1 2,333 Aug-19-2020, 05:44 AM
Last Post: buran
  Output CSV file with filepath and file contents glittergirl 1 1,707 Aug-03-2020, 01:50 AM
Last Post: glittergirl

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020