Jump to content

Running Emby on Apple TV 3


sw1tchm4st3r

Recommended Posts

Thanks Tikuf,

works

 

 

ATV>

GET /mediabrowser/Videos/9aa15e8dcc7b90989a977dfa068d9f6d/stream.m3u8?audioCodec=Aac&VideoCodec=h264&VideoBitRate=3000000&AudioBitRate=128000&audiochannels=2&maxwidth=1280 HTTP/1.1

Host: 192.168.1.125:8096

Range: bytes=0-1

X-Playback-Session-Id: 431C3EC0-072A-4081-B291-71742313E603

Accept-Encoding: identity

Accept: */*

Accept-Language: en-us

Connection: keep-alive

User-Agent: AppleCoreMedia/1.0.0.11B554a (Apple TV; U; CPU OS 7_0_4 like Mac OS X; en_us)
Edited by BC101
Link to comment
Share on other sites

The original video ID I used ended up starting near the end, and never actually got to the end it instead prematurely ended.

So to troubleshoot, I just changed video ID to another video and the weird thing is it doesn't start at 0:00 it starts in the middle of the intro, so 30seconds in? See the video I just created: http://www.youtube.com/watch?v=1GEipDdfBgc

Link to comment
Share on other sites

If my mkv's are Ac3 5.1 channel, what options are best to ensure they come out as 5.1 channel on the ATV, do you know?

I tried changing from Aac to ac3 but it broke, I tried changing from 2 to 6 under audiochannels but that didnt work.

Link to comment
Share on other sites

Ya 5.1 of transcode is not implemented yet.

 

As a stop gap you can play with

http://server-ip:8096/mediabrowser/Videos/502e652c886521c5d2bda00dffd6371c/stream.m3u8?audioCodec=copy&VideoCodec=h264&VideoBitRate=3000000&maxwidth=1280

to keep orig audio (not sure how it will segment with ac3 but it should be ok)

http://server-ip:8096/mediabrowser/Videos/502e652c886521c5d2bda00dffd6371c/stream?static=true

to stream the orig file

Link to comment
Share on other sites

I see the Apple TV is capable of outputting 5.1 Dolby Digital as I can confirm from the NetFlix app (I can query from my receiver to see what the ATV is pushing).

With your suggestion:

 

http://192.168.1.125:8096/mediabrowser/Videos/9e34e0f28bcda58406baee1e761b5636/stream.m3u8?audioCodec=copy&VideoCodec=h264&VideoBitRate=3000000&maxwidth=1280

 

\\edit: oops i was trying a DTS source , I've switched to a AC3 source movie and can confirm 5.1 is working fine with the syntax ?audioCodec=copy -- Thanks

 

Obviously stream?static=true fails because the source is mkv.

Edited by BC101
Link to comment
Share on other sites

So what options needs to be used to reencode DTS to AC3 5.1 channels?

Right now nothing we will add it but our attention is elsewhere right now. I will chat to Luke about adding ac3 5.1 and aac 5.1 (ac3 can be utilized by roku as well)

Link to comment
Share on other sites

we will add it, not to worry. i love what you've done so far, but i personally would suggest focusing on browsing the library first. once this becomes a real project, we'll be glad to allocate more developer time to help you. there's a lot of people out there who know python, so a little recruiting on github could probably get you some help.

Link to comment
Share on other sites

Yup, getting support is a goal, I can hack an interface together but all data elements get pulled from Plex at the moment. However I hardcoded the stream to pull from MB3 so I know it works (given my source is AC3 5.1 I can even get the thing to play with surround sound), fast-forward works, etc.

  • Like 1
Link to comment
Share on other sites

Obviously stream?static=true fails because the source is mkv.

 

if you need to re-contain the original source I would suggest using ts as the container (if all the internal codecs are supported)

 

you can call it with

http://server-ip:8096/mediabrowser/Videos/502e652c886521c5d2bda00dffd6371c/stream.ts?audioCodec=copy&VideoCodec=copy
Link to comment
Share on other sites

Hls is not a requirement unless he is connecting via cell network. But yes he could use either hls or ts 

 

 

http://server-ip:8096/mediabrowser/Videos/502e652c886521c5d2bda00dffd6371c/stream.m3u8?audioCodec=copy&VideoCodec=copy

 

 

or

 

http://server-ip:8096/mediabrowser/Videos/502e652c886521c5d2bda00dffd6371c/stream.ts?audioCodec=copy&VideoCodec=copy

 

 

 

ts will (atm) have a faster start up time (very small diff when re containing). So yes it would probably be best to use hls but as it is a re-contain the segment times will likely not be in compliance with apple spec anyhow.

Link to comment
Share on other sites

The .ts failed stream.ts?audioCodec=copy&VideoCodec=copy

 

ATV>

GET /mediabrowser/Videos/363f2e2c17dbc86ee4b83220f638c0c5/stream.ts?audioCodec=copy&VideoCodec=copy HTTP/1.1
Host: 192.168.1.125:8096
Range: bytes=0-1
X-Playback-Session-Id: 58D5EF2D-2579-43D5-914A-A4DBAFE924E1
Accept-Encoding: identity
Accept: */*
Accept-Language: en-us
Connection: keep-alive
User-Agent: AppleCoreMedia/1.0.0.11B554a (Apple TV; U; CPU OS 7_0_4 like Mac OS X; en_us)
 
MB3>
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: video/mp2t
Accept-Ranges: none
Server: Microsoft-HTTPAPI/2.0
X-UA-Compatible: IE=Edge
X-Powered-By: ServiceStack/4.001 Win32NT/.NET
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type
Date: Sat, 28 Dec 2013 22:26:14 GMT
 
The ATV failed to handle that video type I guess. Trying .m3u8 now
Edited by BC101
Link to comment
Share on other sites

Weird, webserver didnt respond to this request from ATV:

 

ATV>

GET /mediabrowser/Videos/363f2e2c17dbc86ee4b83220f638c0c5/stream.m3u8?audioCodec=copy&VideoCodec=copy HTTP/1.1
Host: 192.168.1.125:8096
X-Playback-Session-Id: B6CFAE0D-8D2B-4F3F-BE4E-780D19ECCF4A
Accept-Encoding: gzip
Accept: */*
Accept-Language: en-us
Connection: keep-alive
User-Agent: AppleCoreMedia/1.0.0.11B554a (Apple TV; U; CPU OS 7_0_4 like Mac OS X; en_us)
Link to comment
Share on other sites

Ooops, could it be because the movie is AVI?  Don't know how i missed that, thought it was mkv. I found one movie that's mkv with AC3 audio and will test that now.

 

webserver logs:

 

2013-12-28 14:33:27.9557, Debug, HttpServer, HTTP GET request received on worker 0 from 192.168.1.34:49347


Headers: X-Playback-Session-Id=198E2892-DCE7-415B-BCC6-536FA6F4C424,Connection=keep-alive,Accept=*/*,Accept-Encoding=gzip,Accept-Language=en-us,Host=192.168.1.125:8096,User-Agent=AppleCoreMedia/1.0.0.11B554a (Apple TV; U; CPU OS 7_0_4 like Mac OS X; en_us)

 

2013-12-28 14:33:27.9607, Info, App, C:\Users\xxxxx\AppData\Roaming\MediaBrowser-Server\ffmpeg\ffmpeg20131209\ffmpeg.exe -i file:"Q:\VIDs\Movies\SOMEMOVIE\SOMEMOVIE CD1 of 2.avi" -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 copy -sc_threshold 0 -codec:a:0 copy -hls_time 10 -start_number 0 -hls_list_size 1440 "C:\Users\xxxxxxx\AppData\Roaming\MediaBrowser-Server\cache\encoded-media\b2a62178-7349-8025-f127-3768ccbf02b8.m3u8"

 

2013-12-28 14:33:28.0847, Info, App, FFMpeg exited with code 1 for C:\Users\xxxxxx\AppData\Roaming\MediaBrowser-Server\cache\encoded-media\b2a62178-7349-8025-f127-3768ccbf02b8.m3u8

 

2013-12-28 14:34:48.0222, Debug, HttpServer, HTTP GET request received on worker 1 from 127.0.0.1:28709


Edited by BC101
Link to comment
Share on other sites

 

Webserver logs:
 
2013-12-28 14:44:32.6787, Debug, HttpServer, HTTP GET request received on worker 0 from 192.168.1.34:49384
Headers: X-Playback-Session-Id=9A55F254-0673-49FB-9489-46EB1019EB3A,Connection=keep-alive,Accept=*/*,Accept-Encoding=identity,Accept-Language=en-us,Host=192.168.1.125:8096,Range=bytes=0-1,User-Agent=AppleCoreMedia/1.0.0.11B554a (Apple TV; U; CPU OS 7_0_4 like Mac OS X; en_us)
2013-12-28 14:44:32.6837, Info, App, C:\Users\xxxxxxxx\AppData\Roaming\MediaBrowser-Server\ffmpeg\ffmpeg20131209\ffmpeg.exe -i file:"Q:\VIDs\Movies\Old School (2003) [1080p.BluRay.x264-HANGOVER]\Old School (2003) [1080p.BluRay.x264-HANGOVER].mkv" -map 0:0 -map 0:1 -map -0:s -vcodec copy -bsf h264_mp4toannexb -threads 0 -acodec copy "C:\Users\xxxxxxxx\AppData\Roaming\MediaBrowser-Server\cache\encoded-media\20b15a52-b506-63d7-fff8-68dcf638e5ea.ts"
2013-12-28 14:44:34.8198, Error, App, Error streaming media
The specified network name is no longer available
System.Net.HttpListenerException
  at System.Net.HttpResponseStream.EndWrite(IAsyncResult asyncResult)
  at System.IO.Stream.<BeginEndWriteAsync>b__17(Stream stream, IAsyncResult asyncResult)
  at System.Threading.Tasks.TaskFactory`1.FromAsyncTrimPromise`1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at System.IO.Stream.<CopyToAsyncInternal>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at MediaBrowser.Api.Playback.Progressive.ProgressiveStreamWriter.<StreamFile>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at MediaBrowser.Api.Playback.Progressive.ProgressiveStreamWriter.<WriteToAsync>d__0.MoveNext()
 
2013-12-28 14:44:34.8198, Error, HttpResponseExtensionsInternal, Error occured while Processing Request: [AggregateException] One or more errors occurred.
One or more errors occurred.
System.AggregateException
  at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
  at MediaBrowser.Api.Playback.Progressive.ProgressiveStreamWriter.WriteTo(Stream responseStream)
  at ServiceStack.HttpResponseExtensionsInternal.WriteToOutputStream(IResponse response, Object result, Byte[] bodyPrefix, Byte[] bodySuffix)
  at ServiceStack.HttpResponseExtensionsInternal.WriteToResponse(IResponse response, Object result, ResponseSerializerDelegate defaultAction, IRequest request, Byte[] bodyPrefix, Byte[] bodySuffix)
InnerException: System.Net.HttpListenerException
The specified network name is no longer available
  at System.Net.HttpResponseStream.EndWrite(IAsyncResult asyncResult)
  at System.IO.Stream.<BeginEndWriteAsync>b__17(Stream stream, IAsyncResult asyncResult)
  at System.Threading.Tasks.TaskFactory`1.FromAsyncTrimPromise`1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at System.IO.Stream.<CopyToAsyncInternal>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at MediaBrowser.Api.Playback.Progressive.ProgressiveStreamWriter.<StreamFile>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at MediaBrowser.Api.Playback.Progressive.ProgressiveStreamWriter.<WriteToAsync>d__0.MoveNext()
 
2013-12-28 14:44:34.8198, Debug, HttpServer, Response code 500 sent to 192.168.1.34:49384. Response time: 2148.1228 ms
Headers: X-UA-Compatible=IE=Edge,X-Powered-By=ServiceStack/4.001 Win32NT/.NET,Access-Control-Allow-Origin=*,Access-Control-Allow-Methods=GET, POST, PUT, DELETE, OPTIONS,Access-Control-Allow-Headers=Content-Type,Accept-Ranges=none,Content-Type=video/mp2t,Transfer-Encoding=chunked
2013-12-28 14:44:35.8319, Info, App, Killing ffmpeg process for C:\Users\xxxxxxxx\AppData\Roaming\MediaBrowser-Server\cache\encoded-media\20b15a52-b506-63d7-fff8-68dcf638e5ea.ts
2013-12-28 14:44:35.8319, Info, App, FFMpeg exited with code -1 for C:\Users\xxxxxxxx\AppData\Roaming\MediaBrowser-Server\cache\encoded-media\20b15a52-b506-63d7-fff8-68dcf638e5ea.ts
2013-12-28 14:44:35.8319, Info, App, Deleting partial stream file(s) C:\Users\xxxxxxxx\AppData\Roaming\MediaBrowser-Server\cache\encoded-media\20b15a52-b506-63d7-fff8-68dcf638e5ea.ts
FFMpeg logs:

 

ffmpeg version N-58882-ga12f679 Copyright © 2000-2013 the FFmpeg developers

  built on Dec  8 2013 22:01:45 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 56.100 / 52. 56.100
  libavcodec     55. 45.100 / 55. 45.100
  libavformat    55. 22.100 / 55. 22.100
  libavdevice    55.  5.102 / 55.  5.102
  libavfilter     3. 92.100 /  3. 92.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, matroska,webm, from 'file:Q:\VIDs\Movies\Old School (2003) [1080p.BluRay.x264-HANGOVER]\Old School (2003) [1080p.BluRay.x264-HANGOVER].mkv':
  Metadata:
    creation_time   : 2008-12-10 14:30:00
  Duration: 01:31:50.53, start: 0.000000, bitrate: 12387 kb/s
    Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x816, SAR 1:1 DAR 40:17, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
Output #0, mpegts, to 'C:\Users\xxxxxxxr\AppData\Roaming\MediaBrowser-Server\cache\encoded-media\20b15a52-b506-63d7-fff8-68dcf638e5ea.ts':
  Metadata:
    encoder         : Lavf55.22.100
    Stream #0:0(eng): Video: h264, yuv420p, 1920x816 [sAR 1:1 DAR 40:17], q=2-31, 23.98 fps, 90k tbn, 23.98 tbc (default)
    Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), 640 kb/s (default)
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  982 fps=0.0 q=-1.0 size=   64503kB time=00:00:40.92 bitrate=12910.7kbits/s    
frame= 1957 fps=1957 q=-1.0 size=  120866kB time=00:01:21.69 bitrate=12119.7kbits/s    
frame= 2802 fps=1868 q=-1.0 size=  177063kB time=00:01:57.02 bitrate=12394.9kbits/s    
frame= 3526 fps=1763 q=-1.0 size=  233136kB time=00:02:27.07 bitrate=12985.8kbits/s    
frame= 4407 fps=1763 q=-1.0 size=  289193kB time=00:03:03.96 bitrate=12877.6kbits/s    
frame= 5274 fps=1757 q=-1.0 size=  345713kB time=00:03:40.00 bitrate=12873.1kbits/s    
 

 

Link to comment
Share on other sites

Ah ok do you have a video spec list for apple tv they must not support ts without an m3u8 (kinda strange but apple is apple )

Link to comment
Share on other sites

Ok I will hunt around see what i can find but streaming to is only a small part of the puzzle we can work on the logic of when to transcode etc later but for now I would suggest working on the library display as luke suggested as it is likely to take more time than streaming (from the looks).

Link to comment
Share on other sites

Starting here: https://github.com/iBaa/PlexConnect/blob/master/XMLConverter.py

 

What converts {{VAL(title)}} in Library.xml ( https://github.com/iBaa/PlexConnect/blob/master/assets/templates/Library.xml#L35 )   from its "placeholder/template element" type to the actual data that's pulled from Plex?

 

This is something I'm struggling with as yesterday was my first introduction to basic python. I don't know how to setup a debug/development environment in which I can trace such things.

Edited by BC101
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...