m3u8 to mp4 with merged audio

Adam Mateusz Brożyński - Aug 4 '23 - - Dev Community

Script below allows to download video files from m3u8 playlist, join them to create a single mp4 video file and merge it with an audio track. It automatically searches for full hd video format (1920x1080) and separate audio track. You need to have youtube-dl, grep and awk installed on your system.

#!/bin/bash
youtube-dl -f $(youtube-dl --list-formats $1|grep 1920|awk '{print $1}'||tr -d '\n')+$(youtube-dl --list-formats $1|grep audio|awk '{print $1}'||tr -d '\n') --hls-prefer-native $1 -o $2
Enter fullscreen mode Exit fullscreen mode

Save file as m3u8dl and make it executable (chmod +x ./m3u8dl).

Usage: m3u8dl <m3u8_url> <output_filename>

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .