digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Avisynth: add subtitles with the new adaptive script? (http://www.digitalfaq.com/archives/avisynth/3983-avisynth-add-subtitles.html)

audioslave 06-14-2003 06:09 PM

Avisynth: add subtitles with the new adaptive script?
 
Hi guys!
I have a few movies that I need to encode with subtitles since they're french. What programs do I need to extract the subtitles and what filter is needed for adding them to the new script (for AviSynth 2.5*)? An exact walkthrough would be apreciated. Sorry if I have have missed any post describing this issue, but I have looked :wink: .

kwag 06-14-2003 08:49 PM

Hi audioslave,

You need Vobsub to extract the subtitles from your DVD. Then, you must add a line to your script AFTER the adaptive filters, so that the subs don't get blurred. Check the Vobsub docs regarding the use of the program.

-kwag

audioslave 06-15-2003 08:52 AM

Thanks kwag,
I figured it out after experimenting a few minutes. I put the VobSub line absolutely last in the script and it works like a charm! I only resized the subs to 75%, both horizontal and vertical, (image scaling) and changed the alignment (origin) to X=85 and Y=73 to get it correct :wink: . I find that these things are easiest to change directly in the *.idx file...

Jellygoose 06-15-2003 11:32 AM

Where did you get VobSub for 2.5x audioslave? And could you please post the script you used? Thank you!

audioslave 06-16-2003 01:35 PM

I have trouble with getting the subtitles in sync with the sound. They (the subs) seem to appear before someone actually say something :? . I have tried to change the "Time offset: 0" to "Time offset: 500" but nothing happens. The subtitles still appear on the exact same frame as they did before I changed the offset. What am I doing wrong :( ? Is there another way of delaying subtitles? I'm using VobSub to create the subs and, of course, the "VobSub()" command in the script. Please help me with this!

-audioslave

audioslave 06-16-2003 03:11 PM

Hi Jellygoose,

Here's the script I used:

Quote:

## DLL Section ##
#
LoadPlugin("C:\Program\AviSynth 2.5\plugins\MPEG2Dec3.dll")
LoadPlugin("C:\Program\AviSynth 2.5\plugins\Decomb.dll")
LoadPlugin("C:\Program\AviSynth 2.5\plugins\Undot.dll")
LoadPlugin("C:\Program\AviSynth 2.5\plugins\ASharp.dll")
LoadPlugin("C:\Program\AviSynth 2.5\plugins\STMedianFilter.dll")
#
####

## Defined Variables and Constants ##
#
MaxTreshold = 1.50
scd_trigger = 30 # Scene change trigger value.
nf = 0 # Current frame.
#
####

## Main section and static filters ###
#
MPEG2Source("D:\DVD Rips\Red Dragon\Red Dragon.d2v")
#
FieldDeinterlace()
#Telecide()
#Decimate()
#
Undot()
Limiter()
ASharp(2, 4)
BicubicResize(480, 430, 0, 0.6, 0, 1, 720, 574)
STMedianFilter(8, 32, 0, 0)
MergeChroma(blur(MaxTreshold))
MergeLuma(blur(0.2))
#
#

## Dynamic Linear Adaptive Filtering and Scene Change Detection ##
#
# ( Portions from AviSynth's manual ) - This will apply temporalsoften to
# very static scenes, and apply variable blur on moving scenes.
# We also assign a variable - and this is why a line break is inserted:

ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf > 2.5 ? ASharp( -(fmin((nf/30), 1)), 0 ) : \
TemporalSoften(2, 7, 7, 3, 2) ")

#
# Scene change detection ( kwag ) - If a scene change is detected, we
# blur heavily. This affects the scene before and the one after the
# scene change, thus providing a softer transition for the encoder instead
# of a sharp "spike".
# If it's not a scene change, then we just blur dynamically, depending on
# the action.

ScriptClip("nf > scd_trigger ? ASharp( -2,0) : ASharp(0,0) ")

#
#
#

LetterBox(56, 56, 4, 4) # Depends on situation. Use MovieStacker!
AddBorders(0, 73, 0, 73) # Depends on situation. Use MovieStacker!
Limiter()

#
#
## Functions ###

function fmin(float f1, float f2) {
return (f1<f2) ? f1 : f2
}

#
####
VobSub("D:\DVD Rips\Red Dragon\vts_01_0")
It's the same as the "Optimal Script" from June 14 - apart from the "VobSub()" line... One advantage of putting "VobSub()" last in the script is that you can put the subs on the widescrren borders of the movie :wink: !

I don't remember where I got VobSub for AviSynth 2.5x (terribly sorry :oops: !), but maybe there's a way for me to post it somewhere in this forum? I still have the original *.zip file... Perhaps I could mail it to you?

-audioslave

Boulder 06-17-2003 12:39 AM

Quote:

Originally Posted by audioslave
One advantage of putting "VobSub()" last in the script is that you can put the subs on the widescrren borders of the movie :wink: !

Actually you don't want to put them on the borders. The pure black borders compress extremely well, but if you put subs there, it will ruin the compression. Lots of sharp edges which will need lots of bits :idea:

audioslave 06-17-2003 02:48 AM

@Boulder

Yes, that's probably true, but if I put the subs on the actual movie area they will cover too much of the movie. That's only my opinion though...
I encoded "Red Dragon" with and without subs (with my previous posted "Letterbox()" parameters) and the CQ only changed ~0,2 units! Higher CQ value on the version without subs. That's quite acceptable don't you think?
Anyway, now I'm using the script from June 16. The one with "GripCrop()" instead of "Letterbox()"...

sh0dan 06-17-2003 03:54 AM

In general: Subs in movies should be avoided - but for VCD/SVCD there is no other way (that I know of).

When encoding subs: Try to put them in in a black area, as it will take up considerably less space here. The reason for this is motion estimation, which is suffering, when static text is placed on a moving background. Static text on a static background take up some space, but much less than compared to text on movie.

When encoding in general: Try to avoid black borders. Even a few pixels will compress worse than a border to border picture. Again this a because of motion estimation.

Boulder 06-17-2003 09:20 AM

Quote:

Originally Posted by sh0dan
When encoding subs: Try to put them in in a black area, as it will take up considerably less space here. The reason for this is motion estimation, which is suffering, when static text is placed on a moving background. Static text on a static background take up some space, but much less than compared to text on movie.

This is true, and I stand corrected. However, in my tests, the difference was very small, 18592857 bytes (subs on film area) vs. 18533161 bytes (subs on borders).

Quote:

When encoding in general: Try to avoid black borders. Even a few pixels will compress worse than a border to border picture. Again this a because of motion estimation.
This is not entirely true. Overscan blocks do increase compression. I did a small test on a clip from Monty Python's The Meaning of Life. Here's the script I used:

Code:

MPEG2Source("e:\temp\dvd-rip\python.d2v",idct=5)
Crop(10,82,-10,-86)

SimpleResize(480,416)
AddBorders(0,80,0,80)

#SimpleResize(464,416)
#AddBorders(8,80,8,80)

#SimpleResize(448,384)
#AddBorders(16,96,16,96)

#SimpleResize(432,384)
#AddBorders(24,96,24,96)

I tried different sizes of overscan blocks, from zero to 24 pixels. I resized the clip to get the AR error less than 2% in every case.

The results:

0 pixels: 19 979 667 bytes
8 pixels: 19 809 823 bytes
16 pixels: 18 646 548 bytes
24 pixels: 18 418 530 bytes

Here we can see that even 8-pixel borders increase the compression. When the borders fill one complete macroblock (16 pixels), the compression is quite big, as would be expected. My TV crops about 24 pixels off the sides and about 20 at the top and bottom at resolutions 480x576 and higher so I use 3 overscan blocks. At smaller resolutions, 2 overscan blocks do the trick.

sh0dan 06-17-2003 09:59 AM

@Boulder: Right! I was talking about clips with different sizes - but didn't make that clear in my post.

My point is just, that borders aren't free, if the picture size remains constant. Best compression is always achieved by compressing the smallest possible picture, without borders. If you crop off the borders from the letterboxed picture you are compressing, I'm sure you'll get smaller files.

So the borders are far from "free" - however the easier compression is quite likely to outweigh the wrong motion estimation, when parts of the picture gets cropped by the borders.

Boulder 06-17-2003 10:21 AM

I should have thought about that too, looks like we're both in the right :wink:

Your suggestion is what MPEG-4 people have to keep in mind, right? Give DivX/XviD small borders and it will kill the quality whereas in VCD/SVCD/XVCD/KVCD encoding the borders are your friends when used correctly.

GFR 06-18-2003 10:50 AM

Quote:

Originally Posted by sh0dan
In general: Subs in movies should be avoided - but for VCD/SVCD there is no other way (that I know of).

When encoding subs: Try to put them in in a black area, as it will take up considerably less space here. The reason for this is motion estimation, which is suffering, when static text is placed on a moving background. Static text on a static background take up some space, but much less than compared to text on movie.

When encoding in general: Try to avoid black borders. Even a few pixels will compress worse than a border to border picture. Again this a because of motion estimation.

Thanks for the tips :)

What about Vobsub's fade in/out feature for subs? Does it make it compress worse?

sh0dan 06-18-2003 12:26 PM

Fading will in most cases make it harder to compress.


All times are GMT -5. The time now is 05:41 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.