gradio icon indicating copy to clipboard operation
gradio copied to clipboard

Lite: Support ffmpeg features

Open whitphx opened this issue 2 years ago • 2 comments

Because ffmpeg features are not supported on the Wasm ver., for example the camera-input video causes an error,

pyodide.asm.js:9 Traceback (most recent call last):
pyodide.asm.js:9   File "/lib/python3.11/site-packages/gradio/routes.py", line 534, in predict
pyodide.asm.js:9     output = await route_utils.call_process_api(
pyodide.asm.js:9              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyodide.asm.js:9   File "/lib/python3.11/site-packages/gradio/route_utils.py", line 226, in call_process_api
pyodide.asm.js:9     output = await app.get_blocks().process_api(
pyodide.asm.js:9              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyodide.asm.js:9   File "/lib/python3.11/site-packages/gradio/blocks.py", line 1548, in process_api
pyodide.asm.js:9     inputs = self.preprocess_data(fn_index, inputs, state)
pyodide.asm.js:9              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyodide.asm.js:9   File "/lib/python3.11/site-packages/gradio/blocks.py", line 1329, in preprocess_data
pyodide.asm.js:9     processed_input.append(block.preprocess(inputs[i]))
pyodide.asm.js:9                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyodide.asm.js:9   File "/lib/python3.11/site-packages/gradio/components/video.py", line 223, in preprocess
pyodide.asm.js:9     raise wasm_utils.WasmUnsupportedError(
pyodide.asm.js:9 gradio.wasm_utils.WasmUnsupportedError: Video formatting is not supported in the Wasm mode.
webworker.js?type=classic&worker_file:2 

Sample app to reproduce:

import gradio as gr


def snap(image, video):
    return [image, video]


demo = gr.Interface(
    snap,
    [gr.Image(source="webcam", tool=None), gr.Video(source="webcam")],
    ["image", "video"],
)

if __name__ == "__main__":
    demo.launch()

whitphx avatar Oct 19 '23 03:10 whitphx

I'm actually moving this webcam flip logic to the front end in v4 which will solve this specific case. We do use ffmpeg elsewhere though.

pngwn avatar Oct 19 '23 10:10 pngwn

Another situation where ffmpeg is used in Gradio is to upload an audio file other than .wav. pydub offloads file loading to ffmpeg internally.

https://github.com/gradio-app/gradio/blob/cccf0fe20834d2ce4f63659b520d27d1f651d08c/gradio/processing_utils.py#L536

https://github.com/jiaaro/pydub/blob/996cec42e9621701edb83354232b2c0ca0121560/pydub/audio_segment.py#L766

whitphx avatar Jun 26 '24 10:06 whitphx

Lite is no longer maintained but someone can fork it and contribute a fix for this.

Last release of lite: https://github.com/gradio-app/gradio-lite

freddyaboulton avatar Sep 18 '25 14:09 freddyaboulton