What's the correct way to escape characters in m3u playlist? - vlc

I have a file name that contains a "#" character and I am having issues creating a playlist that both VLC and MPV will accept (those are the two players I have tested.)
It seems if I use the following, it will work in MPV but not VLC.
#EXTM3U
#EXTINF:282,Marilyn Manson - Revelation #12
01. Revelation #12.flac
And if I use the following it will work in VLC but not MVP.
#EXTM3U
#EXTINF:282,Marilyn Manson - Revelation #12
01.%20Revelation%20%2312.flac
Is there something I am missing or is one or more of these programs simply buggy and there is no compatible solution beyond removing troublesome characters from file names all together?

It seems the reading of m3u files without url-encoded file names was not possible in VLC 3.0.16 and probably certain previous versions. It has been fixed in VLC 3.0.17
See https://forum.videolan.org/viewtopic.php?f=2&t=158920&start=25#p529284
In the current version though, as of this writing (3.0.17.3), there still are characters that need to be url-encoded for VLC being able to read them, one of them being the # character as the VLC developer points out in aboves post. It's unclear if this is about to be fixed in a future version of VLC.

Related

How to download an mp4 video from a blob url or m3u8? [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
The community reviewed whether to reopen this question 6 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I want to download a video whose URL is not a simple MP4 file, but rather a blob type for example:
<video id="playerVideo" width="450px" autoplay="autoplay" height="338px"
style="height:100%;width:100%;" class="mejs-rai-e"
src="blob:http://www.example.com/d70a74e1-0324-4b9f-bad4-84e3036ad354">
</video>
Is there any chrome extension or software which can be used to download videos from blob URLs?
I just came up with a general solution, which should work on most websites.
I tried this on Chrome only, but this method should work with any other browser, though, as Dev Tools are pretty much the same in them all.
Steps:
Open the browser's Dev Tools (usually F12, or Ctrl-Shift-I, or right-click and then Inspect in the popup menu) on the page with the video you are interested in.
Go to Network tab and then reload the page. The tab will get populated with a list of requests (may be up to a hundred of them or even more).
Search through the names of requests and find the request with .m3u8 extension. There may be many of them, but most likely the first or largest is the one you are looking for. It may have any name, e.g. playlist.m3u8.
Click its name to open the request. Under the Headers subsection you will see request's full URL in the Request URL field. Copy it.
Extract the video from m3u8. There are many ways to do it, I'll give you those I tried, but you can google more by "download video from m3u8".
Option 1. If you have VLC player installed, feed the URL to VLC using the "Open Network…" menu option. I'm not going to go into details on this part here, there are a number of comprehensive guides in many places, for example, here. If the page doesn't work, you can always google another one by "vlc download online video".
Option 2. If you are more into command line, use FFMPEG or your own script, as directed in this SuperUser question.
Use the HLS Downloader Google Chrome extension to get the link to the M3U playlist. Its icon in the browser bar will show the number of playlists found on the current webpage. Clicking on the icon you can then see a list of the playlist link and then use the copy button next to a link to copy it.
Then use the youtube-dl program to download the file.
youtube-dl --all-subs -f mp4 -o "file-name-to-save-as.mp4" "https://link-from-Google_Chrome-HLS_Downloader_extension"
Explanation of command line options:
-f mp4 = Output format mp4
--all-subs = Download all subtitles
-o "file-name-to-save-as.mp4" = Name of the file to save the video as.
"https://link-from-Google_Chrome-HLS_Downloader_extension" = This is the link to the playlist you copied from the HLS Downloader extension.
If you use the same configuration options all the time for youtube-dl you may want to take a look at the configuration options for youtube-dl, as this can save you a lot of typing.
The HLS Downloader extension is free and open source under the MIT license if you want to see the code it can be found on its project page on Github.
There are a variety of ways to get the URL .m3u8 either by viewing the source of a page, looking at the Network tab in the Developer Tools in Chrome, or using a plugin such as HDL/HLS Video Downloader.
With the .m3u8 URL in hand you can then use ffmpeg to download the video to a file like so:
$ ffmpeg -i 'https://url/to/some/file.m3u8' -bsf:a aac_adtstoasc \
-vcodec copy -c copy -crf 50 file.mp4
This is how I manage to "download" it:
Use inspect-element to identify the URL of the M3U playlist file
Download the M3U file
Use VLC to read the M3U file, stream and convert the video to MP4
In Firefox the M3U file appeared as of type application/vnd.apple.mpegurl
The contents of the M3U file would look like:
Open VLC medial player and use the Media => Convert option. Use your (saved) M3U file as the source:
The process can differ depending on where and how the video is being hosted. Knowing that can help to answer the question in more detail.
As an example; this is how you can download videos with blob links on Vimeo.
View the source code of the video player iframe
Search for mp4
Copy link with token query
Download before token expires
Source & step-by-step instructions here.
If you can NOT find the .m3u8 file you will need to do a couple of steps different.
1) Go to the network tab and sort by Media
2) You will see something here and select the first item. In my example, it's an mpd file. then copy the Request URL.
3) Next, download the file using your favorite command line tool using the URL from step 2.
youtube-dl -f bestvideo+bestaudio https://url.com/destination/stream.mpd
4) Depending on the encoding you might have to join the audio and video files together but this will depend on a video by video case.
Find the playlist/manifest with the developer tools network tab. There is always one, as that's how it works. It might have an m3u8 extension that you can type into the Filter. (The youtube-dl tool can also find the m3u8 tool automatically some time give it a direct link to the webpage where the video is being displayed.)
Give it to the youtube-dl tool (Download). It can download much more than just YouTube. It'll auto-download each segment then combine everything with FFmpeg then discard the parts. There is a good chance it supports the site you want to download from natively, and you don't even need to do step #1.
If you find a site that is stubborn and you run into 403 errors... Telerik Fiddler to the rescue. It can catch and save anything transmitted (such as the video file) as it acts as a local proxy. Everything you see/hear can be downloaded, unless it's DRM content like Spotify.
Note: in the window, you can use youtube-dl.exe using "Command Prompt" or creating a batch file. i.e
Thanks
I posted this already at some other websites and though why not share it with guys/gals at stackoverflow.
Install the Video DownloadHelper extension on Firefox browser.
With DownloadHelper activated, navigate to the webpage containing the video that you want to download.
Once the video is streaming, click on the DownloadHelper icon. It will give you a list of all file formats available on the current video.
Scroll onto the file format that you wish to download
On the right hand side, you will see an arrow
Click on that arrow to get more information regarding the current video and the selected format
From the displayed window at the end of that arrow, scroll down and select "Details"
You now have all the details concerning the current video and the selected format. It is something like this.
Hit Details⊗
_needsAggregate
_needsCoapp
actions
bitrate
chunked
descrPrefix
durationFloat
extension
frameId
fromCache
group
hls
id
isPrivate
length
masterManifest
mediaManifest
originalId
referrer
size
status
title
topUrl
url
urlFilename
Now, look at the specifics of the referrer in that Hit Details. That's the url you want. Copy it and paste on your favorite downloader.
If the blob is instantiated with data from an F4M manifest (check the Network Tab in Chrome's Developer Tools), you can download the video file using the php script posted here: https://n1njahacks.wordpress.com/2015/01/29/how-to-save-hds-flash-streams-from-any-web-page/
By putting:
if ($manifest == '')
$manifest = $_GET['manifest'];
before:
if ($manifest)
you could even run it on a webserver, using requests with the query string: ?manifest=[manifest url].
Note that you'll probably want to use an FTP client to retrieve the downloaded video file and clean up after the script (it leaves all the downloaded video parts).

Adding chapters to MP4 files, and being identified on iOS 12 podcast app

I have an MP4 file, where I've added chapters via ffmpeg.
But in the iOS 12 Podcasts app, from Apple, the chapters don't appear. This should happen, as noted by idownloadblog.com
In comparison, when using QuickLook on MacOS, the list of chapters can be seen by clicking the chapters button (in the bottom right hand side of the window).
And opening in QuickTime Player, while there isn't a list of chapters to view, you can use the "View > Next Chapter" menu item.
So I'm assuming this is a bug in iOS... but I'm wondering if there is another way to add chapters? or if I've made a mistake?
My current process is to create a "ffmetadata" file, as noted in the ffmpeg documentation:
;FFMETADATA1
title=Example
[CHAPTER]
TIMEBASE=1/1000
START=0
END=221913
title=Chapter 1
[CHAPTER]
TIMEBASE=1/1000
START=221913
END=1169241
title=Chapter 2
https://ffmpeg.org/ffmpeg-formats.html#Metadata-1
Then I've tried each of the following commands:
ffmpeg -i 2019-01-02.mp4 -i 2019-01-02.meta -map_metadata 1 -codec copy 2019-01-02-chapters.mp4
ffmpeg -i 2019-01-02.mp4 -i 2019-01-02.meta -map_metadata 1 2019-01-02-chapters.mp4
ffmpeg -i 2019-01-02.mp4 -i 2019-01-02.meta -map_metadata 1 2019-01-02-chapters.mp3
The first one is from the ffmpeg documentation, where -codec copy means the audio file is not re-encoded.
The second one takes longer, while it re-encodes the audio data.
The third one requires re-encoding to convert it into an MP3 file (which uses ID3 tags for the chapter data).
On a slightly unrelated note, the third party app "RSSRadio" does list the chapters, but the feature added in version 4 that allows you to "skip directly to the start of the next chapter", if the next chapter starts within the next 3 minutes, does not seem to work.
Simple answer, it needs to be an M4A file.
While MP4 and M4A files are pretty much the same, M4A is limited to audio format, whereas an MP4 can also contain video.

Ignore known header of video file

i have video uncompressed .avi video files. however they come with a known 2048kb header at the beginning of the file, such that no video program (Vlc player) recognises the file as video files. can i force VLC to ignore the first 2048kb? how?
what would be the easiest way to remove this header?
Unfortunately there is no known to me way of getting vlc to use a larger "probesize" or somehow just skip to byte X.
Also unfortunately there is no known to me way to add some "camouflage" or even add an empty chunk to the front of an avi container. Next approach could be to genereate a reference movie but also no automatic usage tools available at the best of my knowledge. And as there is also no way to just "set or change" the start offset of a file, we have to copy it.
My recommendation for copying parts of files is this sourceforge project: skf
https://sourceforge.net/projects/swissfileknife/?source=typ_redirect
some examples

MPD templates for MPEG DASH TS content

I am looking for MPD templates which can be used to stream MPEG2-TS fragments.
Client is VLC with DASH plugin.
Go http://mediapm.edgesuite.net/dash/public/support-player/current/index.html and change the "Caption Test" to something else. You would get a corresponding .mpd then.
I couldn't find any fragmented content for DASH with video/mp2t mimeType. I looked here but all of them are based on BMFF (video/mp4) so I think that the best option is to generate your own fragments and corresponding MPD. You can use Gpac's MP4Box like described here.
It appears that most of the work that was put into DASH is based on ISOBMFF and not on MPEG2 TS. Maybe because it provides better separation between audio and video, therefore in case of adaptation you have more flexibility. (Using TS you must create muxed content for each configuration).
The public MPEG-DASH standard is available here: ISO/IEC 23009-1:2014
See sections 6.4, 7.4, 8.6, 8.7, G.3.
You can also find the schema files here: MPEG-DASH Schema

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