Menu

Audit your HLS segments: a Python script that catches the 6-second-that-isn't
πŸ“°

Audit your HLS segments: a Python script that catches the 6-second-that-isn't

DEV Community: pythonΒ·Mason KΒ·about 3 hours ago
#IzvHtPYB
#devtopython#devto#dev#ffmpeg#ext
Reading 0:00
15s threshold

TL;DR

-hls_time 6 is a request, not a guarantee. We'll reproduce the bug on a test clip, fix it with three encoder flags, and write a ~75 line Python audit that checks a playlist against RFC 8216 and Apple's HLS authoring rules.

Most HLS pipelines set the segment length once and never look again. The playlist can disagree with your config and everything still plays, so nothing alerts. #video #ffmpeg

We'll need ffmpeg 6.x or newer , ffprobe , and python 3.10+ . Everything runs locally.

1. πŸŽ₯ Make a test clip

# a 60 s, 720p, 24 fps synthetic clip with a sine tone ffmpeg -y -f lavfi -i "testsrc2=size=1280x720:rate=24:duration=60" \ -f lavfi -i "sine=frequency=440:duration=60" \ -c :v libx264 -preset veryfast -pix_fmt yuv420p -c :a aac -shortest src.mp4

Enter fullscreen mode

Exit fullscreen mode

2.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.