查看完整版本: MC使用AviSynth脚本的方法(中文,带图)有字幕问题的都进来看

warwar 2008-6-23 23:35

MC使用AviSynth脚本的方法(中文,带图)有字幕问题的都进来看

[font=宋体][size=3][color=#000000]MC的功能很强大,但过去对字幕的支持主要是SRT字幕比较完善,所以经常有各位朋友上论坛来问字幕的问题,现在MC开发了AVS脚本支持功能,熟悉AVS脚本的朋友都知道,这个是各大字幕组的必备工具,想挂各种各样的字幕吗?想字幕挂出花样来吗?学下AVS脚本吧。基本你能想到的效果AVS脚本都能实现。至此,MC对字幕的支持度上了一个全新的台阶,再问怎么加载字幕已经是不必要的了。只要你熟悉AVS脚本写法,字幕想怎么挂就怎么挂![/color][/size][/font]
[font=宋体][size=3][color=#000000][/color][/size][/font]
[font=宋体][size=3][color=black]以下内容来自hiphoper的博客,我翻译为中文,帮助国内用户使用MC的AVS脚本功能。具体AVS脚本语法自己上网去搜索学习。翻译基于意译,根据中文习惯做了修改,虽然与英文原文并不是每一个字都对应,但要表达的意思都表达清楚了,且读起来更加流畅。这个也是我翻译的原则。我痛恨“音译”及死板的逐字翻译,那样翻译出来的文章根本就看不懂。[/color][/size][/font]

[size=3][color=#000000][font=宋体]正如同大家了解的一样,[/font][font=Times New Roman]MediaCoder[/font][font=宋体]自带了视频转换所需要的各种组件,运行时不需要操作系统中再安装相应的各种视频分离器、解码器、过滤器。然而,在某些情况下(如挂ASS字幕,挂双字幕等),为了实现特定的目的,我们确实需要利用到系统中安装的各种解码器包等工具。[/font][font=Times New Roman]AviSynth[/font][font=宋体]就是用来连接安装在系统中的分配器[/font][font=Times New Roman]/[/font][font=宋体]解码器[/font][font=Times New Roman]/[/font][font=宋体]过滤器和多媒体转换[/font][font=Times New Roman]/[/font][font=宋体]应用的一座桥梁。在[/font][font=Times New Roman]MediaCoder[/font][font=宋体]中,有两种方法使用[/font][font=Times New Roman]AviSynth[/font][font=宋体]。当然,作为一个先决条件,您需要事先安装[/font][font=Times New Roman]AviSynth[/font][font=宋体]和可能用到的编解码器包(如[/font][font=Times New Roman]K-lite[/font][font=宋体]),其中就包含了一些我们可能用到的分离器和解码器。[/font][font=Times New Roman] [/font][/color][/size]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[size=3][color=#000000][font=宋体]第一种方法:直接将[/font][font=Times New Roman]AviSynth[/font][font=宋体]脚本添加进[/font][font=Times New Roman]MediaCoder[/font][/color][/size]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[size=3][color=#000000][font=宋体]这是一种很简单的方法。先手写出你要使用的脚本,并将这个脚本当作一个正常的媒体文件加载进[/font][font=Times New Roman]MediaCoder[/font][font=宋体]让它转换。此时媒体信息栏显示的信息(如解析信息,帧率,封装等)可能并不符合实际情况,而是将始终显示一样的信息,如[/font][font=Times New Roman]rawyv12[/font][font=宋体]和[/font][font=Times New Roman]PCM [/font][font=宋体],因为[/font][font=Times New Roman]AviSynth[/font][font=宋体]同时兼顾了解码和后处理,而[/font][font=Times New Roman]MediaCoder[/font][font=宋体]只看到[/font][font=Times New Roman]yuv[/font][font=宋体]和[/font][font=Times New Roman]PCM[/font][font=宋体]的数据。[/font][font=Times New Roman] [/font][/color][/size]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[size=3][color=#000000][font=宋体]下面举一个例子,我们打开“附件”-“记事本”写一个脚本,保存为[/font][font=Times New Roman]example.avs [/font][font=宋体]。脚本内容如下:[/font][font=Times New Roman] [/font][/color][/size]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]DirectShowSource(”F:\Video\Sample\tmnt-tlr1_h1080p.mov”)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]# crop a 4:3 square from the original 16:9 screen[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]Crop(416, 0, 1088, 816)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]# resize the dimensions of the video frame to 320×240[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]LanczosResize(320, 240)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]# TemporalSoften is one of many noise-reducing filters[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]TemporalSoften(4, 4, 8, scenechange=15, mode=2)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]# increase the gamma (relative brightness) of the video[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]Levels(0, 1.2, 255, 0, 255)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]# fade-in the first 90 frames from black[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]FadeIn(90)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]# fade-out the last 15 frames to black[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]FadeOut(15)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[size=3][color=#000000][font=宋体]也许我们实际要转换的源文件分辨率是[/font][font=Times New Roman]1920 [/font][font=宋体]×[/font][font=Times New Roman] 816 [/font][font=宋体],但[/font][font=Times New Roman]MediaCoder[/font][font=宋体]显示“[/font][font=Times New Roman] 320 [/font][font=宋体]×[/font][font=Times New Roman] [/font][font=Times New Roman]240 [/font][font=宋体]”[/font][font=宋体]。这是正常的,因为脚本中出现了这样的数据。其他资料的显示也会出现同样的情况,但这些都是正常的,请不要以为是[/font][font=Times New Roman]BUG[/font][font=宋体],不用理会这些显示的属性信息。[/font][/color][/size]
[size=3][color=#000000][font=宋体]脚本写完后保存为一个[/font][font=Times New Roman]AVS[/font][font=宋体]文件,我们将它拖进[/font][font=Times New Roman]MediaCoder [/font][font=宋体]。剩下的转换工作设置操作过程与大家平时转换普通视频是一样的。[/font][/color][/size]
[font=Times New Roman][size=3][color=#000000][img]http://mediacoder.cn/images/blog/mc-avs-tutor-1.png[/img][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[size=3][color=#000000][font=宋体]第二种方法:直接在[/font][font=Times New Roman]MC[/font][font=宋体]中使用[/font][font=Times New Roman]AviSynth[/font][font=宋体]脚本模板[/font][/color][/size]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[size=3][color=#000000][font=宋体]这是一个新的[/font][font=Times New Roman]AviSynth[/font][font=宋体]脚本使用方法,且使用更加简单,于[/font][font=Times New Roman]0.6.1.4115[/font][font=宋体]版本后开始支持。有时,我们同时转换的几个视频文件都会使用相同的脚本,这种情况下使用第二种方法也许更加简单。从[/font][font=Times New Roman]4115[/font][font=宋体]版本开始,新增了一个[/font][font=Times New Roman]AviSynth[/font][font=宋体]标签,作为功能的扩充。[/font][font=Times New Roman] [/font][/color][/size]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font][attach]61311[/attach]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[size=3][color=#000000][font=宋体]若要使用[/font][font=Times New Roman]AviSynth[/font][font=宋体]脚本模板功能,我们需点击“[/font][font=Times New Roman]AviSynth [/font][font=宋体]”选项标签,勾选[/font][font=Times New Roman]“[/font][font=宋体]可能时使用[/font][font=Times New Roman]AviSynth[/font][font=宋体]来解码[/font][font=Times New Roman]”[/font][font=宋体]开启[/font][font=Times New Roman]AviSynth[/font][font=宋体]脚本功能。然后,用“记事本”程序创建一个[/font][font=Times New Roman]MC[/font][font=宋体]用的模板脚本。此模板脚本与正常的[/font][font=Times New Roman]AVS[/font][font=宋体]脚本语法基本一样,只是稍有改变,我们只是用变量[/font][font=Times New Roman]$(SourceFile)[/font][font=宋体]代替前面标准[/font][font=Times New Roman]AVS[/font][font=宋体]脚本中的待转换文件路径。下面写一个脚本举例:[/font][font=Times New Roman] [/font][/color][/size]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]DirectShowSource(”$(SourceFile)”)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]# crop a 4:3 square from the original 16:9 screen[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]Crop(416, 0, 1088, 816)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]# resize the dimensions of the video frame to 320×240[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]LanczosResize(320, 240)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]# TemporalSoften is one of many noise-reducing filters[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]TemporalSoften(4, 4, 8, scenechange=15, mode=2)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]# increase the gamma (relative brightness) of the video[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]Levels(0, 1.2, 255, 0, 255)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]# fade-in the first 90 frames from black[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]FadeIn(90)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]# fade-out the last 15 frames to black[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000]FadeOut(15)[/color][/size][/font]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[size=3][color=#000000][font=宋体]正如我们所看到的,[/font][font=Times New Roman]MC[/font][font=宋体]专用模板和标准[/font][font=Times New Roman]AVS[/font][font=宋体]脚本的唯一区别只在第一行。其他的语法都是一样的。在未来,针对[/font][font=Times New Roman]MC[/font][font=宋体]用的[/font][font=Times New Roman]AviSynth[/font][font=宋体]脚本模板,将会推出更多有用的专用变量名。[/font][/color][/size]
[font=Times New Roman][size=3][color=#000000][/color][/size][/font]
[size=3][color=#000000][font=宋体]将编写好的脚本模板保存为[/font][font=Times New Roman]XXX.avs[/font][font=宋体]文件,点击“使用脚本模板”,然后就可以加载刚才编好的[/font][font=Times New Roman]AVS[/font][font=宋体]脚本模板。接下来,我们就可以将待转换的媒体文件添加进[/font][font=Times New Roman]MC[/font][font=宋体],然后和以前一样开始转换。你也可以尝试使用“自动生成脚本”功能,[/font][font=Times New Roman]MediaCoder[/font][font=宋体]会自动生成一个与当时选定的文件相配套的[/font][font=Times New Roman]AVS[/font][font=宋体]脚本。希望你能喜欢此功能。[/font][/color][/size]

[[i] 本帖最后由 warwar 于 2008-6-25 10:37 编辑 [/i]]

chriszxl 2008-6-24 00:44

AVS脚本语法基本一样,只是稍有改变???
哪有改变??想了半天..没想出名堂来..仔细读才发现更本就是一样吗...设了变量而已..
大家都会用AVS导入就无敌啦......解决了来源统一问题....

心灵震撼 2008-6-27 18:31

我实在太笨蛋了,根本就没弄会....

warwar 2008-6-28 23:57

回复 3# 的帖子

关于AVS脚本写法,可以参考下面3个链接,或者自己再上网搜索
[url]http://www.cnblogs.com/feison/archive/2006/12/26/604246.aspx[/url]
[url]http://hi.baidu.com/candysfm/blog/item/0c71443e61b4083e71cf6c43.html[/url]
[url]http://blog.ccmove.com/0413301/archive/437058.shtml[/url]
这个AVS脚本语法网络上有很多资料。
有些东西,多看几次,就明白了,AVS脚本其实看明白了的就知道很容易,那些脚本语法本身就由一些简单的英文单词改变而来的,你就看英文意思也能猜出来那句话是表达什么意思。
如果实在觉得太难,介绍个工具给你:
[url]http://www.ttant.com/downinfo/55.html[/url]
AVS脚本生成器
但是实际使用的时候,你最好是试着用用看,要想100%的控制,起码要能自己看得懂那些语法。

hiphoper 2008-6-30 22:38

AviSynth script template有点bug,最近会发update修复。

roozhou 2008-7-2 06:55

directshowsource不是frame accurate的,很多文件不是帧率不对就是时间不对,建议使用ffmpegsource。当然ffmpegsource有很多文件解不了。

hiphoper 2008-7-2 18:24

用ffmpegsource还不如不用avisynth呢,mediacoder直接可以调用ffmpeg解码。

xiaogui85122 2008-11-16 16:14

这个AVS和场的概念和什么东东看的我头昏脑胀

日月华光 2008-11-23 10:55

好帖,顶上去

yymyyma 2008-11-24 00:00

最近将一部50分钟左右的mp4影片转为xvid格式,以AVI为容器的影片后(也设置了sub字幕文件),字幕没有出现。
只能写了avs脚本如下
LoadPlugin("VSFilter.dll")
directshowsource("K:\1mp4")
textsub("K:\水印.ssa")
vobsub("K:\1.idx")

直接打开avs文件进行转换,ok了

mcguest 2008-11-28 21:05

建议增加字幕路径的变量名
页: [1]
查看完整版本: MC使用AviSynth脚本的方法(中文,带图)有字幕问题的都进来看