Skip to content

ffmpeg hangs on large HEVC video encoding (image-mp4) #4

@LALITH0110

Description

@LALITH0110

Description

ffmpeg gets stuck at frame=0 when encoding certain large HEVC videos, causing infinite loop and server timeout.

Error

[libx264 @ 0x576011df9500] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x576011df9500] profile High, level 5.1, 4:2:0, 8-bit
frame= 0 fps=0.0 q=0.0 size= 0KiB time=N/A bitrate=N/A speed=N/A
frame= 0 fps=0.0 q=0.0 size= 0KiB time=N/A bitrate=N/A speed=N/A
[repeats forever, never progresses]

Video Info

  • Input: HEVC (Main), 2160x3732, 24fps, 22.5s duration
  • Output: h264 with preset "slow"
  • Bitrate: 32021 kb/s

Issue

subprocess.run() has no timeout - hangs indefinitely when ffmpeg stalls. Server eventually killed by Gunicorn timeout.

Proposed Fix

Add timeout to ffmpeg subprocess:

result = subprocess.run(ffmpeg_cmd, timeout=300)  # 5 min max

And/or change preset from "slow" to "medium" for faster encoding.

Frequency

Rare - large portrait 4K videos from certain phones

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions