I have an issue:
I have m3u8 file format such as:
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=490000,RESOLUTION=640x360
http://XXX.XXX.XX.XXX:31213/MEDIA/76336503.....583609776254/161/4161/
#EXT-X-STREAM-INF:BANDWIDTH=1500000,RESOLUTION=720x576
http://XXX.XXX.XX.XXX:31213/MEDIA/76336503.....583609776254/161/3161/
#EXT-X-STREAM-INF:BANDWIDTH=2500000,RESOLUTION=1280x720
http://XXX.XXX.XX.XXX:31213/MEDIA/76336503.....583609776254/161/2161/
Each EXT-X-STREAM-INF tag link to file like:
#EXTM3U
#EXT-X-TARGETDURATION:5
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:35156
#EXT-X-START:TIME-OFFSET=-25,PRECISE=YES
#EXT-X-KEY:METHOD=AES-128,URI="http://XXX.XXX.XX.XXX:02444/xxXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/191/2191/aeskey_191_
#EXTINF:5,
http://XXX.XXX.XX.XXX:XXXXX/SSEGMENT/3020314583628416652818934133893/191/2191/seg_XXXXX.ts
#EXTINF:5,
http://XXX.XXX.XX.XXX:XXXXX/SSEGMENT/6545456465456456465454564/191/2191/seg_191_XXXXX.ts
#EXTINF:5,
http://XXX.XXX.XX.XXX:XXXXX/SSEGMENT/6545456465456456465454564/191/2191/seg_191_XXXXX.ts
#EXTINF:5,
http://XXX.XXX.XX.XXX:XXXXX/SSEGMENT/6545456465456456465454564/191/2191/seg_191_XXXXX.ts
#EXTINF:5,
http://XXX.XXX.XX.XXX:XXXXX/SSEGMENT/6545456465456456465454564/191/2191/seg_191_XXXXX.ts
Audio and subtitles are embeded in TS file. Since audio/subtitle tracks are not explicitly described in #EXT tag in the above *.m3u8 file, 'mediaSelectionGroupForMediaCharacteristic' returns empty options collection.
In opposite, m3u8 file:
https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8
provided by Apple as an HLS playlist example, has audio/subtitle tracks described in #EXT tags:
#EXTM3U
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="bipbop_audio",LANGUAGE="eng",NAME="BipBop Audio 1",AUTOSELECT=YES,DEFAULT=YES
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="bipbop_audio",LANGUAGE="eng",NAME="BipBop Audio 2",AUTOSELECT=NO,DEFAULT=NO,URI="alternate_audio_aac_sinewave/prog_index.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,LANGUAGE="en",CHARACTERISTICS="public.accessibility.transcribes-spoken-dialog, public.accessibility.describes-music-and-sound",URI="subtitles/eng/prog_index.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English (Forced)",DEFAULT=NO,AUTOSELECT=NO,FORCED=YES,LANGUAGE="en",URI="subtitles/eng_forced/prog_index.m3u8"
This time 'mediaSelectionGroupForMediaCharacteristic' returns a collection which includes two audio options, which I can select successfully.
THE QUESTION: Is there a way for AVPlayer to select audio/subtitle track, if they are not described in #EXT tag inside *.m3u8 file, but embedded within *.ts files? Thanks ahead, any suggestions are appreciated!
Related
I would like to load a playlist file that contains YouTube URLs in MPV. Like this:
playlists.txt
https://www.youtube.com/watch?v=86cQJ0MMses
https://www.youtube.com/watch?v=s22eJ1eVLTU
And one or multiple chapters file:
chapters.txt
;FFMETADATA1
[CHAPTER]
TIMEBASE=1/60
START=0
END=300
title=Introduction
[CHAPTER]
TIMEBASE=1/60
START=300
END=6000
title=Rest of the video
Playing the playlist like this
mpv --playlist=playlist.txt --chapters-file=chapters.txt
The same chapters are shown for both videos. Is it possible to have different chapters for each video in the playlist?
I just want to get a audio file(opus codec used) only in webm file.
I try to search what is webm format, how to parse, but I cant get info well.
I check that webm format is from mkv, then should I check the mkv first?
there is just one github code, but I cant find way how parse the audio from webm.
https://github.com/webmproject/libwebm/tree/master/webm_parser
You're really going to want the MKVToolNix. These include the tool mkvextract in another answer.
The MKVToolNix is actually a series of tools (mkvmerge, mkvinfo, mkvextract, mkvpropedit). First you asked how to parse the info. You can find the details using:
mkvinfo file.webm
mkvinfo file.webm -a
The first command will parse the overall structure. The second gives the detail of each frame. Use the --help switch if you want all commands.
To extract the audio, do
mkvextract file.webm tracks X:newfile.opus
Where X is the track number that you've identified as wanted from mkvinfo previously. Webm and MKV can have multiple tracks. "newfile.opus" is the new file that you want to create, choose the name you want.
There is also a mkvtoolnix gui, but I've never used that.
mkvextract can extract audio for you, and I recommend having a look at the mkvtoolsnix source code.
For example, you can extract audio from a WebM file into an Ogg Opus file like this:
$ mkvextract ~/audio/bubbles.webm tracks 0:audio.opus
Extracting track 0 with the CodecID 'A_OPUS' to the file 'audio.opus'. Container format: Ogg (Opus in Ogg)
Progress: 100%
I want to play subtitles from url.
I tried creating an .m3u playlist, but the subtitle doesn't load:
http://localhost:1111/1.srt
http://localhost:1111/1.mkv
Can VLC load a subtitle (url) from inside the playlist?
If not, I'm thinking of creating a .lua plugin for VLC to search the playlist for "http" access & ".srt" string.
If found I want to Download & use it.
I never created a VLC Plugin... Any help would be awesome...
I did a work around index.php(list files in dir) + javascript(to download files):
download subtitle CoolVideo.srt (if subtitle exists)
generate & download stream.m3u (+ subtitle if exists)
stream.m3u + Subtitle content:
#EXTM3U
#EXTINF:-1,STREAM: Cool Video Name
#EXTVLCOPT:sub-file=CoolVideo.srt
#EXTVLCOPT:subsdec-encoding=System Default
#EXTVLCOPT:subsdec-align=0
#EXTVLCOPT:freetype-rel-fontsize=16
#EXTVLCOPT:sub-fps=0
#EXTVLCOPT:sub-delay=0
http://localhost:1111/CoolVideo.mkv
stream.m3u (No Subtitle) content:
#EXTM3U
#EXTINF:-1,STREAM: Cool Video Name
http://localhost:1111/CoolVideo.mkv
INFO stream.m3u:
It's best to use encodeURI("http://localhost:1111/CoolVideo.mkv"); for the video path just in case it contains empty spaces or other characters, otherwise VLC will not open the stream.
Because stream.m3u is in the same folder as CoolVideo.srt, VLC will load the subtitle
Open the stream.m3u on PC, & enjoy almost any video format :)
BUGS: The subtitle does not auto load on Android
I made a service which record a movie on iOS and publish it to the server. The server divides the stream to the multiple ts files. And by using these files, I make a m3u8 file and publish this file to the client.
However, mediastreamvalidator says that some ts files are invalid though I can play these ts files on Quick Time after I download these files.
Following is the output of the mediastreamvalidator
Error: Playlist vs segment duration mismatch
--> Detail: Segment duration 0.0000, Playlist duration: 12.0900
--> Source: https://***.com/media/*** - https://storage.googleapis.com/***27.ts
--> Detail: Segment duration 0.0000, Playlist duration: 12.0900
--> Source: https://***.com/media/*** - https://storage.googleapis.com/***29.ts
I googled the error that "Error: Playlist vs segment duration mismatch" but there seems to be no answers.
Could you tell me the way to solve this error?
Thanks.
Your segments may have discontinuities between them. If so you will need to enter the tag #EXT-X-DISCONTINUITY between them. The HLS spec specifies that you need to mark discontinuities in the following scenarios:
file format
number, type, and identifiers of tracks
timestamp sequence
See Section 4.3.2.3: https://www.rfc-editor.org/rfc/rfc8216
Here I have a manifest: index.m3u8 and 12 segments. My problem is that VLC player only play the last 5 segments in the manifest. This is my manifest:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-TARGETDURATION:18
#EXTINF:12.960,
sample-0.ts
#EXTINF:10.640,
sample-1.ts
#EXTINF:18.440,
sample-2.ts
#EXTINF:10.000,
sample-3.ts
#EXTINF:12.920,
sample-4.ts
#EXTINF:10.800,
sample-5.ts
#EXTINF:13.400,
sample-6.ts
#EXTINF:12.240,
sample-7.ts
#EXTINF:11.720,
sample-8.ts
#EXTINF:15.320,
sample-9.ts
#EXTINF:13.200,
sample-10.ts
#EXTINF:10.480,
sample-11.ts
#EXTINF:11.800,
sample-12.ts
With this manifest, VLC plays from sample-8.ts. I tried to pull out some segment, leave sample-0.ts -> sample-7.ts, then VLC plays from sample-3.ts. What wrong with my manifest? Your help is very much appreciated.
You need to add the #EXT-X-ENDLIST tag to the end of the playlist, assuming you want it to start from the beginning. Without the end tag the player assumes it's a live playlist, which explains the behaviour you are seeing. You should also set the playlist type, e.g. #EXT-X-PLAYLIST-TYPE:VOD.