Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Cannot remove the video file created through ffmpeg save

$
0
0

It gives this error:os.remove("output.mp4")PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'output.mp4

I am first downloading a reddit video (with separate audio and video file) by joining audio and video files together using ffmpeg

    with open("video.mp4", "wb") as f:        g = requests.get(video_url, stream=True)        f.write(g.content)    with open("audio.mp3", "wb") as f:        g = requests.get(audio_url, stream=True)        f.write(g.content)    os.system("ffmpeg -i video.mp4 -i audio.mp3 -c copy output.mp4")    os.remove("audio.mp3")    os.remove("video.mp4")

After this I am uploading it to YouTube Using YouTube Api and then finally deleting it from the system. I tried everything I thought would solve this error.

        os.system("exit")        os.system("echo 'q'>stop")         os.system("exit()")        os.remove("output.mp4")

But it gives me Permission Error. Please help me with this problem I have no idea what could be wrong.

This is the method I am using to upload the file to YouTube.

      request_body = {'snippet': {'categoryI': 19,'title': f'{item.title}','description': description,'tags': Tags                },'status': {'privacyStatus': 'public','publishAt': upload_date_time,'selfDeclaredMadeForKids': False,                 },'notifySubscribers': False            }      mediaFile = MediaFileUpload(r"output.mp4")      response_upload = service.videos().insert(            part='snippet,status',            body=request_body,            media_body=mediaFile        ).execute

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>