diff --git a/.changeset/young-poets-kneel.md b/.changeset/young-poets-kneel.md new file mode 100644 index 000000000000..f0359495851d --- /dev/null +++ b/.changeset/young-poets-kneel.md @@ -0,0 +1,5 @@ +--- +"gradio": minor +--- + +fix:`make_waveform()` twitter video resolution fix diff --git a/gradio/helpers.py b/gradio/helpers.py index e901e1a91b74..61d4413cc658 100644 --- a/gradio/helpers.py +++ b/gradio/helpers.py @@ -892,7 +892,7 @@ def get_color_gradient(c1, c2, n): if not animate: waveform_img = PIL.Image.open(tmp_img.name) - waveform_img = waveform_img.resize((1000, 200)) + waveform_img = waveform_img.resize((1000, 400)) # Composite waveform with background image if bg_image is not None: @@ -987,11 +987,11 @@ def _animate(_): "-i", audio_file, "-filter_complex", - "[0:v][1:a]concat=n=1:v=1:a=1[v][a]", + "[0:v][1:a]concat=n=1:v=1:a=1[v];[v]scale=1000:400,format=yuv420p[v_scaled]", "-map", - "[v]", + "[v_scaled]", "-map", - "[a]", + "1:a", "-c:v", "libx264", "-c:a", diff --git a/test/test_helpers.py b/test/test_helpers.py index dbb4f761eee0..14c9a83b24b7 100644 --- a/test/test_helpers.py +++ b/test/test_helpers.py @@ -452,6 +452,32 @@ def test_make_waveform_with_spaces_in_filename(): waveform = gr.make_waveform(audio) assert waveform.endswith(".mp4") + try: + command = [ + "ffprobe", + "-v", + "error", + "-select_streams", + "v:0", + "-show_entries", + "stream=width,height", + "-of", + "json", + waveform, + ] + + result = subprocess.run(command, capture_output=True, text=True, check=True) + output = result.stdout + data = json.loads(output) + + width = data["streams"][0]["width"] + height = data["streams"][0]["height"] + assert width == 1000 + assert height == 400 + + except subprocess.CalledProcessError as e: + print("Error retrieving resolution of output waveform video:", e) + def test_make_waveform_raises_if_ffmpeg_fails(tmp_path, monkeypatch): """