SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Clients Development

Notices

SageTV Clients Development This forum is for discussions relating to SageTV Open Source Clients Development.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-19-2016, 07:49 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 125
IOS App Questions

I have had a IOS client under development since Jan. of 2015. Around April of last year(2015) I had enough functionality working my son could use it on his iPad to watch movies on during an empty period he had at school. Since that time I have been steadily improving it. I have gone through 2 major rewrites of the IOS code since that time. I wasn't going to post about it until I had a beta ready to distribute next month(March) but in reading a post this morning from stuckless on the Android MiniClient with the comment:
"Just wait until an iOS client emerges to see even less support for video formats "
I don't know if the way we use SageTV is representative of how most people do. We have 2 hdpvr's each hooked up to a Directv receiver. I only have the hd channels mapped in. We also have hundreds of dvds we have ripped. We always choose "main movie" when ripping. We thus end up with the .ts files from the hdpvr's and the video_ts directory for the dvd rips.

Apple has very strict standards for how an app must do video. An app must use HLS with short chunks of 5-10 seconds each. My server side code is using handbrake to take hdpvr .ts files and dvd VIDEO_TS files to generate a .mp4 file. It then uses ffmpeg to generate the hls segmenting needed. The IOS app then requests either the hls stream for playback of the .mp4 file for downloading and local playback.

So my long round about question is what other video formats are people using with SageTV that I may be able to accommodate?

David
Reply With Quote
  #2  
Old 02-19-2016, 08:00 AM
dinki's Avatar
dinki dinki is offline
Sage Expert
 
Join Date: Mar 2006
Posts: 643
Exciting news on the iOS front!

I suppose live tv is not supported due to the transcoding requirements or are you doing the transcoding on-the-fly server side?
__________________
Intel Q6600 Quad 2.4GHZ, 8GB RAM, Win7 Pro SP1 64bit, 1 TB of Data
SageTV 9, Silicondust HDHomeRun x2 OTA
HD200
Reply With Quote
  #3  
Old 02-19-2016, 08:19 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 125
I have a strange setup at the moment! My sagetv server is very old and is running on an e8400 cpu. This doesn't even provide enough processing power to even do the batch style handbrake encoding/segmenting that is happening now. I actually have a scheduled process on another machine on the network that does this encoding/segmenting.

I actually purchased new hardware(6700k) several months ago for the server. I thought I would be smart and run the new server in parallel with my existing server and share out its drives and then do the encoding on the new hardware. This was working but for reasons I DON'T understand on my existing server the dvd cover art image and descriptions would disappear from my existing server! I am going to migrate to my new server in the next week. If I can get enough information on how to access the live stream from either c# or c++ then I would like to be able to support it, just not initially.


Quote:
Originally Posted by dinki View Post
Exciting news on the iOS front!

I suppose live tv is not supported due to the transcoding requirements or are you doing the transcoding on-the-fly server side?
Reply With Quote
  #4  
Old 02-19-2016, 08:23 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,541
Quote:
Originally Posted by davidb View Post
I have had a IOS client under development since Jan. of 2015. Around April of last year(2015) I had enough functionality working my son could use it on his iPad to watch movies on during an empty period he had at school. Since that time I have been steadily improving it. I have gone through 2 major rewrites of the IOS code since that time. I wasn't going to post about it until I had a beta ready to distribute next month(March) but in reading a post this morning from stuckless on the Android MiniClient with the comment:
"Just wait until an iOS client emerges to see even less support for video formats "
I don't know if the way we use SageTV is representative of how most people do. We have 2 hdpvr's each hooked up to a Directv receiver. I only have the hd channels mapped in. We also have hundreds of dvds we have ripped. We always choose "main movie" when ripping. We thus end up with the .ts files from the hdpvr's and the video_ts directory for the dvd rips.

Apple has very strict standards for how an app must do video. An app must use HLS with short chunks of 5-10 seconds each. My server side code is using handbrake to take hdpvr .ts files and dvd VIDEO_TS files to generate a .mp4 file. It then uses ffmpeg to generate the hls segmenting needed. The IOS app then requests either the hls stream for playback of the .mp4 file for downloading and local playback.

So my long round about question is what other video formats are people using with SageTV that I may be able to accommodate?

David
I think your app would be a welcome addition. You post echos my comment quite well. ie, iOS will play anything as long as it's in the single format it supports The existing Android MiniClient attempts to mimic the HD300 and play everything without transcoding (and it does it fairly well).

Basically, if you are transcoding before watching, then you should have pretty good success, but to answer your question about video formats... there is no limit I have a short list of samples that incude everything from .avi files, mkv files (with lots of different audio stream), mp4 files, .ts (h264, mpeg2), mpg files... interlaced, de-interlaced, etc, etc, etc.

Apple's approach to this was simple. Just send us the video in the only format that we'll support, and it's play fine. And it does. The problem is that almost no one has HLS encoded files, automatically, so, it always has be transcoded.

FYI, in SageTV 9, there is code in there to do HLS encoding on the fly. It's never been used, but, I suspect that it was added to support an iOS client that never emerged. Might be worth checking out.
Reply With Quote
  #5  
Old 02-19-2016, 01:30 PM
Taddeusz Taddeusz is offline
SageTVaholic
 
Join Date: Nov 2004
Location: Yukon, OK
Posts: 3,919
What is the reason for doing the conversion with Handbrake? Does ffmpeg with x264 not work?
__________________
Server: i5 8400, ASUS Prime H370M-Plus/CSM, 16GB RAM, 15TB drive array + 500GB cache, 2 HDHR's, SageTV 9, unRAID 6.6.3
Client 1: HD300 (latest FW), HDMI to an Insignia 65" 1080p LCD and optical SPDIF to a Sony Receiver
Client 2: HD200 (latest FW), HDMI to an Insignia NS-LCD42HD-09 1080p LCD
Reply With Quote
  #6  
Old 02-19-2016, 02:12 PM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 125
I started with handbrake early on in the project before I realized I needed to do hls segmenting. At that point it was easier to just add the segmenting part.

My next major task is going to be generating the hls segmenting when the client requests it. From what I have read ffmpeg should be able to do it but I haven't used it. Just one of the many things to read about!

Quote:
Originally Posted by Taddeusz View Post
What is the reason for doing the conversion with Handbrake? Does ffmpeg with x264 not work?
Reply With Quote
  #7  
Old 02-19-2016, 03:24 PM
Narflex's Avatar
Narflex Narflex is offline
Sage
 
Join Date: Feb 2003
Location: Redondo Beach, CA
Posts: 6,301
You should definitely take a stab at trying to use the HLS server that's in SageTV9. I've used it before to watch videos on iOS successfully (but that was quite a few years ago).

The code for it starts in sage.MiniClientSageRenderer.java (just search for HTTPLS). You can basically just do HTTP requests on port 31099. There's specifics for how the URL needs to be constructed which hopefully you can deduce from the sage.HTTPLSServer code. If you need more help just let me know and I can likely give you some instructions for trying it out.
__________________
Jeffrey Kardatzke
Google
Founder of SageTV
Reply With Quote
  #8  
Old 02-20-2016, 09:17 PM
SageWizdom SageWizdom is offline
Sage Advanced User
 
Join Date: Oct 2013
Location: https://github.com/SageWizdom/SageConnect
Posts: 216
I wanted to post some enthusiasm for this project. We're an IOS family since that keeps the wife happy, and if you need a beta tester, I would be delighted to help.

Any chance your app would work in an AppleTV v4? A SageTV App is the excuse I have been waiting for to get one. (also again happy to test this). Currently I have two ATV2s.

As a side note, I have leveraged the streaming to IOS via the web and mobile web interfaces. It has definitely worked. I was running an IOS / AppleTV hack a year ago based on plex, and found that if I started a stream recording, I could actually watch "live tv" by simply starting a recording of the show I wanted to watch, give it a little time to start buffering and the begin to stream the transcoded file to the ATV.

I was actually hoping to enable comskip support, but leveraging what looked like the ability in the HLS stream to jump to a specific time code. At least in the original plex code, the ATV would report back every x seconds where it was in the stream (for resume). I never got around to seeing if that same function could allow the player to jump ahead in the stream. I was going to try and implement something where at stream load, you would download a bunch of time pairs. When you hit the first, you jump to the second, then delete the pair (in case it was wrong and you wanted to back up). This way it would presumably jump over all of the commercials as if you had used the ATV remote to seek forward (or so went my theory).

Keep up the great work!
Reply With Quote
  #9  
Old 02-21-2016, 09:13 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,541
Something else to consider as well would be to use IJKPlayer
https://github.com/Bilibili/ijkplayer

This player works in both Android and iOS (which is why I chose it for Android MiniClient). The SageTV streaming protocol for PULL mode can be easily adjusted to work like a URL stream. (It's how I started out using it in the Android port, before moving on to the move complex way of building my own datasources).

If IJKplayer was used, then you'd likely not need to worry about transcoding. It will use h264 hardware decoding on iOS, and it will use software decoding for everything else.
Reply With Quote
  #10  
Old 02-21-2016, 09:35 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 125
The comskip part was frustrating! The Apple HLS spec shows how to add chapter support to a stream. When I first tried this no chapters would show up on the device. I looked at for for several days and still couldn't get it to work. I finally broke down and submitted a bug report with Apple last March. They came back and wanted a test server url that demonstrated the problem. I added port forwarding in my router and setup iis on my server on a high port number so Apple could see the problem. Months pasted and I got no response so I removed the port forwarding and iis config. Then 2 months letter I got an email that they couldn't access the test server!

I have the utmost respect for the author of comskip! I am sure it's an enormously complicated code set to be able to detect the commercials. I am running the donator version and when it works its great! When it doesn't work I know it's a matter of tuning for that show/network. I have started reading the tuning guide at least a half a dozen times over the last several years. I haven't figured it out but simply haven't spent enough time with it. I don't mind paying the author an additional donation for a tuning config for some of the shows it doesn't work quite right on but have never set down and followed through with it with what is required to submit a tuning request to him. What he needs is quite reasonable the fault is just with me!

As a result I was looking for another way to skip commercials. What I came up with was a way to when your are playing back the video and a commercial starts you press a button which then sends the media id and current position to my server side code. It then uses ffmpeg to generate poster images every 20 seconds ahead. It generates 15 of these which is 3 per minute so 5 minutes of what is coming ahead. This is then sent to the ios device which shows the images. You touch the image that is the last commercial before the show starts and you then end up watching less than 20 seconds of the commercial instead of 3 or 4 minutes. This is all triggered but on button the player labeled "frames" I don't like this name but haven't come up with a short replacement name. Suggestions welcome!!! In the process of adding "frames" support I basically had to stop using the ios playback menus and do it myself. When I get this working it was a simple matter to add the chapter forward/backward buttons for comskip when a media has the .edl file. If there is no edl file at the time of playback then the chapters buttons are hidden.


Maybe I am missing something but I don't see the value in an Apple TV sage app. I would expect most existing Sage users already have and HD300 extender. For new people Stuckless's Android client looks like a great option that can already provide access to Sage.

My first design goal for this app was to be able to provide non internet connected operation. What this means is after you have run it once it actually downloads from my server code a database of the recordings and video info. This means the titles, descriptions and poster image are always available even when you don't have connectivity. When you start the app it sends the db version number you have to the sever side code. If you have connected fairly recently then the server sends down any updates to your database to bring you current with what has been added and deleted. If you haven't connected recently then the server will just send you a new database to replace the one you have. When you watched something the server side code streams it to you. You can also download a single item or add an item to a download list. You can then download everything in the list or the first item in the list. The app has a menu choice that lets you see a view of just downloaded items. I have used this a lot when traveling on an airplane to be able to watch something.

I will make up a short video of the app running which will probably be much clearer than this!

Yes I will need beta tester and would appreciate your help.


Quote:
Originally Posted by SageWizdom View Post
I wanted to post some enthusiasm for this project. We're an IOS family since that keeps the wife happy, and if you need a beta tester, I would be delighted to help.

Any chance your app would work in an AppleTV v4? A SageTV App is the excuse I have been waiting for to get one. (also again happy to test this). Currently I have two ATV2s.

As a side note, I have leveraged the streaming to IOS via the web and mobile web interfaces. It has definitely worked. I was running an IOS / AppleTV hack a year ago based on plex, and found that if I started a stream recording, I could actually watch "live tv" by simply starting a recording of the show I wanted to watch, give it a little time to start buffering and the begin to stream the transcoded file to the ATV.

I was actually hoping to enable comskip support, but leveraging what looked like the ability in the HLS stream to jump to a specific time code. At least in the original plex code, the ATV would report back every x seconds where it was in the stream (for resume). I never got around to seeing if that same function could allow the player to jump ahead in the stream. I was going to try and implement something where at stream load, you would download a bunch of time pairs. When you hit the first, you jump to the second, then delete the pair (in case it was wrong and you wanted to back up). This way it would presumably jump over all of the commercials as if you had used the ATV remote to seek forward (or so went my theory).

Keep up the great work!
Reply With Quote
  #11  
Old 02-21-2016, 09:58 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 125
If I wasn't so far along and spent so many hours getting the "frames" menu and playback/resume support going then I would certainly look at other options.

The way my app works is I have server side code written which is using NancyFX which lets my self host inside my app. The IOS app then sends different requests for database updates, recording schedule, downloads and playback. When I started the project I bought a 4tb drive for less than $150. I use this drive for all encoding for my app. I have a process that runs at midnight that encodes anything new to mp4 and then splits the mp4 into the hls segements. When the app is running and they watch a something the server serves up the .ts segments and the .m3u8 file. They can also download the video which is why the mp4 file is kept. This lets someone use the app when not connected to watch something that has been downloaded. For reasons I don't understand I can't just download the .ts files and the .m3u8 file and have IOS play it back locally! IOS requires a url for HLS placyback!! This is stupid and frustrating! I like developing for windows because I can do what I want when want but for IOS my hands are tied. There is IOS code available which runs a mini web server from an app and I thought of going approach but it looks like the App acceptance guidelines prohibit running your own web server.

Quote:
Originally Posted by stuckless View Post
Something else to consider as well would be to use IJKPlayer
https://github.com/Bilibili/ijkplayer


This player works in both Android and iOS (which is why I chose it for Android MiniClient). The SageTV streaming protocol for PULL mode can be easily adjusted to work like a URL stream. (It's how I started out using it in the Android port, before moving on to the move complex way of building my own datasources).

If IJKplayer was used, then you'd likely not need to worry about transcoding. It will use h264 hardware decoding on iOS, and it will use software decoding for everything else.
Reply With Quote
  #12  
Old 02-21-2016, 10:18 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,541
Quote:
Originally Posted by davidb View Post
If I wasn't so far along and spent so many hours getting the "frames" menu and playback/resume support going then I would certainly look at other options.

The way my app works is I have server side code written which is using NancyFX which lets my self host inside my app. The IOS app then sends different requests for database updates, recording schedule, downloads and playback. When I started the project I bought a 4tb drive for less than $150. I use this drive for all encoding for my app. I have a process that runs at midnight that encodes anything new to mp4 and then splits the mp4 into the hls segements. When the app is running and they watch a something the server serves up the .ts segments and the .m3u8 file. They can also download the video which is why the mp4 file is kept. This lets someone use the app when not connected to watch something that has been downloaded. For reasons I don't understand I can't just download the .ts files and the .m3u8 file and have IOS play it back locally! IOS requires a url for HLS placyback!! This is stupid and frustrating! I like developing for windows because I can do what I want when want but for IOS my hands are tied. There is IOS code available which runs a mini web server from an app and I thought of going approach but it looks like the App acceptance guidelines prohibit running your own web server.
Creating a decent playback is no small task, and sounds like you are doing a decent job of it. Don't think that that using IJKPlayer devalues what you've done... It can probably be implemented along side of your existing implementation, and work exactly the same way you are using the native player (ie using frames, etc). I haven't used IJKplayer on iOS, but I think the API was meant to emulate the native player API, to make it easy for people to consume it. If IJKPlayer was used, then can keep your existing logic as is... but maybe it would help when doing things like local playback, playback from files, and eventually if you severed up non-transcoded files via URLs from the server, it would just work with that as well. Something to look into, down the road.

Last edited by stuckless; 02-21-2016 at 10:20 AM.
Reply With Quote
  #13  
Old 02-21-2016, 10:55 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 125
Thanks for the suggestion! I will definitely consider it as I am adding functionality to my app. I don't really care if I switch to something and it obsoletes a portion of my code. I have been a developer now for over 30 years so it's happened to me many times before. I am just looking for what is best for the app that I can get done in a reasonable portion of my spare time.

David

Quote:
Originally Posted by stuckless View Post
Creating a decent playback is no small task, and sounds like you are doing a decent job of it. Don't think that that using IJKPlayer devalues what you've done... It can probably be implemented along side of your existing implementation, and work exactly the same way you are using the native player (ie using frames, etc). I haven't used IJKplayer on iOS, but I think the API was meant to emulate the native player API, to make it easy for people to consume it. If IJKPlayer was used, then can keep your existing logic as is... but maybe it would help when doing things like local playback, playback from files, and eventually if you severed up non-transcoded files via URLs from the server, it would just work with that as well. Something to look into, down the road.
Reply With Quote
  #14  
Old 02-21-2016, 03:22 PM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 6,578
I am also hugely supportive of this effort as we are also an iOS family that has to use stuff like Air Video HD or Plex to watch SageTV content on an iPad. I am willing to chip in financially if you desire.

By the way, you mentioned that your SageTV server was ancient running an E8400. There are tons of people here using WAY older/slower CPUs.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #15  
Old 02-22-2016, 06:39 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,805
Quote:
Originally Posted by davidb View Post
As a result I was looking for another way to skip commercials. What I came up with was a way to when your are playing back the video and a commercial starts you press a button which then sends the media id and current position to my server side code. It then uses ffmpeg to generate poster images every 20 seconds ahead. It generates 15 of these which is 3 per minute so 5 minutes of what is coming ahead. This is then sent to the ios device which shows the images. You touch the image that is the last commercial before the show starts and you then end up watching less than 20 seconds of the commercial instead of 3 or 4 minutes.
Great work on this. IOS support is a welcome addition.

FYI - I wrote a plugin that does what you describe above. See Thumbnail Navigator. After you install the plugin pressing the up arrow will display thumbnails for different points in the video. The gap between the tumbnails is configurable.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #16  
Old 02-23-2016, 06:22 AM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 125
Thanks for the offer of financial support but I don't need any. I am curious what kind of hardware are you running the Air Video server side stuff on? I briefly tried it about a year ago but didn't spend much time with it. It sounds like I still need to keep my old e8400 sage server around but just running it on a different network than the rest of the house. That way I can still do testing on lower end hardware.

Quote:
Originally Posted by wayner View Post
I am also hugely supportive of this effort as we are also an iOS family that has to use stuff like Air Video HD or Plex to watch SageTV content on an iPad. I am willing to chip in financially if you desire.

By the way, you mentioned that your SageTV server was ancient running an E8400. There are tons of people here using WAY older/slower CPUs.
Reply With Quote
  #17  
Old 02-23-2016, 07:52 AM
oddjob's Avatar
oddjob oddjob is offline
Sage Advanced User
 
Join Date: Aug 2004
Location: Chicago, IL
Posts: 184
Great news! I will keep an eye on this thread!

FYI - I use airvideo on my appletv and it works great. My PC is a 6 year old AMD 6 core 4.0 ghz
Reply With Quote
  #18  
Old 02-23-2016, 10:29 AM
wayner wayner is offline
SageTVaholic
 
Join Date: Jan 2008
Location: Toronto, ON
Posts: 6,578
Quote:
Originally Posted by davidb View Post
Thanks for the offer of financial support but I don't need any. I am curious what kind of hardware are you running the Air Video server side stuff on? I briefly tried it about a year ago but didn't spend much time with it. It sounds like I still need to keep my old e8400 sage server around but just running it on a different network than the rest of the house. That way I can still do testing on lower end hardware.
My CPU is in my sig - it is an i5-660 so it is one generation newer than yours I think. But I will be moving to a V9 server on the latest and greatest hardware an i7-6700K.
__________________
New Server - Sage9 on unRAID 2xHD-PVR, HDHR for OTA
Old Server - Sage7 on Win7Pro-i660CPU with 4.6TB, HD-PVR, HDHR OTA, HVR-1850 OTA
Clients - 2xHD-300, 8xHD-200 Extenders, Client+2xPlaceshifter and a WHS which acts as a backup Sage server
Reply With Quote
  #19  
Old 03-10-2016, 07:53 PM
SageWizdom SageWizdom is offline
Sage Advanced User
 
Join Date: Oct 2013
Location: https://github.com/SageWizdom/SageConnect
Posts: 216
Any chance you would be up for some beta testers? I think my wife would love this.
Reply With Quote
  #20  
Old 03-11-2016, 06:20 PM
davidb's Avatar
davidb davidb is offline
Sage Advanced User
 
Join Date: Feb 2009
Posts: 125
Yes I certainly will. I would have had it in beta now but I changed my mind at the last minute to change to encoding on the fly with ffmpeg when you want to watch something. The way I was doing it everything would have to be encoded first. This way is more flexible and will let you have access to all video media on Sage. I should be ready for beta testing later this month.

David

Quote:
Originally Posted by SageWizdom View Post
Any chance you would be up for some beta testers? I think my wife would love this.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ROKU Questions, Plex Questions ThePaladinTech The SageTV Community 16 08-26-2013 10:53 PM
Newbie questions... hardware questions bigRoN18 Hardware Support 9 10-13-2010 02:50 PM
MVP Questions... vvulture SageTV Media Extender 4 05-02-2007 04:06 PM
HD OTA Questions crowland Hardware Support 8 02-14-2007 05:06 PM
Questions regarding 2.2.3 srcurtis SageTV Beta Test Software 0 01-22-2005 01:51 PM


All times are GMT -6. The time now is 12:17 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.