parkerRose
Posts: 6
Joined: Mon Aug 07, 2017 9:55 pm

Using subprocess.call to use arecord stopped working overnight

Wed Aug 09, 2017 1:34 am

Hi,
I'm working on a project that records and uploads a video when a key is pressed. I am using arecord in my python script and it was working last night and now it is not. I haven't changed anything except for the name of the audio files. The command also works when I remove the quotes and run it in the terminal, and the python script still pauses for 10 seconds like it used to, but the file never shows up. Here's my script:

Code: Select all

import pygame, sys
from pygame.locals import *
from picamera import PiCamera
from time import sleep
from subprocess import call
camera = PiCamera()

pygame.init()
BLACK= (0,0,0)
WIDTH = 640
HEIGHT = 480
windowSurface = pygame.display.set_mode((WIDTH,HEIGHT), 0, 32)

windowSurface.fill(BLACK)

while True:
	events = pygame.event.get()
	for event in events:
		if event.type == pygame.KEYDOWN and event.key == pygame.K_b:
			camera.start_recording('testing123.h264')
			print("vrecord")
			call(['arecord','-d 10 -D plughw:0,0 -f cd testing123.wav'])
			print('done')
			camera.stop_recording()
			print('stopped')
		pass
		if event.type == QUIT:
			pygame.quit()
			sys.exit()
Any help would be appreciated.
Thank you!

User avatar
elParaguayo
Posts: 1838
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: Using subprocess.call to use arecord stopped working overnight

Wed Aug 09, 2017 8:41 am

I've no idea if this is the problem if the code worked before, but I don't think you can use 'call' like that. The line should be:

Code: Select all

call(['arecord','-d', '10', '-D', 'plughw:0,0', '-f', 'cd', 'testing123.wav'])
Each argument needs to be a separate item in the list.
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

parkerRose
Posts: 6
Joined: Mon Aug 07, 2017 9:55 pm

Re: Using subprocess.call to use arecord stopped working overnight

Wed Aug 09, 2017 6:23 pm

Hi, this didn't work for me. Are there any other solutions (not necesarily using subprocess.call?)

parkerRose
Posts: 6
Joined: Mon Aug 07, 2017 9:55 pm

Re: Using subprocess.call to use arecord stopped working overnight

Wed Aug 09, 2017 7:54 pm

Hi everyone, solved my own problem. I just took the command and put it in a shell script and then called that. Thanks to the community for helping me!

Return to “Python”

Who is online

Users browsing this forum: No registered users and 18 guests