LinkedIn videos use HLS to stream video content. HLS uses m3u8
playlist file which contains the path to all the fragments for that media. We can use ffmpeg
to download the contents from the playlist and convert it into a single file.
#!/bin/bash
ffmpeg -user_agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.157" \
-i "${@:1}" \
-c copy $(date '+%d-%m-%Y-%H-%M-%S').mp4
Save this as say m3u8-download
. Here I am using mp4
as the container. If this is not encoding properly, we can use mkv
and then convert it to mp4
.
Identifying the playlist
1. Open the LinkedIn post containing the video in a new page.
2. Open Network
panel from browser's Web Inspector
.
3. In Filter Full URL
, search for playlist
and check the Preview
to see if it has content of the form:
Here it lists various resolutions. Based on the bandwidth one of these link will be loaded. We can instead use the playlist link from this file.
4. Here we can see the playlist for 720p
video.
5. Get the URL from the Headers
section and use it with the above script.
m3u8-download "https://dms.licdn.com/playlist/vid/pl/D4000ffffffffff00Sg/hls-720p-30fp-crf28/0/1706767890123?e=1715167890&v=beta&t=Lira7003k0v50uAbcaTS5vfUfIyflxfmMFfBufvbfmg"