NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Support Legacy (v4.x and earlier) v
« Previous 1 … 222 223 224 225 226 … 433 Next »
Challenge with Postprocessing.bat

Challenge with Postprocessing.bat
Bobins
Offline

Posting Freak

UK (North West)
Posts: 1,219
Threads: 138
Joined: Sep 2004
#1
2014-03-05, 12:46 PM
My days of programming batch files are a bit rusty so I think I’m missing something very basic here.

Having just built a new NPVR system with a quad tuner where I could be recording multiple HD programmes concurrently whilst playing back previously recorded HD content, I was concerned about the potential throughput bottleneck and wear & tear on my new 3Tb hard disks.

I decided that a better approach may be to use an SSD as a “high speed” recoding cache and then move the recordings to the hard disk as they complete using the PostProcessing.bat file.

I set the PostProcessing.bat file to call a file Move.bat logging to a log file in the Logs directory. The Move.bat file checks the recording exists in the relevant directory on the SSD, copies it to the new location, checks the new file/directory exists, updates the database then deletes the old recording file.
I’ve proven this works reliably (even handling when the file name contains an “&” which proved tricky in variables in a batch file Smile ).

The other night I noticed that some recordings hadn’t been moved from the SSD cache. I checked my log file and couldn’t find any trace of a request to move these files or any error. When I checked the NPVR logs I find that the problem occurs when multiple recordings finish at exactly the same time. The first recording details are submitted to the PostProcessing.bat and it triggers the move process which completes successfully and logs the results in my log file.

The 2nd (and any other recordings which complete at the same instant) are logged in the NPVR log as calling PostProcessing.bat and passing the correct parameters however there is no record of these 2nd or subsequent calls to Postprocessing.bat actually resulting in the batch file running.

The 1st call to the PostProcessing.bat file would have still been running when the 2nd, 3rd call etc. would have been made. My log file records the 1st running of the PostProcessing.bat file but shows no evidence of the additional calls nor are there any errors in the Windows or NPVR logs.

I’m assuming here that the problem may be that running concurrent instances of PostProcessing.bat isn’t being allowed and the 2nd and subsequent calls are being ignored because it’s already running. If that’s the case how can I fix this?

Any ideas anyone?
NPVR Version= 7.0.1.241229
Intel i5 Ten Core 14400 + 16GB DDR5 in Gigabyte B760 AX Motherboard
Windows 11 Pro 64bit
TBS-6902 dual DVB-S tuner
TBS-6205 quad DVB-T tuner
500Gb System Disk (M2 Nvme SSD)
4Tb Media Store (2 x 2Tb M2 Nvme SSD Spanned)

Raspberry Pi3 B+, Pi4B (OSMC) & Pi5 (XBian) running Kodi v21.1
Graham
Offline

Posting Freak

UK
Posts: 4,058
Threads: 102
Joined: Dec 2005
#2
2014-03-05, 03:14 PM
My complete stab in the dark would be to use the "start" command to run the file copy and update process so that a new cmd process is spawned to do the copies.

But ... I don't think that any of this is necessary. I would expect a local hard drive to easily cope with the load from four simultaneous HD recordings and one (or more) HD playbacks.

Have you tried recording and playback while looking at % disk active time in Resource Monitor (started from inside Task Manager)?
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,754
Threads: 769
Joined: Nov 2003
#3
2014-03-05, 04:28 PM
I'm confident that if the nrecord.log shows it running PostProcessing.bat, then it's definitely running it. This stuff is very simple, and hasn't been changed in years. There is lots of people use PostProcessing.bat files - we'd have heard a lot more about it if it wasn't coping with multiple recordings ending at the same time.

It's likely something in your batch is at fault. For your own logging being missing, maybe you're trying to write to the same log file that is open at the same instance in the other running batch file? Maybe temporarily try new log file names for each run on the batch file? (for example, put recording oid in the filename)
johnsonx42
Offline

Posting Freak

Posts: 7,298
Threads: 189
Joined: Sep 2008
#4
2014-03-05, 05:20 PM
I've run into a variety of conditions with multiple simultaneous scripts running, none of which are NPVR's fault. I use a "sleep %2" (or "timeout /T %2" now with windows vista/7) command at the beginning to make each script pause for a number of seconds equal to the channel number; this way the scripts aren't doing their processing at the same time. For situations where I'm logging the std-out of a command that doesn't finish instantly, I direct the output to a unique log file using %3 (recording OID as sub suggested). Here's my current parallelprocessing.bat, which does a bunch of stuff along those lines (as always, I disclaim any suggestion that my batch file is in any way elegant or the right way to do anything):
Code:
cd c:\users\public\npvr\comskip

echo %date%,%time% - %~n1 (%3) recording from channel %2 on tuner %4 >>"%~dp0\recording.log"

Rem list of channels to not run comskip on; PBS channels have no commercials
if "%2" == "27" goto skip
if "%2" == "28" goto skip
if "%2" == "29" goto skip
if "%2" == "50" goto skip
if "%2" == "51" goto skip
if "%2" == "52" goto skip
if "%2" == "53" goto skip
if "%2" == "58" goto skip
if "%2" == "59" goto skip
if "%2" == "60" goto skip
if "%2" == "61" goto skip

goto next

:skip
echo skipping comskip on %~n1; channel %2 in skip list >>"%~dp0\recording.log"
goto continue

:next
echo   ---  sleeping %2 seconds to avoid simultaneous execution >>"%~dp0\recording.log"
sleep %2

:check
tasklist | find /c "comskip" > %3.txt
set /p count= <%3.txt
if %count% geq 3 (
  echo ...%count% comskips running now, waiting 1 minute >>"%~dp0\recording.log"
  sleep 60
  goto check
)
del %3.txt

echo %date%,%time% - invoking comskip on %1 >>"%~dp0\recording.log"
comskip %1 >>"%~dp0\%3.log"
echo %date%,%time% - comskip finished with %1 >>"%~dp0\recording.log"

:continue

REM ok, now we're going to rename the recorded file
REM first sleep for 5 seconds just to make sure file activity is settled, +60 to avoid npvr padding bug
sleep 65

REM check if comskip has run on this file; if not skip to renaming (this is kinda pointless right now, but might be useful later)
:checkcomskip
if not exist "%~dpn1.log" goto makename

REM get rid of excess comskip files... we only need the .edl
del "%~dpn1.log"
del "%~dpn1.txt"
del "%~dpn1.logo.txt"

:makename
REM I used to have a long sequence of commands to build a new name here, but now imagegrablite does all that

REM ok, ready to rename the file... but first check to make sure no one is watching it!
REM try renaming the file to the same name, see if gets an error
echo checking if %1 is open >>"%~dp0\recording.log"
:checkopen
rem first check that the original file is still here; if it's gone the loop will be infinite
if not exist %1 goto abort
rem now try renaming the file to see if it's open
ren %1 "%~nx1"
if errorlevel 1 goto waitandcheck
echo %1 wasn't open >>"%~dp0\recording.log"
goto rename
:waitandcheck
REM if we got here, the rename failed so wait a minute and try again
echo %1 still open, waiting 1 minute >>"%~dp0\recording.log"
sleep 60
goto checkopen
:abort
echo %1 is gone, aborting!!!>>"%~dp0\recording.log"
goto eof

:rename
REM finally, all is clear.  run imagegrablite against the file
echo %date%,%time% - renaming oid %3, file %1 >>"%~dp0\recording.log"
"c:\program files\npvr\imageGrabLite.exe" --oid %3 --rename --zap2it >>"%~dp0\%3.log"

REM now grab the log output and save it for possible later examination
type "c:\users\public\npvr\logs\imageGrabLite.log" >> "%~dp0\recording.log"

:eof
server: NextPVR 5.0.7/Win10 2004/64-bit/AMD A6-7400k/hvr-2250 & hvr-1250/Winegard Flatwave antenna/Schedules Direct
main client: NextPVR 5.0.7 Desktop Client; LG 50UH5500 WebOS 3.0 TV
Bobins
Offline

Posting Freak

UK (North West)
Posts: 1,219
Threads: 138
Joined: Sep 2004
#5
2014-03-05, 05:48 PM
Thanks guys, I'll do some furtehr testing tonight.

And for the record Sub, I wasn't for a minute suggesting this was a problem with NPVR....I'm sure it's self inflicted with a Windows/batch issue I've not quite got right.
NPVR Version= 7.0.1.241229
Intel i5 Ten Core 14400 + 16GB DDR5 in Gigabyte B760 AX Motherboard
Windows 11 Pro 64bit
TBS-6902 dual DVB-S tuner
TBS-6205 quad DVB-T tuner
500Gb System Disk (M2 Nvme SSD)
4Tb Media Store (2 x 2Tb M2 Nvme SSD Spanned)

Raspberry Pi3 B+, Pi4B (OSMC) & Pi5 (XBian) running Kodi v21.1
Bobins
Offline

Posting Freak

UK (North West)
Posts: 1,219
Threads: 138
Joined: Sep 2004
#6
2014-03-15, 09:09 AM
Problem solved.

The issue was as Sub suggested. I was using an append to the log file assuming that would allow write from different running batches concurrently....FAIL.

The first batch opens the file for write and holds it open preventing other batches accessing therefore they exit without completing the process. The problem was fixed by creating discrete log files for each running batch (named by time/date).

I didn't really want lots of files accumulating in my log directory so just need to figure out a way to get the info back into a single file Big Grin
NPVR Version= 7.0.1.241229
Intel i5 Ten Core 14400 + 16GB DDR5 in Gigabyte B760 AX Motherboard
Windows 11 Pro 64bit
TBS-6902 dual DVB-S tuner
TBS-6205 quad DVB-T tuner
500Gb System Disk (M2 Nvme SSD)
4Tb Media Store (2 x 2Tb M2 Nvme SSD Spanned)

Raspberry Pi3 B+, Pi4B (OSMC) & Pi5 (XBian) running Kodi v21.1
stustunz
Offline

Posting Freak

Posts: 5,111
Threads: 112
Joined: Oct 2006
#7
2014-03-15, 10:04 AM
write speed of a standard hard drive at least 150MB/s
amount of data from HD 3MB/s x4 stations =12MB/s

Are my numbers wrong ?
[SIZE="1"]Specs[/SIZE]
[SIZE="1"]Server:Cpu-Intel i3,ATI Radeon HD 5670 ,OS-Windows 7,2gig ram. 2xHvr4400,Nova-s plus(dvb-s SD),hvr2210(dvb-t HD)[/SIZE]
[SIZE="1"]Client:Cpu-AMD am2,Gpu-Ati HD2100 integrated ,OS-Windows 7,2gig ram[/SIZE]
[SIZE="1"]Client:Cpu Intel 2 gig ram ,Nvidia 9400[/SIZE]
[SIZE="1"]ClientTongueopcorn Hour A110[/SIZE]
[SIZE="1"]Client:Samsung [NZ][DVB-s][2012]BD-E5900x2 [/SIZE]
[SIZE="1"]Client:Samsung [NZ][DVB-s][2013]BD-F6500 [/SIZE]
stustunz
Offline

Posting Freak

Posts: 5,111
Threads: 112
Joined: Oct 2006
#8
2014-03-15, 10:36 AM
Its actually less
the maximum amount of data per frequency is 19.39 Mbit/s which is 2.42MB/s x4 =9.68MB/s

but your hard drive may only write at say 80MB/s if its a green one \
[SIZE="1"]Specs[/SIZE]
[SIZE="1"]Server:Cpu-Intel i3,ATI Radeon HD 5670 ,OS-Windows 7,2gig ram. 2xHvr4400,Nova-s plus(dvb-s SD),hvr2210(dvb-t HD)[/SIZE]
[SIZE="1"]Client:Cpu-AMD am2,Gpu-Ati HD2100 integrated ,OS-Windows 7,2gig ram[/SIZE]
[SIZE="1"]Client:Cpu Intel 2 gig ram ,Nvidia 9400[/SIZE]
[SIZE="1"]ClientTongueopcorn Hour A110[/SIZE]
[SIZE="1"]Client:Samsung [NZ][DVB-s][2012]BD-E5900x2 [/SIZE]
[SIZE="1"]Client:Samsung [NZ][DVB-s][2013]BD-F6500 [/SIZE]
Bobins
Offline

Posting Freak

UK (North West)
Posts: 1,219
Threads: 138
Joined: Sep 2004
#9
2014-03-15, 10:39 AM
Wouldn't suggest they are....

My target was more to reduce wear & tear on the hard drives due to head thrashing caused by writing 2 or 3 HD recordings at the same time as playing back 1 or 2 HD recordings.

Over the years I've had a few hard disks fail and the more data you have on them the more painful any attempt at recovery. I had a 1Tb drive fail in my home server two weeks ago (Used for photos & Music storage). Typically at any one time there's 1.5Tb - 2Tb on the NPVR drives. (99% not my recordings but the other half's)

Whilst modern drives should be reliable, I've even had "enterprise" class drives fail after 18 months so I'm being ultra cautious. The drives in the NPVR media store are even set to spin down when not in use.
NPVR Version= 7.0.1.241229
Intel i5 Ten Core 14400 + 16GB DDR5 in Gigabyte B760 AX Motherboard
Windows 11 Pro 64bit
TBS-6902 dual DVB-S tuner
TBS-6205 quad DVB-T tuner
500Gb System Disk (M2 Nvme SSD)
4Tb Media Store (2 x 2Tb M2 Nvme SSD Spanned)

Raspberry Pi3 B+, Pi4B (OSMC) & Pi5 (XBian) running Kodi v21.1
stustunz
Offline

Posting Freak

Posts: 5,111
Threads: 112
Joined: Oct 2006
#10
2014-03-15, 10:42 AM
Ok i just buy a new one every year to record on they are so cheap now
[SIZE="1"]Specs[/SIZE]
[SIZE="1"]Server:Cpu-Intel i3,ATI Radeon HD 5670 ,OS-Windows 7,2gig ram. 2xHvr4400,Nova-s plus(dvb-s SD),hvr2210(dvb-t HD)[/SIZE]
[SIZE="1"]Client:Cpu-AMD am2,Gpu-Ati HD2100 integrated ,OS-Windows 7,2gig ram[/SIZE]
[SIZE="1"]Client:Cpu Intel 2 gig ram ,Nvidia 9400[/SIZE]
[SIZE="1"]ClientTongueopcorn Hour A110[/SIZE]
[SIZE="1"]Client:Samsung [NZ][DVB-s][2012]BD-E5900x2 [/SIZE]
[SIZE="1"]Client:Samsung [NZ][DVB-s][2013]BD-F6500 [/SIZE]
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (2): 1 2 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  postprocessing batch to escape special characters donbrew 3 1,749 2019-11-06, 11:29 PM
Last Post: JavaWiz
  PostProcessing.bat not executing MiyoshiSaki 13 4,756 2019-09-03, 10:36 PM
Last Post: sub
  PostProcessing and PostCancel.bat being triggered but not working antenna 4 1,861 2018-08-05, 07:40 PM
Last Post: antenna
  PostProcessing.bat doesn't run wscrivens 23 7,877 2016-04-08, 06:30 PM
Last Post: Handy.Man
  Show CMD window while executing PostProcessing.bat uspino 6 2,876 2015-12-08, 11:41 PM
Last Post: mvallevand
  Havng trouble using VideoRedo in Batch (Postprocessing.bat) ????? puck64 0 1,504 2015-11-14, 10:39 AM
Last Post: puck64
  PostProcessing failing Quaraxkad 22 7,149 2015-10-19, 10:43 AM
Last Post: puck64
  PostProcessing.bat not run on Recording Cancel arrmo 9 2,638 2015-08-10, 01:31 PM
Last Post: arrmo
  Strange problem with PostProcessing and PsExec Reddwarf 8 2,675 2015-06-10, 07:39 PM
Last Post: Reddwarf
  PostProcessing not running, recording marked as recording service not running Reddwarf 12 3,625 2015-05-24, 11:20 PM
Last Post: sub

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode