title: Cannot remove the video file created through ffmpeg save
body: <p>It gives this error:
  <strong>os.remove(&quot;output.mp4&quot;)
  PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'output.mp4</strong></p>
  <p>I am first downloading a reddit video (with separate audio and video file) by joining audio and video files together using <strong>ffmpeg</strong></p>
  <pre><code>    with open(&quot;video.mp4&quot;, &quot;wb&quot;) as f:
          g = requests.get(video_url, stream=True)
          f.write(g.content)
  
      with open(&quot;audio.mp3&quot;, &quot;wb&quot;) as f:
          g = requests.get(audio_url, stream=True)
          f.write(g.content)
  
      os.system(&quot;ffmpeg -i video.mp4 -i audio.mp3 -c copy output.mp4&quot;)
      os.remove(&quot;audio.mp3&quot;)
      os.remove(&quot;video.mp4&quot;)
  </code></pre>
  <p>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.</p>
  <pre><code>        os.system(&quot;exit&quot;)
          os.system(&quot;echo 'q' &gt;stop&quot;) 
          os.system(&quot;exit()&quot;)
          os.remove(&quot;output.mp4&quot;)
  </code></pre>
  <p>But it gives me Permission Error. Please help me with this problem I have no idea what could be wrong.</p>
  <p>This is the method I am using to upload the file to YouTube.</p>
  <pre><code>      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&quot;output.mp4&quot;)
  
        response_upload = service.videos().insert(
              part='snippet,status',
              body=request_body,
              media_body=mediaFile
          ).execute
  </code></pre>