0

code:

import os
import sys
from subprocess import Popen, DEVNULL, STDOUT, PIPE
import subprocess
import time

stream_url = "https://impradio3.bytemasters.gr/8002/stream?type=http"

p1 = Popen(['ffmpeg','-y','-loglevel','quiet','-i',stream_url,'outputfile.mp3'],stdin=PIPE,stdout=PIPE, stderr=PIPE)
time.sleep(10)
p1.terminate()
p1.wait()
print(p1.returncode)
os.remove("outputfile.mp3")

Output - Error:

1
Traceback (most recent call last):
  File "test_stream.py", line 14, in <module>
    os.remove("outputfile.mp3")
PermissionError: [WinError 32] The process cannot access the file because it is
being used by another process: 'outputfile.mp3'

OS: Windows 7 64 bit Python: 3.7.0

How can i solve this error?

Edit:

i tried this command:

os.kill(p1.pid, signal.SIGTERM)

which gives this error:

Traceback (most recent call last):
  File "test_stream.py", line 12, in <module>
    os.kill(p1.pid, signal.SIGTERM)
PermissionError: [WinError 5] Access is denied

so maybe it's an avast antivirus issue.

Chris P
  • 2,059
  • 4
  • 34
  • 68

0 Answers0