Encommander @ wiki
TIPS
最終更新:
encom
-
view
ファイル分割
知人からのリクエストに応えたんですが、有用な方はどうぞ。バッチファイルコマンドを使ってるので判りにくいですが^^;
<Title>SPLIT:分割</Title> <Pre> lmt = 1 * 1024^3 spl = if_( #lmt# < #FileSize#, 1, int( #FileSize# / #lmt# / 0.9 ) +1 ) dur1 = int( secoftime( "#Duration#" ) / #spl# ) +1 </Pre> <Command> setlocal if #spl# == 1 goto end set cnt=1 :split set /a ss=#dur1#*(cnt-1) ffmpeg.exe -ss %ss% -t {{#dur1#+5}} -y -i "#InputFile#" -vcodec copy -acodec copy "#FilePath##FileName#_%cnt%.#Extension#" @echo count: %cnt% / #spl# if %cnt% == #spl# goto end set /a cnt=cnt+1 goto split :end endlocal </Command>
- 動画ファイルを「lmt」の数値(byte)をファイルサイズ制限として分割します。この例ではlmt=1GBです。「lmt = 1 * 1024^3」を「= 4 *」にしたら4GB、「* 1024^2」にしたら1MBとなります。
- 例えば60分の動画で1.3GBだったとしたら、1.3G ÷ 1GBの90%(安全率?)=1.444、切り上げで「2」という分割数が決定します。安全率を入れる理由は、単純に時間分割する為、ギリで分割すると制限値を超える可能性が大だからです。
- 分割するのはエンコード後のファイルになるケースが多いかなと思い、出力ファイルは入力ファイルと同じフォルダに作られます。
- 分割後の動画は入力動画のファイル名の後ろに「_1」「_2」といった連番が付きます。繋ぎ目は5秒間ラップするようになってます。
- MP4Boxを使う方が簡単ですが、MP4Boxのsplitは元動画のビデオプロファイルと全く同じになるとは限らないようなんで、ffmpegを利用してます。
PSP向け設定の例
- 11/23 abのとこを修正しました
- 11/23 aspのとこを修正しました
- 11/25 -deinterlaceを判定式にしました
- 11/25 サムネイル切り出しを修正しました
<Title>PSP:向け</Title> <Choose>psp;PSP</Choose> <Pre> ct = Even( #V_CropTop# ) cb = Even( #V_CropBottom# ) cl = Even( #V_CropLeft# ) cr = Even( #V_CropRight# ) vw = min( 480,even( #V_Width# - #cl# - #cr# ) ) vh = min( 272,even( #V_Height# - #ct# - #cb# ) ) b = round( ( #vw# + #vh# ) * 0.7 ) asp = round( ( #V_Width#-#cl#-#cr# ) / ( #V_Height#-#ct#-#cb# ) * #V_PAR# , 3 ) di = if_("#V_ScanType#"="Interlaced","-top 1 -deinterlace","") ab = if_( #A_BitRate# = 0, 128, min( 128, int( #A_BitRate# / 1024 ) ) ) ss = min( 60, int( secoftime( "#Duration#" ) / 2 ) ) </Pre> <Command> ffmpeg -y -i "#InputFile#" #di# -croptop #ct# -cropbottom #cb# -cropleft #cl# -cropright #cr# -s #vw#x#vh# -aspect #asp# -r 30000/1001 -vcodec libx264 -b #b#k -crf 25 -g 230 -mbd 2 -me_method umh -subq 6 -qdiff 6 -me_range 32 -sc_threshold 65 -keyint_min 3 -nr 100 -qmin 12 -flags bitexact+alt+mv4+loop -flags2 bpyramid+wpred+mixed_refs -partitions parti4x4+partp4x4+partp8x8 -f mp4 -acodec libfaac -ac 2 -ar 48000 -ab #ab#k -sn -coder 1 -level 30 -threads 4 "#OutPath##FileName#.mp4" ffmpeg -y -i "#InputFile#" -ss #ss# -croptop #ct# -cropbottom #cb# -cropleft #cl# -cropright #cr# -f image2 -pix_fmt jpg -vframes 1 -s 160x{{int(160/#asp#)}} -qscale 1 -qmin 1 -qmax 1 -an "#OutPath##FileName#_p.jpg" </Command>
すいませんオプションの詳しい解説不可w。こちらを参考にしました。
iPod向け設定の例
<Title>iPod:5.5G_ワイドテレビ表示</Title> <Choose>ipod;IPOD;iPod</Choose> <Pre> ct = Even( #V_CropTop# ) cb = Even( #V_CropBottom# ) cl = Even( #V_CropLeft# ) cr = Even( #V_CropRight# ) vw = min( 640,even( #V_Width# - #cl# - #cr# ) ) vh = min( 480,even( #V_Height# - #ct# - #cb# ) ) b = #vw# + #vh# asp = round( ( #V_Width#-#cl#-#cr# ) / ( #V_Height#-#ct#-#cb# ) * #V_PAR# * 0.75, 3 ) di = if_("#V_ScanType#"="Interlaced","-top 1 -deinterlace","") ac = if_( "#A_Format#"="AAC" and #A_BitRate# < 140000, "-acodec copy", "-acodec libfaac -ar 44100 -ab 128k" ) </Pre> <Command> ffmpeg -y -i "#InputFile#" #di# -croptop #ct# -cropbottom #cb# -cropleft #cl# -cropright #cr# -s #vw#x#vh# -r 30000/1001 -aspect #asp# -b #b#k -maxrate {{int(#b#*1.3)}}k -flags bitexact -vcodec libx264 -coder 0 -level 30 -qmin 18 -qmax 51 -bufsize 1024kb -me_method epzs -me_range 16 -subq 8 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor -0.8 -qcomp 0.5 -qdiff 3 -flags2 +fastpskip #ac# -threads 0 "#OutPath#temp.mp4" NicMP4Box -add "#OutPath#temp.mp4" "#OutPath##FileName#.mp4" del "#OutPath#temp.mp4" </Command>
色々織り込んでみました。
- これが必要になります→NicMP4BOX ダウンロードして圧縮フォルダ内の「NicMP4BOX.exe」をEncommanderフォルダにコピーしてください。
- 「-deinterlace」は_「V_ScanType」がInterlacedかどうかで入れる判断をします。
- オーディオは元動画のA_FormatがAACで140000bps以下ならコピーされます。
- 「NicMP4Box.exe」が必要になります。新しいiPodやiPhoneならいらないのかな?
- 「asp = ~ * 0.75 ~」の0.75がキモですw