SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-06-2006, 10:44 PM
BobPhoenix BobPhoenix is offline
SageTVaholic
 
Join Date: Oct 2004
Posts: 3,152
Question about replacing a SageTV recording

I am writeing a plugin that will need to replace an original recording in a SageTV recording directory with one that has been edited with VideoReDo. I have code in place to change the modifed date and time:
Code:
DateTime=java_io_File_lastModified(FilePath)
java_io_File_setLastModified(OutputFile, DateTime)
Where FilePath is the original file in the Recording directory and OutputFile is the new edited file. Both are UNC paths so that they can be accessed with the same name from either my developement client and the SageTV server. In windows when I look at both the new and old files they appear to have the same date and time so it looks like this code will work unless I need to modify the create date and time also?

I have tried several ways to copy the new file back to the SageTV server and get the new file to show up the way I want. I've tried leaving the SageTV Service mode running and also with the Service and GUI completely shut down. Here's the problem. I copy it to the Server then rename the existing file to .old and rename the new file by removing the .new (file names are AmazingEarth-9024239-0.mpg.new and AmazingEarth-9024239-0.mpg) so the names match what Sage is expecting when done. I've also tried kicking off an EPG update and an imported files refresh but that hasn't worked either. I even tried adding a vrd to the file name ahead of the Sage id (mazingEarth-vrd-9024239-0.mpg).

Sage appears to recognize the diference in the files just fine as the size is listed in detailed setup correctly (2.17Gb instead of 3.41Gb). The problem is I expected to see red in the OSD to show that some of the show was missing or the time line on the OSD display to be less then an hour and I don't. In addition the edited file starts playback 2 minutes into the file because of the start padding I put on the recording on the original file. Which is what the problem really is. Anybody using this would miss however much of the file due to the padding.

Is this how something like this is suppose to work or do I need to modify another file attribute like create time or maybe change the extension to get Sage to recogize that part of the recording is missing? What I hoped was that with the same ending time I would just see red in the OSD for the begining of the file for the amount of time cut from the file. Would this have worked if instead of doing it manually I had let my code copy the file to the appropriate directory?

This is the first time I've tried this so your help would be appreciated. This is with 6.0.15 so this could just be new with the beta I suppose. Also I posted this here because ultimately whatever I need to do would need to be done in studio and/or java even though I did all my testing manually.

Thanks.
BobP.
Reply With Quote
  #2  
Old 12-07-2006, 04:52 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
GetSize(MediaFile) just reads the file size from the disk, so it is no surprise that it gets updated.

I went through this a lot when creating the webserver's edit file info...

Sage only rescans a media file for duration when the file is seen as a new file, so you need to convince Sage that the old file is gone, and to find the new file.

AddMediaFile() tells sage about new media files without the need for any library rescan

Sage will only reassociate a file with an Airing when that Airing does not have any old files (so you need to delete the old file from the DB)

File Start time is calculated as file timestamp - file duration, so you need to set the modified time to: AIRING START TIME + NEW FILE DURATION (don't worry about create time)

So what you need to do is:
  1. create your edited MPG (as file_xxx_0.mpg_new so that Sage does not see it)
  2. get the Airing and AiringID for the old MPG file (to get the Airing from a Media File, call: GetAiringForID(GetAiringID(MediaFile)) )
  3. set the timestamp of your edited MPG to: AIRING START TIME + EDITED MPG DURATION
  4. rename the old MPG file to file_xxx_0.mpg_old
  5. call Delete(MediaFile) to remove the old MediaFile from Sage's DB (the actual _old file will not be deleted)
  6. rename the new MPG file to file_<airingID>_0.mpg
  7. Call file=AddMediaFile("<path>\file_<airingID>_0.mpg")
  8. Check that the Airing associated with the new media file matches the Airing of the old media file (if you are lucky, Sage will have got it from the airing ID in the file name). If not, call SetMediaFileAiring(file,airing) to make the mapping.

That should be it... The file should now start at offset=0, and there should be a bunch of red at the end of the timebar corresponding to the missing edited commercials.

If at step 3, you do not know in advance what the new file duration will be, then rename the new to temp_dnjlafdaj.mpg (or similar), add the file to Sage with tempfile=AddMediaFile(), get the tempfile duration, rename the file back to it's old name, then Delete(tempfile)

Things to check: in older versions of sage, when a file was much shorter than the Airing duration, it was considered to be a partial recording. I think in the newer (5.0 or later) versions any file added with AddMediaFile() is automatically considered to be complete. Check this with a very edited file

Error check after every step: A couple of obvious failures are:
If the media file is in use (playing by a client), you will not be able to rename or delete it.
If the edited file is not be readable by Sage, AddMediaFile will fails, (and so you will need to rename the _old back and re-add it to the DB to prevent the Airing from being cleaned up)

Good luck!!!
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki
Reply With Quote
  #3  
Old 12-07-2006, 01:14 PM
BobPhoenix BobPhoenix is offline
SageTVaholic
 
Join Date: Oct 2004
Posts: 3,152
Thanks. I was afraid it was going to have to be something this complicated. Thanks for the detailed instructions too!!!

BobP.
Reply With Quote
  #4  
Old 12-14-2006, 11:18 PM
BobPhoenix BobPhoenix is offline
SageTVaholic
 
Join Date: Oct 2004
Posts: 3,152
Quote:
Originally Posted by nielm
So what you need to do is:
  1. create your edited MPG (as file_xxx_0.mpg_new so that Sage does not see it)
  2. get the Airing and AiringID for the old MPG file (to get the Airing from a Media File, call: GetAiringForID(GetAiringID(MediaFile)) )
  3. set the timestamp of your edited MPG to: AIRING START TIME + EDITED MPG DURATION
  4. rename the old MPG file to file_xxx_0.mpg_old
  5. call Delete(MediaFile) to remove the old MediaFile from Sage's DB (the actual _old file will not be deleted)
  6. rename the new MPG file to file_<airingID>_0.mpg
  7. Call file=AddMediaFile("<path>\file_<airingID>_0.mpg")
  8. Check that the Airing associated with the new media file matches the Airing of the old media file (if you are lucky, Sage will have got it from the airing ID in the file name). If not, call SetMediaFileAiring(file,airing) to make the mapping.
Well I've tried this and I get some strange results but I modified step 3 slightly I used AIRING END TIME instead of Start Time + Duration. I get the file showing up as an archived currently recording file. The only way I found it was to do a search in Sage and select Current Recordings folder and in Detailed info it shows up as recording until 2:00pm Oct 20, 2006. Would that be because I didn't use Start Time + Duration? I didn't really care which end of the file would have the missing info and by using the end time I don't have to calculate the duration or add and remove a temporary media file. Also when I look in the SERVER log file (I am doing this from a client) I see:
Code:
Thu 12/14 20:12:24.370 Added:Wasted[id=9563084 Airing=A[9024239,9024222,"Amazing Earth",16616@1020.13:00,60]]
Thu 12/14 20:12:24.397 Carny got a Wasted job of A[9024239,9024222,"Amazing Earth",16616@1020.13:00,60]
Thu 12/14 20:12:24.401 Deleted media segment file \\SageTVSrv\VideoSrv$\Video\AmazingEarth-9024239-0.mpg dtime=30 len=0
Thu 12/14 20:12:24.404 Added:Agent[Trend=TitleReRunsTrend, Title=Amazing Earth id=9563085 watchProb=0.0 createTime=Thu 12/14 20:12:24.400]
Thu 12/14 20:12:24.517 Added:MediaFile[id=9563086 A[9563090,9563087,"VideoAmazingEarth-9024239-0",0@1231.17:59,19435812] host=sagetvsrv encodedBy= format=null \\SageTVSrv\VideoSrv$\Video\AmazingEarth-9024239-0.mpg_new, Seg0[Wed 12/31 17:59:59.999-Wed 12/31 18:00:00.000]]
.
.
.
Thu 12/14 20:16:56.662 Checking video directories for new files
Thu 12/14 20:16:56.738 Swapping MediaFile's file to be \\SageTVSrv\VideoSrv$\Video\AmazingEarth-9024239-0.mpg from MediaFile[id=9563086 A[9024239,9024222,"Amazing Earth",16616@1020.13:00,60] host=sagetvsrv encodedBy= format=null \\SageTVSrv\VideoSrv$\Video\AmazingEarth-9024239-0.mpg_new, Seg0[Wed 12/31 17:59:59.999-Wed 12/31 18:00:00.000]]
Thu 12/14 20:16:58.280 File Format Parsed-2 \\SageTVSrv\VideoSrv$\Video\AmazingEarth-9024239-0.mpg=MPEG2-PS 0:41:59 0 kbps [#0 Video[MPEG2-Video 29.97003 fps 720x480 4:3 interlaced]#1 Audio[MP2 48000 Hz 2 channels 384 kbps MAIN idx=1 id=c0]]
Do I need to put some delays in? The fact that the "_new" files are listed in the log makes me wonder if Sage is seeing all files in a recording directory and not just media files. Suggestions would be welcome.

BobP.

Edit: Figured it out. It's amazing what typo'ing a variable name will cause.

Last edited by BobPhoenix; 12-15-2006 at 09:22 PM.
Reply With Quote
Reply


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

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


All times are GMT -6. The time now is 03:47 PM.


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