Page 1 of 2

Watching while recording

PostPosted: Mon Nov 28, 2011 6:28 pm
by sla
Hi,

I have a PVR recorder that can record to my NAS/Linux server. On the same server I have Serviio running. Serviio scans for new files every 2 mins.
Serviio publish the files normally, but only the first few minutes is available. I guess that Serviio finds the length on the files when scanning.

Is it possible to watch the recording while it is recorded?

Re: Watching while recording

PostPosted: Mon Nov 28, 2011 6:33 pm
by moltra
You might be able to do that once live streaming is completed.

Re: Watching while recording

PostPosted: Mon Nov 28, 2011 6:34 pm
by zip
I think you are right. It could be the file size, as Serviio doesn't know the file is not complete.

Re: Watching while recording

PostPosted: Mon Nov 28, 2011 6:58 pm
by sla
zip wrote:I think you are right. It could be the file size, as Serviio doesn't know the file is not complete.


Then what about let Serviio check for changed file size and scan again if changed?

Re: Watching while recording

PostPosted: Mon Nov 28, 2011 9:10 pm
by zip
Too much work for a niche functionality. You might be able to set up transcoding of that file and then Serviio can deal with growing file size.

Re: Watching while recording

PostPosted: Mon Nov 28, 2011 9:41 pm
by sla
zip wrote:Too much work for a niche functionality. You might be able to set up transcoding of that file and then Serviio can deal with growing file size.


I see, but could you get me a hint on how to do that?

Re: Watching while recording

PostPosted: Tue Nov 29, 2011 2:21 pm
by Illico
sla wrote:I see, but could you get me a hint on how to do that?

Could you provide information about your PVR file format (ffmpeg -i or Mediainfo result) , and the serviio profile you used?

Re: Watching while recording

PostPosted: Sat Dec 10, 2011 4:58 pm
by sla
Illico wrote:
sla wrote:I see, but could you get me a hint on how to do that?

Could you provide information about your PVR file format (ffmpeg -i or Mediainfo result) , and the serviio profile you used?


Hi, sorry for the late response.

Input #0, mpegts, from '11-12-02 - Disney XD - Et Par Konger - Da de 16-årige tveæggede tvillinger Brady og Boomer finder .ts':
Duration: 00:25:10.57, start: 15495.998978, bitrate: 5088 kb/s
Program 3207
Stream #0.0[0x209]: Video: mpeg2video (Main), yuv420p, 544x576 [PAR 24:17 DAR 4:3], 10000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0.1[0x2a4](swe): Audio: mp2, 48000 Hz, stereo, s16, 256 kb/s
Stream #0.2[0x2a5](nor): Audio: mp2, 48000 Hz, stereo, s16, 256 kb/s
Stream #0.3[0x2a6](dan): Audio: mp2, 48000 Hz, stereo, s16, 256 kb/s
Stream #0.4[0x2a7](fin): Audio: mp2, 48000 Hz, stereo, s16, 256 kb/s
Stream #0.5[0x246](swe): Subtitle: [6][0][0][0] / 0x0006
Stream #0.6[0x1ffe]: Data: [5][0][0][0] / 0x0005
Stream #0.7[0x350]: Data: [192][0][0][0] / 0x00C0
Stream #0.8[0x8fb]: Data: [11][0][0][0] / 0x000B
At least one output file must be specified


I'm using the Toshiba Regza profile.

Re: Watching while recording

PostPosted: Wed Feb 01, 2012 2:03 pm
by skug67
I'd love to figure this out also -- and I'm not sure it's such a "niche" functionality. I don't know that much about how the Serviio community uses their installations, but this functionality is certainly one of the most used aspects of TiVo. It's also available within the MythTV frontend setup. It would be tremendous if we could get the same functionality to an arbitrary DLNA-enabled advice that may be in a different room from a TiVo/MythTV box.

Re: Watching while recording

PostPosted: Mon Feb 13, 2012 5:17 pm
by Geers
Does it slow down the recording speed when you're watching this file at the same time?

Re: Watching while recording

PostPosted: Mon Feb 13, 2012 7:14 pm
by Illico
Could we considering an "in recording" file like a live stream media ?

Re: Watching while recording

PostPosted: Sat Apr 28, 2012 6:05 pm
by SpiderDawg
My search for a DLNA media server with this functionality is what brought me to Serviio; to date I've not found any media server capable of this. The best alternative I've found is to use vlc to stream the file via http and Serviio to send the live stream to my PS3, but that does not allow pause, ff, rw etc. I'm using an hdHomerun to record, and would love to be able to use the PS3's remote to control playback while recording. I have all the hardware, the only thing missing is appropriate software but I fear that a continued search is futile.

Is this even possible with DLNA? It would seem that someone would have already done it if it were possible.

Anyway, much thanks to Zip for creating Serviio, it's my favorite of all the media servers I've tried.

Re: Watching while recording

PostPosted: Sun Jul 28, 2013 9:54 am
by mavack
I've just started doing this myself recording to file on the server and having serviio pick the file up.

It does refresh eventually but i have no idea on what interval it does see the change in the file? Is there anyway to force a refresh on the files to pick up file size changes?

I do like the idea of having a live folder or something any chance of some sort of implementation?

Or has anyone else come up with a work around?

Re: Watching while recording

PostPosted: Mon Aug 12, 2013 8:15 am
by mavack
Well i've started using the cli method to trigger a database refresh via curl ...

This means that when the show is finished i can watch the completed recording, before it would refresh somewhere in the middle and then not refresh again until much later so the length would never update.

Would it be possible to directly hit the database with a minor class file?

Maybe implement some minor search functions? Maybe delete entry to force a re-discover? And maybe a method to overwrite the length so that serviio will continue to serve the file as its being written?

It would probably break DLNA standards or something but only allow it to be executed via CLI

java file.class search 12435

java file.class delete 12435

or
java file.class set attrib length 7200

I can write a batch/bash script in front to deal with the logic but some basic commands might be better since they are lesser used and you don't want them in the guy anyway.

Re: Watching while recording

PostPosted: Tue Aug 13, 2013 11:09 am
by mavack
ok i'm just going to put notes of my investigations while i try and work it out myself.

derby provides the sql interface you can use to do sql queries, i guess i should bursh up on my SQL, however derby database in embedded mode means you need to shut down serviio in order to connect to the database, another step :S

Having to kill the server makes it rather annoying. Can the code be modified to allow serviio to run in server mode and allow connections while its running? Wouldn't you just need to change your connect string? And i would need to setup server, i know its not for all users but there have been some asking for database access.

Re: Watching while recording

PostPosted: Fri Aug 16, 2013 5:16 am
by mavack
For those playing at home.

database access is actually pretty easy, using the ij utility from http://db.apache.org/derby/derby_downloads.html

you then connect to the database, since serviio runs in embedded mode you need to shutdown serviio before you can connect else it will error. I've copied mine to a different folder while i play.

  Code:
connect 'jdbc:derby:d:\tmp\db\db';


  Code:
HELP;


will give you a command reference but the ones you need to know.

  Code:
SHOW TABLES;


You can take a pretty good guess on what each of them hold, the one that i have been interested at the moment is MEDIA_ITEM

You can view the entire media database with

  Code:
SELECT * FROM MEDIA_ITEM;


you might want to widen your command prompt window as well to make it easier to read. This will output every file and every column.

you can get the column names with

  Code:
DESCRIBE MEDIA_ITEM;


Now lets build a custom table since you don't really care about all the data.
Lets say for what i'm interested in i want file_name title duration and file_size

  Code:
SELECT
id,file_name,title,duration,file_size
FROM media_item
where FILE_NAME like 'MasterChef%';


This outputs a table with only those columns as indicated by SELECT, and anything that starts with MasterChef the % is a wildcard, it can be used at the start or the end or both if you want, or without to find exact matches. Feel free to look at other columns for different information etc.

and now what i want to do edit/change something. you may have noticed above i included the id column, this is a unique value to a table like a line item so its easier to identify stuff.

So say i want to update the file_size and the duration as is my plan to allow a file to be played even while its being written.

  Code:
UPDATE media_item
SET duration = 10000
where id=31112;

UPDATE media_item
SET file_size = 9000000000
where id=31112;


and check that changes have happened

  Code:
select
id,file_name,title,duration,file_size
FROM media_item
WHERE id=31112;


you then have to commit i think, i'm not sure if autocommit is on by default but no harm. i believe you can also rollback changes as well via rollback and haven't tried that.

  Code:
COMMIT;



obviously this is messing with serviio at a low level so at your own risk is in order, currently i have only messed with a duplicate database, i have not yet loaded the database back to serviio.

Some things i will aim to find on the weekend
Is changing Duration/File size enough to allow uninterrupted playback of a file currently being written?
What happens if you do hit end of real file instead of fake file size?
It probably also breaks DLNA standards so no set correct action for this type of event?
When does serviio overwrite the changes?
What does serviio use as the reference to know if a file is currently in the database file_name? Or do multiple fields have to match?


If this works i then need to work out a way to script it, probably perl or bash via cygwin to stop service make changes start serviio.

If that works then maybe see if i can get class files that are compiled with a different JDBC string that links to a local database instead of an embedded, i can setup the derby database myself and link to that. And then make changes without stop/starting serviio.

Re: Watching while recording

PostPosted: Fri Aug 16, 2013 10:04 am
by zip
Note that Serviio also caches data, so the DB change might not be visible until the cache is invalidated (usually when files are added / updated)

Re: Watching while recording

PostPosted: Sat Aug 17, 2013 1:26 am
by atc98092
Zip, is the DB connectivity hard coded in Serviio, or is there something in a config or jar file that could edited to redirect to a different DB, either a full Derby install or perhaps MySQL? That would provide a way to build a DB maintenance application. I can completely understand your desire to keep it as simple as possible for most users, but it would be nice for us few tech heads to play around with something like that.

Re: Watching while recording

PostPosted: Sat Aug 17, 2013 10:54 am
by mavack
I've done some reading the embedded is slightly different to the server, and the JDBC drivers are not compatible, however there appears to be a 3rd mode, embedded server

http://db.apache.org/derby/papers/Derby ... ded+Server

and discussed here

http://www.coderanch.com/t/467789/open- ... ork-Server

A bit of best of both worlds, comes with some additional overhead but will allow people that want to read the database. I don't know how much additional overhead is and if it is worth it for the masses, but potentially if the changes are minor enough you could put a simple config flag that changes the operation, 1 checkbox in the gui or hide it in one of the xml files and make it change on reload or something.

Otherwise work out which class file needs to change and maybe just provide that to those that want it, and we can push it into the jar files ourselves since the ones that want it can surely work that out

Re: Watching while recording

PostPosted: Sat Aug 17, 2013 6:53 pm
by zip
atc98092 wrote:Zip, is the DB connectivity hard coded in Serviio, or is there something in a config or jar file that could edited to redirect to a different DB, either a full Derby install or perhaps MySQL? That would provide a way to build a DB maintenance application. I can completely understand your desire to keep it as simple as possible for most users, but it would be nice for us few tech heads to play around with something like that.

There is dbURL system property, where you could pass an external Derby server URL.