Is it possible to make m3u8 file smaller by removing the base URL parts of all ts file URL in m3u8 - http-live-streaming

1). My .m3u8 files and all .ts files are all located at a website like http://m3u8.abc.com/xxx.m3u8(.ts).
2). In m3u8 file, every #EXTINF parts points to a URL such as:
#EXTINF:3.436767,
http://m3u8.ffmlive.com/47AE361A16FF0BA311E272CA925AEB4004751D6C0000.ts
#EXTINF:2.268933,
http://m3u8.ffmlive.com/47AE361A16FF0BA311E272CA925AEB4004751D6C0001.ts
#EXTINF:1.968633,
http://m3u8.ffmlive.com/47AE361A16FF0BA311E272CA925AEB4004751D6C0002.ts
#EXTINF:1.034367,
http://m3u8.ffmlive.com/47AE361A16FF0BA311E272CA925AEB4004751D6C0003.ts
...
3). There are hundreds of .ts files in each m3u8 file.
My question is: Does m3u8 file standard supports to set a base URL, and make all segment parts use relative URIs. so it helps to make m3u8 file smaller and easier to load. such as
#EXT-X-BASE-URL: http://m3u8.ffmlive.com
#EXTINF:3.436767,
/47AE361A16FF0BA311E272CA925AEB4004751D6C0000.ts
#EXTINF:2.268933,
/47AE361A16FF0BA311E272CA925AEB4004751D6C0001.ts
#EXTINF:1.968633,
/47AE361A16FF0BA311E272CA925AEB4004751D6C0002.ts
#EXTINF:1.034367,
/47AE361A16FF0BA311E272CA925AEB4004751D6C0003.ts
...
If it does, how to do with it?

It supports realitive URLs, just like HTML. But the base is the manifest URL, and there is not a way to override that.

Related

Losing the .txt extension of .txt.gz file after saving a python requests response as .gz

I have a list of HTTP URLs which return file content and I have saved those in a file. I don't know which URL will return what file content type. One of the URLs, when manually loaded on browser, downloads a .txt.gz file. However when I check for the content type of the request response it is application/x-gzip, and the file signature is 1f8b08 indicating a .gz file. When I save this file as .gz, the .txt extension of internal file is lost. And a file without any extension is present in the saved .gz file.
Is there any way to know what the file type of the file compressed inside the .gz or .zip file is from the requests content? Or to know that the file is a .txt.gz file?
In the image above we can see that the file inside 12345.gz does not have a .txt extension when I write the response content to a .gz file. But when I load the URL manually, the internal file has a .txt extension.
After reading the response content:
I am able to identify that the file signature is for .gz file but is there any way to know that file inside .gz archive is .txt or other type of file.
Here is an example of .gz file i get by manually downloading and saving the response.

Extract WAV from RAW database file

I have a .raw file. The header seems XML and the included files .wav.
What I know is the filename, the offset and the filesize of the particular files.
What I've tried is extracting a .wav from the .raw file with:
dd bs=1 seek=1147710 count=455346 if=Data.raw of=output.wav
But the file was not playable. I added a .wav header from another .wav and all what I got was noise. Maybe I extracted the file wrong?
The beginning of the .raw file looks like this:
<FILE name="File 1.wav" offset="1147710" size="455346"/>
and after all those flags I get only data for a million lines:
ö•Æû^0å?w±lŽ{ÜA2ôy™^¼’rBõM,Ó¾ä¥x‹ƒº£Ö
Can anyone point me in the right direction? Do I need to add a header to it? Or did I extract it wrong?
Thank you
Extract with dd
Add .wav header from another file, but not sure if I got the header right
Played without header (didn't play)

Parse bytes of a zip file?

I am requesting a zip file from an API and I'm trying to retrieve it by bytes range (setting a Range header) and then parsing each of the parts individually. After reading some about gzip and zip compression, I'm having a hard time figuring out:
Can I parse a portion out of a zip file?
I know that gzip files usually compresses a single file so you can decompress and parse it in parts, but what about zip files?
I am using node-js and tried several libraries like adm-zip or zlib but it doesn't look like they allow this kind of possibility.
Zip files have a catalog at the end of the file (in addition to the same basic information before each item), which lists the file names and the location in the zip file of each item. Generally each item is compressed using deflate, which is the same algorithm that gzip uses (but gzip has a custom header before the deflate stream).
So yes, it's entirely feasible to extract the compressed byte stream for one item in a zip file, and prepend a fabricated gzip header (IIRC 14 bytes is the minimum size of this header) to allow you to decompress just that file by passing it to gunzip.
If you want to write code to inflate the deflated stream yourself, I recommend you make a different plan. I've done it, and it's really not fun. Use zlib if you must do it, don't try to reimplement the decompression.

How to add zip file without compression using node.js?

I am converting docx to epub using pandoc. After converting epub, i do changes with zip file and converting epub also. At that time,
I got the following issue after converting zip file to epub on mimetype file.
Mimetype contains wrong type (application/epub+zip expected).
I am searching a lot and get two logic
First one e.g., extra spaces, new line characters but it was going vain(there is no extra spaces, new line).
Add the mimetype file without compression in zip.
I am getting struck with second point. How to add mimetype file without compression in zip using node.js coding.
var archiver = require('archiver');
var archive = archiver('zip');
archive.file('d:\\xxxx'+'\\mimetype', { name:'mimetype'});
What is the problem in the above code and any attribute for zip?
Can any one assist me for adding file without compression in zip?
Thanks in advance.
add the zip option {store:true} for without compression
https://www.npmjs.com/package/archiver#store-boolean

How many .ts files should be there in .m3u8 file for Live streaming?

For Http Live streaming, initially I have added 3 .ts files in to .m3u8 file it starts playing. In what ways should I append the incoming .ts file into .m3u8 file?
Shall I keep appending?
Shall I replace the older files with new one? If so in what order like, new set of files?
The best method I've seen is where you decide on the amount of "history" you want, for example H = 20 files, and then publish on the last X files in the playlist (if each segment is 10 seconds, then 3 files is a good idea).
you start by publishing movie_000, movie_001, and movie_002.
after 10 seconds you publish movie_001, and movie_002 and movie_003
...
and so on until you reach the amount of files you wish to have and then you rewrite older files (this way your hard drive doesn't overflow with data)
so after H files X 10 seconds, you will have movie_018, movie_019, movie_000

Resources