NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Add-ons (3rd party plugins, utilities and skins) Old Stuff (Legacy) GB-PVR Support (legacy) v
« Previous 1 … 343 344 345 346 347 … 1231 Next »
transcoding techniques

 
  • 0 Vote(s) - 0 Average
transcoding techniques
zaprat
Offline

Member

Posts: 59
Threads: 33
Joined: Dec 2005
#1
2008-03-30, 03:34 PM
I had a look around for automated transcoding solutions and found them to either overkill:eek: or underkillSad, hence this is what I came up withRolleyes.

It uses the following steps

Step 1. - postprocessing.bat to write recorded filename to a file containing a a list of files for processing. This is referred to as the queue.

Code:
@echo "%~1" >> "c:\batch\transcode.txt"

Step 2. - run a batch file at low priority at scheduled time using scheduler. The scheduler to abort the batch after ? number of hours.

batch is called with:
Code:
%windir%\system32\cmd.exe /c start "transcodeit3" /min /low "C:\batch\transcodeit3.cmd"

Step 3. the batch will loop through each file in the queue and process it;

Code:
cd "%_mplayerpath%"
copy "%_quepath%transcode.txt" "%_quepath%transcode.tmp"
for /f "delims==" %%a in ('type ^"%_quepath%transcode.tmp^"') do call :process %%a
del "%_quepath%transcode.tmp"
goto :eof

Step 4 - check to see if the in or out files exist
Code:
:process
@echo %date% %time% "MESSAGE:processing %~1" >> "%_logpath%transcode.log"
if not exist "%~1" @echo %date% %time% "ERROR:%~1 not found;abort transcode" >> "%_logpath%transcode.log" & goto :failed
if exist "%~dpn1.avi" @echo %date% %time% "ERROR:%~dpn1.avi already exists;abort transcode" >> "%_logpath%transcode.log" & goto :failed
if exist "%~dpn1.new.avi" @echo %date% %time% "WARNING: %~dpn1.new.avi already exists;try again..." >> "%_logpath%transcode.log"

Step 5. - determine the crop size and scale size. First get the length and divide by 20. Then using mencoder, step through first frame of each of the 20 blocks to determine the optimum crop size. The scale size auomatically determined to be aspect and divisible by 16. This is what the :-10 does.

Code:
:identifyit
"%_mplayerpath%mplayer.exe" "%~1" -msglevel all=0:identify=6 -vo null -frames 1 > "%_logpath%%~n1.info"
FOR %%p in ("ID_") DO (
       FOR /f "usebackq tokens=1*" %%g in (`findstr %%p "%_logpath%%~n1.info"`) DO SET "%%g %%h"
)
@echo %date% %time% "MESSAGE:length is %ID_LENGTH%" >> "%_logpath%transcode.log"
set /A _showlength=%ID_LENGTH%
set /A _steps=_showlength / 20
"%_mplayerpath%mplayer.exe" "%~1" -vf cropdetect -nosound -vo null -frames 20 -sstep %_steps%  > "%_logpath%%~n1.crop"

FOR /f "usebackq tokens=5-8 delims==:^)" %%g in (`find ^"[CROP]^" ^"%_logpath%%~n1.crop^"`) DO (
    (set _cx=%%g:%%h:%%i:%%j)
    (set _sx=%%g)
    )
(set _crop=%_cx%)
(set _scale=%_sx%:-10)

Step 6. then run mencoder to transcode/process the files
Code:
"%_mencoderpath%mencoder.exe" "%~1" -vf pullup,softskip,pp=fd,crop=%_crop%,scale=%_scale%,hqdn3d,harddup -profile %_profile% -o "%~dpn1_new.avi"
if errorlevel 1 goto :failed

Step 7. if success, change the file name and delete the original; note the xml is about keeping the xml file stuff which is stored as a seperate stream by GB
Code:
:success
@echo %date% %time% "MESSAGE:transcode OK" >> "%_logpath%transcode.log"
more < "%~1:metadata.xml" > "%~dpn1_new.avi:metadata.xml"
move "%~dpn1_new.avi" "%~dpn1.avi"
del "%~1"
goto :cleanup

Step 8.
if transcode failed, just cleanup

Step 9. cleanup. remove the just processed file name from the queue file and delete temporary files.
Code:
:cleanup
@echo %date% %time% "MESSAGE:doing cleanup" >> "%_logpath%transcode.log"
find /v "%~1" < "%_quepath%transcode.txt" > "%_quepath%transcode.new"
del /q "%_quepath%transcode.txt"
move "%_quepath%transcode.new" "%_quepath%transcode.txt"
del /q "%~dpn1_new.avi"
del /q "%_logpath%%~n1.crop"
del /q "%_logpath%%~n1.info"
goto :eof

Does anyone having any further suggestions for improving it. Remember this is intended as strictly simplistic. Anything more complex, will defeat what I am trying to achieve,


Things I would like to do next:
- before processing, check if another instance of the batch is running and if so, abort.
- avoid scaling during transcoding, this should be done during decoding but most decoders dont seem do this properly with AVI files. I have tried using autoaspect parameter in mencoder but not sure if it is working?

Notes; what I like about this is;
if the transcoding fails it skips over it, and does not reattempt it.
If the transcoding is interupted (say a reboot), it will start again for that file to be processed.
It only deletes the file after the transcoding has been completed.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Automatic Transcoding Not Working taz 3 2,305 2010-11-22, 09:01 AM
Last Post: goelectric
  Transcoding dvr-ms to DivX and recording to Mpeg2 Boworr 23 11,109 2010-02-04, 07:54 AM
Last Post: LeCoux
  no transcoding in gb-pvr 1.4.7 alevideotestservice 6 2,865 2009-12-07, 11:15 PM
Last Post: alevideotestservice
  GBPVR + Vista Media Center + MCE remote - techniques? c128 5 8,147 2009-11-16, 05:47 PM
Last Post: StephaneM
  What has happened to the Manual Transcoding? Basher52 4 1,843 2009-09-21, 05:51 PM
Last Post: Basher52
  Some recordings created but not available after transcoding htewam 6 2,324 2009-09-18, 07:59 PM
Last Post: gEd
  Transcoding TS to AVI loses sound DrSoftware 2 2,099 2009-06-29, 08:28 PM
Last Post: serafis
  Transcoding, COMSKIP and the GPBVR database serafis 8 4,136 2009-06-15, 07:52 PM
Last Post: shadowze
  transcoding from avi medic29 0 1,127 2009-02-24, 03:19 AM
Last Post: medic29
  MVP transcoding error InVermont 2 1,430 2009-01-20, 01:25 AM
Last Post: InVermont

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

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

Linear Mode
Threaded Mode