Repository: gradio-app/gradio

Issue:
[Video] Video component does not check if file already exists when `include_audio=False`
### Describe the bug

The video component does not check if the file already exists when `include_audio=False` which causes an error if the same video file is uploaded twice
```
File '/tmp/gradio/87bf2b9d4da7170c8f8fe9673e7780effe24e254/muted_01.mp4' already exists. Overwrite? [y/N] Not overwriting - exiting
Traceback (most recent call last):
  File "/home/artem.kotov/mambaforge/envs/control/lib/python3.10/site-packages/gradio/routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "/home/artem.kotov/mambaforge/envs/control/lib/python3.10/site-packages/gradio/blocks.py", line 1428, in process_api
    inputs = self.preprocess_data(fn_index, inputs, state)
  File "/home/artem.kotov/mambaforge/envs/control/lib/python3.10/site-packages/gradio/blocks.py", line 1245, in preprocess_data
    processed_input.append(block.preprocess(inputs[i]))
  File "/home/artem.kotov/mambaforge/envs/control/lib/python3.10/site-packages/gradio/components/video.py", line 250, in preprocess
    ff.run()
  File "/home/artem.kotov/mambaforge/envs/control/lib/python3.10/site-packages/ffmpy.py", line 106, in run
    raise FFRuntimeError(self.cmd, self.process.returncode, out[0], out[1])
ffmpy.FFRuntimeError: `ffmpeg -i /tmp/gradio/87bf2b9d4da7170c8f8fe9673e7780effe24e254/01.mp4 -an /home/artem.kotov/tmp/gradio/87bf2b9d4da7170c8f8fe9673e7780effe24e254/muted_01.mp4` exited with status 1
```

### Have you searched existing issues?  🔎

- [X] I have searched and found no existing issues

### Reproduction

```
def identity(input_video):
    return input_video

with gr.Blocks() as demo:
    input_video = gr.Video(source="upload", width=384, include_audio=False)
    result_video = gr.Video(label="Output", width=384)
    run_button = gr.Button(label="Run")
    run_button.click(fn=identity, inputs=[input_video], outputs=[result_video])

demo.queue().launch()
```

then try to upload the same video twice: the first time everything should be working just fine but the second time the error occurs.

### Screenshot

_No response_

### Logs

_No response_

### System Info

```shell
Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 3.40.1
gradio_client version: 0.4.0

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.1.0
aiohttp: 3.8.4
altair: 5.0.1
fastapi: 0.98.0
ffmpy: 0.3.0
gradio-client: 0.4.0
httpx: 0.24.1
huggingface-hub: 0.15.1
importlib-resources: 6.0.1
jinja2: 3.1.2
markdown-it-py: 2.2.0
markupsafe: 2.1.1
matplotlib: 3.7.1
mdit-py-plugins: 0.3.3
numpy: 1.25.0
orjson: 3.9.1
packaging: 23.0
pandas: 1.5.3
pillow: 9.4.0
pydantic: 1.10.9
pydub: 0.25.1
python-multipart: 0.0.6
pyyaml: 6.0
requests: 2.31.0
semantic-version: 2.10.0
typing-extensions: 4.7.1
uvicorn: 0.22.0
websockets: 11.0.3
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2023.6.0
httpx: 0.24.1
huggingface-hub: 0.15.1
packaging: 23.0
requests: 2.31.0
typing-extensions: 4.7.1
websockets: 11.0.3
```


### Severity

I can work around it


Discussion:
Can confirm the issue, thanks @breengles! Would you be interested in opening a PR to fix this? 

Resolving patch:
diff --git a/gradio/components/video.py b/gradio/components/video.py
--- a/gradio/components/video.py
+++ b/gradio/components/video.py
@@ -239,6 +239,8 @@ def preprocess(
             return output_file_name
         elif not self.include_audio:
             output_file_name = str(file_name.with_name(f"muted_{file_name.name}"))
+            if Path(output_file_name).exists():
+                return output_file_name
             if wasm_utils.IS_WASM:
                 raise wasm_utils.WasmUnsupportedError(
                     "include_audio=False is not supported in the Wasm mode."


Test patch:
diff --git a/test/test_components.py b/test/test_components.py
--- a/test/test_components.py
+++ b/test/test_components.py
@@ -1332,6 +1332,11 @@ def test_component_functions(self):
         output2 = video_input.preprocess(x_video)
         assert output1 == output2
 
+        video_input = gr.Video(include_audio=False)
+        output1 = video_input.preprocess(x_video)
+        output2 = video_input.preprocess(x_video)
+        assert output1 == output2
+
         video_input = gr.Video(label="Upload Your Video")
         assert video_input.get_config() == {
             "autoplay": False,