M3U8 file to MP4 conversion?

23

13

Can an M3U8 video file be converted to MP4? I have had no luck finding a file converter that can do this since the M3U8 file is really an Audio playlist with many smaller files in a folder.

Rick Jones

Posted 2015-02-26T18:29:18.810

Reputation: 231

4M3U is a playlist format. What exactly do you want to get? A single large audio file? – Daniel B – 2015-02-26T18:41:28.480

Can you tell us what have you tried and what results you're expecting? – Darius – 2015-02-26T18:42:27.930

I have actually downloaded a video with extension m3u8. I cannot get it onto my Iphone video player app by file sharing since the file is a folder of smaller files. It is suggested I use mp4. I am hoping to get the m3u8 video in mp4 format. – Rick Jones – 2015-02-26T19:00:03.623

As m3u8 is not a standard and known format for video you are going to need to provide more information on the file. Where did you download it from? How large is the file? Do you have any more details on the file at all? – Mokubai – 2015-02-26T19:11:27.027

As suspected m3u8 is not an actual video file but is a playlist used to link together video files: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/DeployingHTTPLiveStreaming/DeployingHTTPLiveStreaming.html http://stackoverflow.com/questions/19782389/playing-m3u8-files-with-html-video-tag People are suggesting you use mp4 because what you have is not a video file, it is a playlist that links together streamed video files.

– Mokubai – 2015-02-26T19:19:32.287

Can it be converted to MP4 by somehow recording it? – Rick Jones – 2015-02-26T19:23:31.213

Answers

31

You can use ffmpeg to do this...

Here is an example:

ffmpeg -i "http://host/folder/file.m3u8" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 file.mp4

John E

Posted 2015-02-26T18:29:18.810

Reputation: 411

2That looks like a local network ip address, meaning only the people on the same network can use that link. Can you clean up and add more information to your answer? – Cfinley – 2015-04-08T16:26:34.657

You are correct, it is a local server. However, the command line switches still apply to be able to convert an HLS stream to MP4 – John E – 2015-04-09T16:58:59.657

Does not work with ssl – jjxtra – 2015-09-30T17:16:01.763

Is it possible to include Captions or subtitle tracks? Can't seem to find much on that. – Justin – 2016-02-10T20:56:42.377

Yes take a look here on how to export the captions https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo

– John E – 2016-02-11T21:23:39.917

This answer would be a lot more helpful with an explanation of what the options do. Obviously there's man ffmpeg but that's not as simple. – YPCrumble – 2018-06-08T14:21:14.367

@YPCrumble Here's an example to add a subtitle track to a video without re-encoding (softsub) : ffmpeg -i video.mp4 -i subTrack1.vtt -map 0:a -map 0:v -map 1 -c copy -c:s mov_text video_NEW.mp4 You can read more at FFMPEG An Intermediate Guide/subtitle options

– SebMa – 2019-04-10T00:38:48.200

3

M3U is a playlist file as previously mentioned. Use VLC player to open them and then use the wizard (File → Streaming/Transcoding Wizard) to convert/transcode.

If you open the M3U in Notepad you will see the URL of where the file is actually stored.

askmematt

Posted 2015-02-26T18:29:18.810

Reputation: 54

It works (use web URL of M3U file). for test you can play M3U file with VLC player. – M-Razavi – 2017-04-08T20:25:54.543

1

You can also use youtube-dl to download your video from a m3u8 url, example :

$ youtube-dl --hls-prefer-native "http://host/folder/file.m3u8"
[generic] playlist: Requesting header
[generic] playlist: Downloading m3u8 information
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 275
[download] Destination: file-file.mp4
[download] 100% of 123.19MiB in 01:02
[ffmpeg] Fixing malformed AAC bitstream in "file-file.mp4"

To install/update youtube-dl, you need to type :

$ sudo -H $(which pip3) install -U youtube-dl
[sudo] password for xyztabcd:              
Requirement already up-to-date: youtube-dl in /usr/local/miniconda3/lib/python3.6/site-packages (2019.4.7)

SebMa

Posted 2015-02-26T18:29:18.810

Reputation: 599

1

As @Daniel B pointed out, M3U is a playlist format. It is a very small file that contains links to the actual media. M3U8 is the Unicode version of it, which means that it supports links with letters and symbols from any language.

Since it is a plain text file, you can open it with Notepad or other simple text editor and try to copy the links from it, and then download each video manually with your browser.

If it isn't a direct HTTP(S) link to the video, but a streaming technology like RTMP, you may need to download a special program to record it. For example, this is used to save RTMP streams.

user33758

Posted 2015-02-26T18:29:18.810

Reputation:

1

I downloaded video file xxxx-ad .m3u8 recently and I tried to solved the same problem (downloaded with Apowersoft from online stream). The file was only 201b big and it needed internet connection to play.

I used formatfactory. I was unable to open this file with FF at first. You can not use open button.

But if you point and click on file and move it to FF window, it allows you to add it, choose format and rip it. Result is classical video file that can be played offline. Same works if you want only audio file like mp3.

enjoy

user520477

Posted 2015-02-26T18:29:18.810

Reputation: 11

0

At least in recent versions of Internet Download Manager, you should get a .ts file rather than .m3u8 (unless you copy an .m3u8 link and try adding that as a download manually0, as it supports downloading HLS (.m3u8) streams properly. You can play that file directly in some players. If you want an .mp4 file, you can use a tool like My MP4Box GUI (or FFmpeg, see JohnE's answer and just put the .ts file's path after -i instead of the link).

nyuszika7h

Posted 2015-02-26T18:29:18.810

Reputation: 2 024

-2

Changing the extension worked for me.
I downloaded a movie using internet download manager in .m3u8 format changed the extension to .mp4
POOF computer science at work - I was able to play the file.

Cray-Z.Guy

Posted 2015-02-26T18:29:18.810

Reputation: 1

1I think this only works if the host is also storing an mp4 file, so all you did was download that file. It didn't work for me. – Sridhar Sarnobat – 2016-10-01T19:50:13.847