Can subtitles also be returned as part of the playlist?

Discuss your Lua playlist, album art and interface scripts.
midas02
Blank Cone
Blank Cone
Posts: 18
Joined: 27 Oct 2011 21:47
Location: Paris, France

Can subtitles also be returned as part of the playlist?

Postby midas02 » 22 Mar 2017 22:40

Hello,

I'm in the process of writing an LUA script for parsing an external data source, feeding it back to VLC with the parse() function. Now the documentation on that function states that it has to return playlist item(s), those items being, amongst others,

Code: Select all

.path: the item's full path / URL .name: the item's name in playlist (OPTIONAL) .title: the item's Title (OPTIONAL, meta data) .artist: the item's Artist (OPTIONAL, meta data) ...
Now, what's not mentioned in there, is an option to return subtitles. But my data source provides them. So is there such an option?

Thanks

Ps: sorry, it's not related to the main question, but if one could help out, that would be great. My data source is a JSON file providing the following formats:

Code: Select all

"PROGRESSIVE_DOWNLOAD","url":"https://...mp4"} "HLS","url":"https://.../playlist.m3u8"}, "HDS","url":"http://.../video.smil/manifest.f4m"}, "RTMP","url":"rtmp://....mp4"}, "RTSP","url":"rtsp://....mp4"}
I believe the f4m manifest cannot be read by VLC, but other than that one, is there any format which should be given preference over the others? Is there a particular format VLC is more comfortable with? ... I'm currently parsing them in the order mentioned above.

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Can subtitles also be returned as part of the playlist?

Postby mederi » 25 Mar 2017 16:08

Try options:

Code: Select all

.options: a list of VLC options (OPTIONAL) example: .options = { "run-time=60" } --sub-file=<string> Use subtitle file Load this subtitle file. To be used when autodetect cannot detect your subtitle file. --sub-track=<integer> Subtitle track Stream number of the subtitle track to use (from 0 to n). --input-slave=<string> Input slave (experimental) This allows you to play from several inputs at the same time. This feature is experimental, not all formats are supported. Use a “#” separated list of input.

midas02
Blank Cone
Blank Cone
Posts: 18
Joined: 27 Oct 2011 21:47
Location: Paris, France

Re: Can subtitles also be returned as part of the playlist?

Postby midas02 » 25 Mar 2017 20:08

Ok, brilliant. Took me a bit to figure out what you meant, but got it now.

First tried it with the sub-file option, but that didn't work as it is apparently expecting a local file as an argument, and not a URL. (he kept trying to open c:\....\VLC\http://....)

Using 'options = { input-slave=http://... }' did work however!

One more remaining issue, the source is webvtt, but VLC seems to have trouble recognising the 'codec'.
I do obtain a stream with video on stream 0, audio on stream 1, and 'Subtitle' on stream 2. So he does recognise the link as a subtitle. However, it also mentions 'Subtitle - codec : undf'. When I try to activate the subtitles within the VLC window, I get an error saying 'Unidentified codec: VLC could not identify the audio or video codec'.
Strangely enough, when I first save that vtt file to the hard drive, and then add it to the stream as it is running, he doesn't have a problem with it at all.

Any ideas on what might be causing this?

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Can subtitles also be returned as part of the playlist?

Postby mederi » 26 Mar 2017 15:28

Check vlc-help.txt dump file (vlc -H) for more useful options. You could also try it with VLC 3.

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Can subtitles also be returned as part of the playlist?

Postby mederi » 26 Mar 2017 20:04

/demux?

Code: Select all

Stream MRL syntax: [[access][/demux]://]URL[#[title][:chapter][-[title][:chapter]]] [:option=value ...] Many of the global --options can also be used as MRL specific :options. Multiple :option=value pairs can be specified.
sub-type=vtt?

mederi
Big Cone-huna
Big Cone-huna
Posts: 1951
Joined: 15 Mar 2011 16:38
VLC version: 2.0.8
Operating System: Windows Vista/XP

Re: Can subtitles also be returned as part of the playlist?

Postby mederi » 30 Mar 2017 16:04

I have found some MP4+VTT sample on Internet. Following options work for me:

Code: Select all

vlc.exe https://thepaciellogroup.github.io/AT-browser-tests/video/ElephantsDream.mp4 :input-slave=https/subtitle://thepaciellogroup.github.io/AT-browser-tests/video/subtitles-en.vtt :sub-track=0

midas02
Blank Cone
Blank Cone
Posts: 18
Joined: 27 Oct 2011 21:47
Location: Paris, France

Re: Can subtitles also be returned as part of the playlist?

Postby midas02 » 30 Mar 2017 20:11

Hello mederi,

Sorry for not answering earlier, but I have been busy all week. But your suggestion nailed it! The syntax :input-slave=[access]/subtitle://[subtitlepath] is indeed the working one !!
Great, thanks for all your help.

For those interested in how to do this, my code is as follows:

Code: Select all

-- Extracting subtitles if string.match( line, "\"CLOSED\",") then -- subtitles are presented in a JSON file under a key called "CLOSED" subtitles = string.match( line, "CLOSED\",\"url\":\"(.-)\"" ) -- extract subtitles URL -- prepare substring for returning as a parameter subtitlesaccess = string.match( subtitles, "(.-)://" ) subtitlespath = string.gsub( subtitles, "(%a+)://", "" ) subtitles = "input-slave\="..subtitlesaccess.."/subtitle://"..subtitlespath end ... return { { path = path; name = name; description = description; arturl = arturl; duration = duration; options = { subtitles } } }


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 0 guests