http://forum.doom9.org/showthread.php?t=144271
このスクリプトを改造した。
オリジナルは8mmフィルムレストア用なので、そのまま使うとシャープが強すぎて再生速度も変わる。
モーションデータはMVToolsの方が精度が高いけれども、処理が遅いのでDePanEstimateを使う。
手順
1.dvgrabでキャプチャしたdvファイルをkinoでトリミング書き出し。音声だけも書き出し。
2.avisynthに読ませるために、無圧縮aviに変換。
$ mencoder キャプチャしたファイル名.dv -nosound -ovc raw -vf format=yuy2 -o avisynthに読ませるファイル名.avi
3.avsスクリプトを実行。
$ wine avs2yuv.exe スクリプト名.avs - | mencoder - -o 処理されたファイル名.avi -ovc lavc -lavcopts vcodec=ffvhuff:vstrict=-1:pred=2:context=1 -demuxer y4m
4.書き出しておいた音声とavsスクリプトを実行された動画を合成。
$ ffmpeg -i 切り出し音声.wav -i 処理されたファイル名.avi -target ntsc-dv -|ffmpeg2theora - -x 720 -y 202 -o 書き出すファイル名.ogg #アップロードする時
$ ffmpeg -i 切り出し音声.wav -i 処理されたファイル名.avi -target ntsc-dv dvファイル名.dv #dvにする時
5.avsファイルの拡張子をshに変えてhiglightで色分けHTMLで書き出し。
$ highlight -J 80 -z -n -l -W -t -s ide-msvs2008 -i avsファイル.sh -o 書き出し.html
<p>test.sh</p>
- # film restoration script by videoFred.
- # denoising, resizing, stabilising, sharpening, auto-levels and auto-white
- balance.
- #===========================================================================
- =========
- film="/home/poi/ex1.avi"
- #GENERAL PARAMETERS
- #---------------------------------------------------------------------------
- -------------------------------------------------
- result="resultS5" # specify the wanted output here
- #COLOR AND LEVELS PARAMATERS
- #---------------------------------------------------------------------------
- -------------------------------------------------
- saturation=1.4 #for all outputs
- gamma=1.2 # for all outputs
- blue= -0 red=-0 #manual color adjustment, when returning result3. Values
- can be positive or negative
- black_level=0 white_level=255 output_black=0 output_white=255 # manual
- levels, when returning result4
- #SIZE, CROP AND BORDERS PARAMETERS
- #---------------------------------------------------------------------------
- -------------------------------------------------
- CLeft=20 CTop=20 CRight=20 CBottom=20 #crop values after Depan and
- before final resizing
- W=720 H=404 #final size after cropping
- bord_left=0 bord_top=0 bord_right=0 bord_bot=0 #720p= borders 150
- #STABILISING PARAMETERS
- #---------------------------------------------------------------------------
- -------------------------------------------------
- maxstabH=30
- maxstabV=30 #maximum values for the stabiliser (in pixels) 20 is a good
- start value
- est_left=40 est_top=40 est_right=40 est_bottom=40 est_cont=1.6 #crop
- and contast values for special Estimate clip
- #DENOISING PARAMETERS
- #---------------------------------------------------------------------------
- -------------------------------------------------
- denoising_strenght=600 #denoising level of first denoiser: MVDegrainMulti()
- denoising_frames= 2 #number of frames for averaging (forwards and
- backwards) 3 is a good start value
- block_size= 16 #block size of MVDegrainMulti()
- block_size_v= 16
- block_over= 8 #block overlapping of MVDegrainMulti()
- second_denoising_strenght= 400 #denoising level of second denoiser:
- MDegrain1()
- temp_radius=4 temp_luma=3 temp_chroma=3 #final smoother: TemporalSoften()
- #FOUR STEP SHARPENING PARAMETERS
- #---------------------------------------------------------------------------
- -----------------------------------------------------
- PRE_sharp_ness= 120 PRE_radi_us= 3 #presharpening (UnsharpMask) just
- after first denoising
- LSF_sharp_ness=160 LSF_radi_us=2 LSF_sub=1.5 #second sharpening parameters
- (LimitedSharpenFaster) sub=subsampling
- USM_sharp_ness2= 50 USM_radi_us2=1 USM_thres_hold2=0 #third sharpening
- parameters (UnsharpMask)
- last_sharp= 0.5 # final sharpening step after interpolation
- mo_blur= 10 #this will add some motion blur, can be useful in panning
- scenes etc..
- #AUTO LEVELS PARAMETER
- #---------------------------------------------------------------------------
- -----------------------------------------------------
- X=4 # X is a special parameter for reducing the autolevels effect on the
- whites
- X2=2 # X2 is a special parameter for reducing the autolevels effect on the
- blacks
- # END VARIABLES, BEGIN SCRIPT
- #===========================================================================
- ======================================================
- SetMemoryMax(800) #set this to 1/3 of the available memory
- LoadPlugin("GuavaComb.dll")
- LoadPlugin("TDeint.dll")
- LoadPlugin("AGC.dll")
- LoadPlugin("Deflicker.dll")
- Loadplugin("Depan.dll")
- LoadPlugin("DepanEstimate.dll")
- Loadplugin("removegrain.dll")
- LoadPlugin("MVTools.dll")
- LoadPlugin("MVTools2.dll")
- Loadplugin("mt_masktools.dll")
- Loadplugin("warpsharp.dll")
- LoadPlugIn("LimitedSupport_09Jan06B.dll")
- LoadPlugin("autolevels.dll")
- Import("LimitedSharpenFaster.avs")
- source0= Avisource(film).Lanczos4Resize(720,404).converttoYV12().TDeint()
- source1= Avisource(film).Lanczos4Resize(720,404).converttoYV12().TDeint()
- #STABILIZING
- #...........................................................................
- ............................................................................
- .............
- stab_reference= source1.crop(est_left,est_top,-est_right,-est_bottom).tweak(
- cont=est_cont).MT_binarize(threshold=80).greyscale().invert(
- )
- vectors = stab_reference.MSuper().MVAnalyseMulti()
- globalmotion = stab_reference.MVDepan(vectors)
- mdata=globalmotion
- stab2=DePanStabilize(source1,data=mdata,method=0,mirror=15,info=true,
- cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,rotmax=10)
- WS= width(stab2)
- HS= height(stab2)
- #DENOISING
- #...........................................................................
- ............................................................................
- ............
- noise_baseclip= stab2.HDRAGC( min_gain = 3.0,avg_window=30,corrector=1,
- debug=0,coef_sat=2)
- #SHARPENING
- #...........................................................................
- ............................................................................
- ............
- sharp1=limitedSharpenFaster(noise_baseclip,smode=1,strength=LSF_sharp_ness,
- overshoot=50,radius=LSF_radi_us, ss_X=LSF_sub, SS_Y=LSF_sub,
- dest_x=W,dest_y=H)
- #RESULT5: SPECIAL SERVICE CLIP FOR RESULT S5
- #...........................................................................
- ............................................................................
- ..............
- result6= sharp1.ConvertToYUY2().GuavaComb(mode="NTSC").converttoYV12()
- #COMPARISONS: ORIGINAL VS RESULTS
- #...........................................................................
- ............................................................................
- ...............
- resultS5= stackhorizontal(subtitle(source0,"original",size=56,align=6),
- subtitle(result6,"stabiliser+AGC.dll",size=56,align=6))
- Eval(result)