The silent MP4: why grabbing an HLS stream gives you video with no sound
You wrote the scraper. It found the .m3u8, pulled every segment, concatenated them, and ffprobe says the result is a valid H.264 MP4. You open it. The picture is perfect. There is no sound.
This is the single most common bug in home-grown video downloading, and it is not a bug in your code. It is how the streams are published.
Why the audio is somewhere else
Adaptive streaming splits a video into independent tracks so a player can switch quality without re-downloading audio. In HLS that split is explicit in the manifest:
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud",NAME="English",URI="audio/en.m3u8" #EXT-X-STREAM-INF:BANDWIDTH=4500000,RESOLUTION=1920x1080,AUDIO="aud" video/1080p.m3u8 The #EXT-X-STREAM-INF line gives you picture. The #EXT-X-MEDIA line points at a second playlist that contains nothing but audio segments. DASH does the same thing with separate AdaptationSets and a Role descriptor.
So when you follow the video playlist, you get exactly what you asked for: a video-only file. It plays, it has a duration, it has a resolution. It is silently incomplete.
If you are inspecting a manifest by hand, that is the check: does the master playlist contain #EXT-X-MEDIA:TYPE=AUDIO? If yes, you must fetch that URI as well and mux the two. If the media playlist itself has #EXT-X-MAP and nothing else unusual, you are probably on a muxed stream and single-track fetching is fine.
Three things that break the naive fix
Fetching both playlists and concatenating them does not work either — you cannot staple an AAC stream onto the end of an H.264 stream. You need a container. But before you reach for ffmpeg, three details will bite you:
Interstitial ad segments. Some hosts splice ad segments into the same playlist between the real ones. Concatenate everything and your episode has a 15-second detour three minutes in. There is no flag that marks them reliably; in practice you compare segment timelines and drop segments whose continuity breaks.
AES-128 encryption. Segments can be encrypted with a key referenced by #EXT-X-KEY. The key URI is usually fetchable with the same session that served the manifest, so decryption is local and lossless — but if you skip it, ffmpeg fails with a decode error rather than telling you what is missing.
Track length mismatch. If the audio playlist has a different total duration than the video one, you grabbed two different sources (an ad variant, a different language, a re-encode). Merging them anyway gives you a file that is silently trimmed to whichever track is shorter. This is the failure that looks completely fine afterwards.
The part that actually works
Download both tracks, then copy them into one container without re-encoding:
ffmpeg -i video.mp4 -i audio.m4a -c copy -movflags +faststart out.mp4 -c copy matters. Re-encoding costs quality and minutes of CPU for a task that is pure container work. From Python:
subprocess.run([ "ffmpeg", "-y", "-i", video_path, "-i", audio_path, "-c", "copy", "-movflags", "+faststart", out_path, ], check=True) And the audio track you get is still an audio track — you can write it out as MP3 directly if that is all you wanted, without ever touching the video.
Verify before you accept
A "download finished" event means bytes stopped arriving. That is not the same as a file that opens. Before you move the output anywhere, check three things:
def looks_complete(path, expected_seconds): probe = json.loads(subprocess.run([ "ffprobe", "-v", "quiet", "-print_format", "json", "-show_format", "-show_streams", path, ], capture_output=True, text=True).stdout) duration = float(probe["format"]["duration"]) has_audio = any(s["codec_type"] == "audio" for s in probe["streams"]) size = os.path.getsize(path) if size < 256 * 1024: return "fragment or init segment, not a video" if duration < expected_seconds * 0.7: return f"preview: {duration:.0f}s of {expected_seconds:.0f}s" if not has_audio: return "no audio track: separate audio playlist was not fetched" return None Those three checks catch most of the ways a download lies to you: a 40-second "video" that is really the init chunk, a 90-second sample served instead of a 40-minute episode, and the silent MP4 itself.
The 70% threshold is not magic — it is just wide enough to tolerate encoding padding and narrow enough to catch previews. Adjust it if your source is unusual, but keep some version of it: without a check, a failed download and a successful one look identical from the outside.
The uncomfortable conclusion
Every one of these failures produces a file that opens. That is why they survive: the download is "done", the user blames the site, and the bug is never filed. The fix is not a better scraper. It is treating "complete" as a claim you have to verify, the same way you would treat a database write or a payment callback.
I build GanKa Downloader, a Windows download manager that does this in the normal path: separate audio and video are downloaded, merged losslessly, then checked against size, duration and audio-track rules before the task is marked finished. The checks above are the same ones it runs.