How to: Playm3u8 files offline in VLC - vlc

I'm using an offline terminal to create an .m3u8 file but I would like to play it using VLC. Every example so far has shown examples of using m3u8 online but this isn't an option for me. If you can play it offline using VLC how do you do so?

You have to download the playlist from m3u8 to watch it offline and to do that you have to either use youtube-dl or ffmpeg
i would recommend ffmpeg , and the command for downloading the m3u8 file goes like this :-
ffmpeg -i "here your m3u8 link" -c copy Output.mp4
This will download the highest quality video available in that m3u8 file.
To change quality you can use map command or simply download the m3u8 file and open it with notepad and there you will find links for other resolution.

m3u8 files are just playlists without actual contents, but just URL pointers. Those files are mostly being used these days for HLS.
While you can play the files while offline, you won't see anything unless you are also hosting the referenced Contents.

Related

Getting .mp4 from .f4m stream url

Currently I have the following url
http://vpl.rtl.be/z//2018/08/21/CA00001318626_,400,600,800,1200,1800,.mp4.csmil/manifest.f4m?hdcore=1
which contains an .f4m file, which directs to an mp4 file.
I can't find a way to get that mp4 from that file (i just need the direct mp4 url or file).
How should I proceed? I have tried using ffmpeg or simply reading the file, with no luck.
I'm not much familiar with FFMpeg but you can try livestreamer :-)
Command line:
livestreamer "hds://http://vpl.rtl.be/z//2018/08/21/CA00001318626_,400,600,800,1200,1800,.mp4.csmil/manifest.f4m?hdcore=1" best -o video.ts
I tried in .mp4 format but it didn't like that, the file header shows FLV, you can use VLC Media Player to open the video.ts file.
Good luck!

How to download HLS stream into a local machine?

Sometimes it is useful to download a stream into our local machine.
Reasons could be
To make a manual modification to the manifest
For getting fast access to files of a server with poor networking.
If we try to use curl or wget to download the asset which is pointed by the URL for the stream, we end up downloading a small text file. It is surely not the video asset.
So how can we download the stream itself?
The actual script which does the download is given in the link at the bottom of my answer. But before we proceed to the how-to, let's first understand the steps for downloading a stream.
Without going into too much details, the URL pointing to the stream is typically named with the m3u8 extension. That file is called the manifest of the stream and is actually a text file containing, among other things, a list of pairs: a bitrate and a corresponding URL for the matching playlist file. Here is an excerpt from a manifest file:
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=380600,CODECS="avc1.4d00c,mp4a.40.2",RESOLUTION=320x180
http://f24hls-i.akamaihd.net/hls/live/221193-b/F24_EN_LO_HLS/master_250.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=655600,CODECS="avc1.77.30,mp4a.40.2",RESOLUTION=640x360
http://f24hls-i.akamaihd.net/hls/live/221193/F24_EN_LO_HLS/master_500.m3u8
A playlist file is another text file which tell the player which TS file is to be playing on each position of the playback head.
Here is the beginning of a typical playlist file:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:303165
#EXTINF:10.000,
20170216T114458/master_500/00151/master_500_01165.ts
#EXTINF:10.000,
20170216T114458/master_500/00151/master_500_01166.ts
So after downloading the playlist file for each of the bitrates, we can start downloading the TS files required to play the stream at each of the possible bitrates.
All this is done using a quite simple and self-explaining script which I was putting in GitHub: https://github.com/ishahak/HLS_Downloader
I hope it will be useful for others.
You can simply use ffmpeg. Like this:
fmpeg -i "http://somewhere.com/video.m3u8" -c copy -bsf:a aac_adtstoasc output.mp4

How to play ts file using the cache in the AVPlayer?

I want to cache the HLS in the ts file.
Apple demo site use custom schema for this site.
https://developer.apple.com/library/ios/samplecode/sc1791/Introduction/Intro.html
This sample use custom schema. But it's use redirect for ts file.
I searched "How to play ts file using the cache in the AVPlayer". I found use redirect local proxy. But it method is prohibited to Apple that the move background.
https://developer.apple.com/library/ios/technotes/tn2277/_index.html#//apple_ref/doc/uid/DTS40010841-CH1-SUBSECTION2
Is it possible to start the ts file cached locally on the AVPlayer ?
As far as I know, Its not possible to play ts files directly using iOS Player (AVPlayer).
But there is a way to play it.
Download the .ts file and save it in app document directory.
Use this library Keemotion/TS2MP4 to
convert ts file to mp4 which can be played using AVPlayer.
Now you can either do it discreetly downloading -> convert -> play for each single file.
or You can download multiple -> convert them to one large mp4 file and play it.

Is there a way to render the images from the stream of youtube video data or any video stream data?

I want to know how to get the images of a particular video strem data?
What are the ways to do this?
Use one of your favorite downloading tools/extensions to download the video file to your computer. Then get and use ffmpeg, with the following command line:
ffmpeg -i video.mp4 image_%3d.jpg

Streaming Technique from pocketcast in xcode

I've been asked by my client whether it is possible to download a video and stream it once a bit has downloaded, just like pocketcasts does. His reasoning is this will allow him to store his video files on a site such as godaddy and bypass the need to stream the file to the phone which normally requires a dedicated server.
Is this even possible? if so do you know anywhere I can look to find out how pocketcasts does it? At the moment my app just streams an mp4.
Thanks for looking,
Matt
Since you're targetting iOS, HLS (HTTP Live Streaming) is your friend: https://developer.apple.com/streaming/
Please see my answer here for how you can use it: Simultaneously downloading and playing a song that is pieced together from multiple URLs
It's very easy to run a long movie through the mediafilesegmenter tool from Apple (or FFMPEG) which spits out a number of small .ts files (MPEG 2 Transport Stream). Then you create a manifest (a .m3u8 file) which describes how these files fit together (which mediafilesegment will create for you too!). Then you just put the manifest file and the .ts files on a hosting provider (like GoDaddy) and you're all set.
For example, given a file called test.mp4, first turn it into a .ts file with ffmpeg:
ffmpeg -i test.mp4 -acodec copy -vcodec copy -bsf h264_mp4toannexb test.ts
Then turn it into a series of HLS segments with mediafilesegmenter (the same can be done using the ffmpeg segment muxer, but mediafilesegmenter seems to be more robust):
mediafilesegmenter -t 3 test.ts
The result is a bunch of 3 second clips (that's what -t 3 means) and an manifest file called prog_index.m3u8. The contents of that look like:
#EXTM3U
#EXT-X-TARGETDURATION:3
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:2.99520,
fileSequence0.ts
#EXTINF:2.99520,
fileSequence1.ts
#EXTINF:2.99520,
fileSequence2.ts
#EXTINF:2.99520,
fileSequence3.ts
...
#EXTINF:0.37440,
fileSequence75.ts
#EXT-X-ENDLIST
Simply putting all of the .ts files and the .m3u8 file on a web server and pointing your AVPlayer or MPMoviePlayerController in iOS at the URL for the .m3u8 will get you an excellent streaming performance.

Resources