p1 = subprocess.Popen(["arecord", "-Dhw:1,0", "-fS16_LE", "-d120", "-r44100"],stdout=subprocess.PIPE)
p2 = subprocess.Popen(["lame", "-", "test/%s/%s" %(dirname, filename)], stdin=p1.stdout)
output = p2.communicate()[0]
As you see here, I’m recording using arecord directly to mp3.
The problem i’m facing is that I need to upload the files i’m recording but as soon as the recording start it’s generating a file and appending the audio to it rather than generating the mp3 file when the duration of the record is finished. The result is each time it checks for the file, it uploads the chunk of the file that is ready.
I only want the script to upload the file when the file is completed or i want lame to generate me the file when the duration is finish.
How can i check that the file is not in use anymore or maybe make lame use a temporary file then save the completed file to the main directory.
Why not just wait for the process to complete? Just do the upload after
communicatereturns.