tvOS TVVLCKit problem with NSURL

iOS, iPad, iPhone, tvOS specific usage questions
Airrud
New Cone
New Cone
Posts: 6
Joined: 14 Nov 2015 17:50

tvOS TVVLCKit problem with NSURL

Postby Airrud » 14 Nov 2015 18:05

Hi all,
I am developing a Apple TV 4 app for streaming from Enigma 2 receivers. Life TV streaming to Apple TV works fine. But I run in problems with recorded movies on the receiver. Here my code:

Code: Select all

VLCMediaPlayer *mediaplayer; mediaplayer = [[VLCMediaPlayer alloc] init]; mediaplayer.delegate = self; mediaplayer.drawable = movieView; NSString *path = @"http://bm750.local/hdd/movie/20151023 2030 - ZDF HD - Der Alte.ts"; NSString *encodedPath = [path stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet]; NSURL *url = [NSURL URLWithString:encodedPath]; mediaplayer.media = [VLCMedia mediaWithURL:url]; [mediaplayer play]; NSLog(@"URL: %@", url); // Output: URL: http://bm750.local/hdd/movie/20151023%202030%20-%20ZDF%20HD%20-%20Der%20Alte.ts
The stream does not start and I got VLCMediaPlayerStateError.

It seems the encoding/encapsulation is the problem. If I try to access a movie w/o spaces in the path it works fine.
It works also fine when I open the encoded URL in VLC on OS X.

I tried different character sets w/o success:
- URLFragmentAllowedCharacterSet
- URLHostAllowedCharacterSet
- URLPasswordAllowedCharacterSet
- URLPathAllowedCharacterSet
- URLQueryAllowedCharacterSet
- URLUserAllowedCharacterSet

Thanks, Matthias

matrog
Blank Cone
Blank Cone
Posts: 42
Joined: 27 Sep 2015 08:55

Re: tvOS TVVLCKit problem with NSURL

Postby matrog » 14 Nov 2015 19:14

I should not help you since you are developing my same app... :D but.....

try this

Code: Select all

URLHostAllowedCharacterSet
instead of

Code: Select all

URLQueryAllowedCharacterSet

matrog
Blank Cone
Blank Cone
Posts: 42
Joined: 27 Sep 2015 08:55

Re: tvOS TVVLCKit problem with NSURL

Postby matrog » 14 Nov 2015 19:24

try also something like that

Code: Select all

http://bm750.local/web/ts.m3u?file=/hdd/movie/20151023%202030%20-%20ZDF%20HD%20-%20Der%20Alte.ts

Airrud
New Cone
New Cone
Posts: 6
Joined: 14 Nov 2015 17:50

Re: tvOS TVVLCKit problem with NSURL

Postby Airrud » 14 Nov 2015 19:37

Thanks for your help - but it does not work.
Tried:

Code: Select all

NSURL *url = [NSURL URLWithString: @"http://bm750.local/web/ts.m3u?file=/hdd/movie/20151023%202030%20-%20ZDF%20HD%20-%20Der%20Alte.ts"]; mediaplayer.media = [VLCMedia mediaWithURL:url];
No success.

For testing I have created two files on the receiver:
- Film.ts
- Fi lm.ts

Does not work:

Code: Select all

NSString *escapedAdresse = [@"Fi lm.ts" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://bm750.local/hdd/movie/%@", escapedAdresse]]; mediaplayer.media = [VLCMedia mediaWithURL:url];
Works fine:

Code: Select all

NSString *escapedAdresse = [@"Film.ts" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://bm750.local/hdd/movie/%@", escapedAdresse]]; mediaplayer.media = [VLCMedia mediaWithURL:url];

matrog
Blank Cone
Blank Cone
Posts: 42
Joined: 27 Sep 2015 08:55

Re: tvOS TVVLCKit problem with NSURL

Postby matrog » 15 Nov 2015 09:25

enable debugging to see what's wrong

Code: Select all

mediaplayer.libraryInstance.debugLogging = YES;

Airrud
New Cone
New Cone
Posts: 6
Joined: 14 Nov 2015 17:50

Re: tvOS TVVLCKit problem with NSURL

Postby Airrud » 15 Nov 2015 12:33

I have enabled the debug mode.

Here the output if I try to open "Fi lm.ts":

Code: Select all

2015-11-15 12:23:47.900 VU Plus[4886:2409431] Creating an input for 'Fi lm.ts' 2015-11-15 12:23:47.900 VU Plus[4886:2410142] using timeshift granularity of 50 MiB 2015-11-15 12:23:47.900 VU Plus[4886:2410142] using default timeshift path 2015-11-15 12:23:47.901 VU Plus[4886:2410142] `http://10.0.1.23/hdd/movie/Fi lm.ts' gives access `http' demux `' path `10.0.1.23/hdd/movie/Fi lm.ts' 2015-11-15 12:23:47.901 VU Plus[4886:2410142] specified demux: any 2015-11-15 12:23:47.901 VU Plus[4886:2410142] creating demux: access='http' demux='any' location='10.0.1.23/hdd/movie/Fi lm.ts' file='(null)' 2015-11-15 12:23:47.901 VU Plus[4886:2410142] looking for access_demux module matching "http": 3 candidates 2015-11-15 12:23:47.901 VU Plus[4886:2410142] no access_demux modules matched 2015-11-15 12:23:47.901 VU Plus[4886:2410142] creating access: http://10.0.1.23/hdd/movie/Fi lm.ts 2015-11-15 12:23:47.901 VU Plus[4886:2410142] looking for access module matching "http": 17 candidates 2015-11-15 12:23:47.902 VU Plus[4886:2410142] querying proxy for http://10.0.1.23/hdd/movie/Fi lm.ts 2015-11-15 12:23:47.903 VU Plus[4886:2410142] no proxy 2015-11-15 12:23:47.903 VU Plus[4886:2410142] http: server='10.0.1.23' port=80 file='/hdd/movie/Fi lm.ts' 2015-11-15 12:23:47.903 VU Plus[4886:2410142] net: connecting to 10.0.1.23 port 80 2015-11-15 12:23:47.906 VU Plus[4886:2410142] connection succeeded (socket = 12) 2015-11-15 12:23:47.919 VU Plus[4886:2410142] protocol 'HTTP' answer code 400 2015-11-15 12:23:47.919 VU Plus[4886:2410142] error: HTTP/1.1 400 Bad Request 2015-11-15 12:23:47.919 VU Plus[4886:2410142] switching to HTTP version 1.0 2015-11-15 12:23:47.919 VU Plus[4886:2410142] net: connecting to 10.0.1.23 port 80 2015-11-15 12:23:47.922 VU Plus[4886:2410142] connection succeeded (socket = 12) 2015-11-15 12:23:47.933 VU Plus[4886:2410142] protocol 'HTTP' answer code 400 2015-11-15 12:23:47.934 VU Plus[4886:2410142] error: HTTP/1.1 400 Bad Request 2015-11-15 12:23:47.934 VU Plus[4886:2410142] net: connecting to 10.0.1.23 port 80 2015-11-15 12:23:47.936 VU Plus[4886:2410142] connection succeeded (socket = 12) 2015-11-15 12:23:47.949 VU Plus[4886:2410142] error: HTTP/1.1 400 Bad Request 2015-11-15 12:23:47.950 VU Plus[4886:2410142] no access modules matched 2015-11-15 12:23:47.950 VU Plus[4886:2410142] cannot access http://10.0.1.23/hdd/movie/Fi lm.ts 2015-11-15 12:23:47.950 VU Plus[4886:2410142] Your input can't be opened 2015-11-15 12:23:47.950 VU Plus[4886:2410142] VLC is unable to open the MRL 'http://10.0.1.23/hdd/movie/Fi lm.ts'. Check the log for details.
And here the output for video file w/o spaces ("Film.ts"):

Code: Select all

2015-11-15 12:25:27.905 VU Plus[4933:2425443] Creating an input for 'Film.ts' 2015-11-15 12:25:27.905 VU Plus[4933:2426073] using timeshift granularity of 50 MiB 2015-11-15 12:25:27.905 VU Plus[4933:2426073] using default timeshift path 2015-11-15 12:25:27.905 VU Plus[4933:2426073] `http://10.0.1.23/hdd/movie/Film.ts' gives access `http' demux `' path `10.0.1.23/hdd/movie/Film.ts' 2015-11-15 12:25:27.905 VU Plus[4933:2426073] specified demux: any 2015-11-15 12:25:27.906 VU Plus[4933:2426073] creating demux: access='http' demux='any' location='10.0.1.23/hdd/movie/Film.ts' file='(null)' 2015-11-15 12:25:27.906 VU Plus[4933:2426073] looking for access_demux module matching "http": 3 candidates 2015-11-15 12:25:27.906 VU Plus[4933:2426073] no access_demux modules matched 2015-11-15 12:25:27.906 VU Plus[4933:2426073] creating access: http://10.0.1.23/hdd/movie/Film.ts 2015-11-15 12:25:27.906 VU Plus[4933:2426073] looking for access module matching "http": 17 candidates 2015-11-15 12:25:27.906 VU Plus[4933:2426073] querying proxy for http://10.0.1.23/hdd/movie/Film.ts 2015-11-15 12:25:27.907 VU Plus[4933:2426073] no proxy 2015-11-15 12:25:27.907 VU Plus[4933:2426073] http: server='10.0.1.23' port=80 file='/hdd/movie/Film.ts' 2015-11-15 12:25:27.907 VU Plus[4933:2426073] net: connecting to 10.0.1.23 port 80 2015-11-15 12:25:27.911 VU Plus[4933:2426073] connection succeeded (socket = 12) 2015-11-15 12:25:27.944 VU Plus[4933:2426073] protocol 'HTTP' answer code 206 2015-11-15 12:25:27.944 VU Plus[4933:2426073] this frame size=8148078672 2015-11-15 12:25:27.944 VU Plus[4933:2426073] stream size=8148078672,pos=0,remaining=8148078672 2015-11-15 12:25:27.944 VU Plus[4933:2426073] Server: TwistedWeb/12.0.0
The differences:
Not working: protocol 'HTTP' answer code 400 - error: HTTP/1.1 400 Bad Request
Working: protocol 'HTTP' answer code 206

It seems, VLC removes the escaped encoding.....

matrog
Blank Cone
Blank Cone
Posts: 42
Joined: 27 Sep 2015 08:55

Re: tvOS TVVLCKit problem with NSURL

Postby matrog » 15 Nov 2015 15:27

not sure...could be only the display on logs.

You should check receiver's log as well to see the actual url request received by the decoder

Airrud
New Cone
New Cone
Posts: 6
Joined: 14 Nov 2015 17:50

Re: tvOS TVVLCKit problem with NSURL

Postby Airrud » 17 Nov 2015 14:42

Hi,
the receiver does not log any problems in /var/log/messages. But I have copied the TS file to my Mac and enabled a HTTP server:

$ python -m SimpleHTTPServer 9001

Streaming with "Film.ts" in Apple TV Simulator works fine. But if I try to access to "Fi lm.ts" the HTTP server logs:

127.0.0.1 - - [17/Nov/2015 14:37:02] code 400, message Bad request syntax ('GET /Fi lm.ts HTTP/1.1')
127.0.0.1 - - [17/Nov/2015 14:37:02] "GET /Fi lm.ts HTTP/1.1" 400 -
127.0.0.1 - - [17/Nov/2015 14:37:02] code 400, message Bad request syntax ('GET /Fi lm.ts HTTP/1.0')
127.0.0.1 - - [17/Nov/2015 14:37:02] "GET /Fi lm.ts HTTP/1.0" 400 -
127.0.0.1 - - [17/Nov/2015 14:37:02] code 400, message Bad request syntax ('GET /Fi lm.ts HTTP/1.0')
127.0.0.1 - - [17/Nov/2015 14:37:02] "GET /Fi lm.ts HTTP/1.0" 400 -

As you can see, the VLCKit ignores/deletes the escapes in NSURL.

Airrud
New Cone
New Cone
Posts: 6
Joined: 14 Nov 2015 17:50

Re: tvOS TVVLCKit problem with NSURL

Postby Airrud » 17 Nov 2015 15:09

I believe I have solved the problem.

In "MobileVLCKit - Sources - VLCMedia" I found:

Code: Select all

- (instancetype)initWithURL:(NSURL *)anURL { if (self = [super init]) { VLCLibrary *library = [VLCLibrary sharedLibrary]; NSAssert(library.instance, @"no library instance when creating media"); p_md = libvlc_media_new_location(library.instance, [[[anURL absoluteString] stringByRemovingPercentEncoding] UTF8String]); _metaDictionary = [[NSMutableDictionary alloc] initWithCapacity:3]; [self initInternalMediaDescriptor]; } return self; }
I changed it to:

Code: Select all

- (instancetype)initWithURL:(NSURL *)anURL { if (self = [super init]) { VLCLibrary *library = [VLCLibrary sharedLibrary]; NSAssert(library.instance, @"no library instance when creating media"); p_md = libvlc_media_new_location(library.instance, [[anURL absoluteString] UTF8String]); _metaDictionary = [[NSMutableDictionary alloc] initWithCapacity:3]; [self initInternalMediaDescriptor]; } return self; }
No it works fine.....

Vibou
Blank Cone
Blank Cone
Posts: 10
Joined: 09 Nov 2015 10:58

Re: tvOS TVVLCKit problem with NSURL

Postby Vibou » 18 Nov 2015 16:10

Thank you very much it works !!

Vibou
Blank Cone
Blank Cone
Posts: 10
Joined: 09 Nov 2015 10:58

Re: tvOS TVVLCKit problem with NSURL

Postby Vibou » 18 Nov 2015 17:59

I thinks you fixed one issue but there are others...

It is not working anymore. It worked only once ! Very weird !

My player is not playing it s like it is blocked on a thread (I m not using a multi-threaded environment no dispatch_async or whatever). :(

OlivierAubert
Developer
Developer
Posts: 92
Joined: 08 Mar 2007 15:43

Re: tvOS TVVLCKit problem with NSURL

Postby OlivierAubert » 24 Nov 2015 10:20

The python SimpleHTTPServer is not up to the task of serving videos, it does not even support range requests. For this kind of task (video server launched from the command line for quick tests), I tend to use alternatives such as

Code: Select all

gatling
from fefe.de

ssbmaccom
Cone that earned his stripes
Cone that earned his stripes
Posts: 184
Joined: 26 Nov 2015 15:21
Operating System: Mac OS, iOS, tvOS

Re: tvOS TVVLCKit problem with NSURL

Postby ssbmaccom » 26 Nov 2015 17:18

While I tried to build the TVVLCKit on my Mac I saw, that this issue might have been fixed in the meantime by Felix.


Return to “VLC for iOS, iPadOS and Apple TV”

Who is online

Users browsing this forum: No registered users and 11 guests