Skip to content
TalonZeng

Can't Download the Online Course? HLS Unpack + Local Whisper Batch Subs

A first-person walkthrough: pair an LLM assistant with DevTools to archive entitled HLS streams to MP4, then batch-transcribe on CPU with faster-whisper into SRT and TXT—pitfalls, pinned deps, reusable prompts.

zhudi7 min read
Share
Cover: browser stream to MP4, then SRT and TXT

Corporate training videos that only play in the browser are awkward to keep offline—and worse to search later. I had a set of courses I was already entitled to retain, and I wanted a local archive: MP4 files plus searchable transcripts. There was no download button. The player used ordinary HLS (an m3u8 playlist, .ts segments, often AES-128). I did not treat that as a crack. I paired with a local LLM assistant and reverse-engineered the playback pipeline together—so I could archive what I already had the right to keep.

This write-up has two halves: A. using an LLM assistant to map any HLS site’s download path, and B. batch local speech-to-text with faster-whisper into SRT + TXT. Domains, keys, and course names below are placeholders. Use this only for content you are allowed to keep offline. Do not use it to punch through paywalls.

Cover: browser stream to MP4, then SRT and TXT

Mental model first#

When a browser plays HLS, roughly:

  1. The player fetches an m3u8 playlist;
  2. The playlist lists .ts segments (sometimes nested by quality);
  3. If you see #EXT-X-KEY, segments are usually AES-128 encrypted, and the player decrypts with a key from the current session;
  4. A single MP4 is: a usable playlist + key → ffmpeg pulls segments, decrypts, and remuxes.
HLS pipeline: page → m3u8 → key.bin → .ts → MP4

The LLM assistant’s job is not “one-click download.” It reads Network/Console dumps with you, rewrites playlists for offline use, and debugs ffmpeg errors. You still sign in, confirm entitlement, and run the final commands.

Part A — Download HLS with an LLM assistant#

1. Find m3u8 / .ts in DevTools#

Chrome: F12 → Network, filter m3u8, then ts. Play for a bit so requests appear.

Short clips sometimes never land in disk cache, and Network can miss them. In Console:

javascript
performance.getEntriesByType('resource')
  .map(e => e.name)
  .filter(u => /m3u8|\.ts(\?|$)/i.test(u))

Paste the URL list to the assistant and ask it to dedupe by media id (the same play session often repeats noisy index0.ts entries).

Placeholder CDN shapes:

plaintext
https://cdn.example.com/.../media/{id}_sharp/{id}_1/index.m3u8
https://cdn.example.com/.../media/{id}_sharp/{id}_1/index0.ts
https://cdn.example.com/.../media/{id}_sharp/{id}_1/index1.ts

2. When the ticketed API m3u8 returns 422#

Many corporate LMS players mint a short-lived ticket, then fetch m3u8 from an API. Wrong headers or an expired ticket → 422. We burned time chasing that path. The more reliable artifact was often the CDN “sharp” / variant playlist that already lists relative or absolute .ts URLs.

Practical rules:

  • Confirm the browser can still play right now (session key still valid);
  • Prefer the playlist that already expands to segments;
  • Tickets rotate—keep the download window short.

3. Localize the playlist: key on disk + rewrite EXT-X-KEY#

A typical playlist snippet:

plaintext
#EXTM3U
#EXT-X-KEY:METHOD=AES-128,URI="https://cdn.example.com/.../key",IV=0x0123456789abcdef0123456789abcdef
#EXTINF:4.000,
index0.ts
#EXTINF:4.000,
index1.ts

Steps:

  1. From the same logged-in playback session, download the key to key.bin in your work folder (this tutorial never pastes a real key hex);
  2. Copy to playlist-local.m3u8, set URI="key.bin", keep the original IV;
  3. Keep .ts paths relative, or rewrite to reachable absolute URLs.

Example layout:

plaintext
Downloads\course-video\
  playlist1-local.m3u8
  key1.bin
  course-01.mp4   ← output

4. Decode with ffmpeg#

On my Windows box ffmpeg lived under the user Local\ffmpeg\bin. Example:

plaintext
ffmpeg -y `
  -allowed_extensions ALL `
  -protocol_whitelist "file,http,https,tcp,tls,crypto" `
  -i "playlist-local.m3u8" `
  -c copy "course-01.mp4"

-c copy remuxes without re-encode. We reused the same AES-128 localize-and-ffmpeg pattern across the course set; one episode was about 9:51 at 1280×720.

5. Pitfalls we hit (anonymized)#

Symptom

Fix

https not allowed

Add -protocol_whitelist "file,http,https,tcp,tls,crypto"

Incomplete MP4 / missing moov

Delete partial output and restart with a complete playlist

Short Part missing from Cache_Data

Use Console performance.getEntriesByType('resource')

Duplicate index0.ts noise

Dedupe by media id

Ticketed API m3u8 always 422

Prefer CDN expanded variant playlist

6. General recipe for any site#

Download and transcribe checklist overview
  1. Confirm you may keep the content offline;
  2. Play a short stretch in-browser so the session is live;
  3. Capture a usable m3u8 (prefer one that lists .ts);
  4. If #EXT-X-KEY exists, save key.bin, rewrite URI locally, keep IV;
  5. ffmpeg + whitelist + -c copy → MP4;
  6. Smoke-test playback, then transcribe.

Part B — Local batch speech-to-text with faster-whisper#

Download is only half. I also wanted one timed subtitle file and one plain transcript per video, without uploading media to a cloud ASR (installing deps and the first model pull still need network once).

Batch transcription: MP4 → faster-whisper → SRT + TXT

Background and outcomes#

Item

This run

Input

12 MP4s, ~419 minutes total

Mix

9 English + 3 Chinese courses

Output

Matching .srt + .txt per video

Where

Local CPU inference

Model

Multilingual Whisper small (CTranslate2 / faster-whisper)

Tools

faster-whisper, PyAV, OpenCC, FFprobe

Quality bar

ASR draft — needs human proofreading

Note

No initial_prompt in this run

1. Inspect streams with FFprobe#

plaintext
ffprobe -v error `
  -show_entries "format=duration:stream=index,codec_type,codec_name" `
  -of json "course-01.mp4"

All 12 had video + audio; no separate subtitle stream. Some English captions were burned into the picture, so we chose ASR.

Decision tree:

  • Separate subtitle track → try extract first;
  • Burned-in only → OCR or ASR;
  • No captions → ASR draft.

2. Pin the environment#

Python 3.12, faster-whisper==1.2.1, av==16.1.0:

plaintext
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install "faster-whisper==1.2.1" "av==16.1.0" opencc-python-reimplemented

You can pre-download the model directory and pass that path to WhisperModel.

3. Core parameters (exactly this run)#

python
model = WhisperModel(
    model_path,
    device="cpu",
    compute_type="int8",
    cpu_threads=8,
)

segments, info = model.transcribe(
    video_path,
    beam_size=5,
    vad_filter=True,
    condition_on_previous_text=False,
)
  • device="cpu": no GPU this time;
  • compute_type="int8": lighter CPU footprint;
  • cpu_threads=8 (some parallel long jobs used 4);
  • beam_size=5, vad_filter=True, condition_on_previous_text=False;
  • no language= → auto-detect matched the course languages;
  • no initial_prompt.

We passed MP4 paths straight into faster-whisper; PyAV decoded audio—no intermediate WAV export. Load the model once per process, then walk that process’s video list.

4. One recognition pass → SRT + TXT#

plaintext
1
00:00:00,140 --> 00:00:14,580
Dear colleagues. Hello everyone.
plaintext
Dear colleagues. Hello everyone.

Chinese text went through OpenCC t2s (Simplified). Files used utf-8-sig for friendlier Windows editors.

Write course-01.srt.part / course-01.txt.part first, then rename. The script skips a video if either .srt or .txt already exists—if only one is present, inspect before re-running.

Scrubbed examples live in files/transcribe.example.py and files/verify.example.py (edit ROOT / MODEL_DIR).

5. Compatibility: PyAV version clash#

First failure:

plaintext
TypeError: open() got an unexpected keyword argument 'metadata_errors'

faster-whisper called av.open(..., metadata_errors="ignore"), but PyAV 19.x rejected that kwarg. Pinning av==16.1.0 fixed decoding. Lesson for the FAQ: match versions, then prove one audio decode works—do not assume every future release shares the same bug.

6. How we verified#

For each of the 12 videos we checked:

  1. Matching .srt and .txt exist;
  2. Neither is empty;
  3. Cue indices and timestamp format look right;
  4. Cue times are valid and ordered;
  5. Last cue is not wildly past media duration.

All 12 passed those structural checks. That does not mean every word is correct. Spot checks found Chinese homophone mistakes (a brand name heard as a near-sounding word)—fix with context. Names, numbers, and jargon still need the original video.

Reusable prompts#

These are for a local-capable coding agent or a proofreading assistant—not Whisper’s initial_prompt.

1. Batch transcription task#

Short original ask: “Generate a separate subtitle document for every video in this folder.” A tighter brief:

plaintext
Please process every MP4 under the current folder (including subfolders).

Requirements:
1. Inspect duration, audio tracks, and whether a separate subtitle stream exists.
2. Run a local speech model on the audio; auto-detect Chinese or English.
3. For each video, write a same-named SRT and TXT next to the source file.
4. Convert Chinese output to Simplified Chinese.
5. Do not overwrite existing subtitle/transcript files; report conflicts first.
6. Verify outputs exist and cue timelines look valid.
7. Spot-check for proper nouns and unclear audio; flag human review items.
8. Report the model, key parameters, and process you used.

Whether an assistant can execute this depends on its tools and permissions.

2. Proofread a transcript#

plaintext
Proofread the ASR draft below. Fix clear typos, homophones, punctuation,
and sentence breaks using context.

Rules:
1. Keep the speaker’s meaning; do not invent claims that were not said.
2. Correct brand/product names only when context is clear; otherwise mark [to verify].
3. Mark uncertain names, numbers, and jargon as [to verify] — do not guess.
4. If the input is SRT, keep indices and timestamps; edit cue text only.
5. List important edits and items that still need a human.

Transcript:
【paste text or SRT】

Handle internal material only in environments your organization allows.

3. Ask an assistant to draft a tutorial#

plaintext
Using the processing notes below, write a beginner tutorial:
“How to batch-generate subtitles and transcripts locally.”

Requirements:
1. Cover setup, inspect video, recognize audio, export SRT/TXT,
   verify/proofread, and FAQ — in that order.
2. Separate parameters we actually used from optional optimizations.
3. Explain why ASR drafts still need humans.
4. Do not invent runtime, accuracy %, or steps we did not run.
5. Include copy-paste commands and AI-assistant task prompts.

Notes:
【paste the technical flow and parameters】

Closing#

One sentence: HLS you can play—and are allowed to archive—can become a local MP4; local Whisper turns that into a searchable draft. ASR saves “typing from scratch,” not proofreading. Keeping keys, tickets, and course media inside your own machine and policy boundary matters more than chasing a magic one-click tool.

Comments

No comments yet — be the first to leave one.

Related articles