Thread: tff to bff with avisynth

1. Is it easy to convert from TFF to BFF with AviSynth? Is the avs script below a proper way to convert from tff to bff?
Code:
LoadPlugin("drive:\path\to\DGDecode.dll")
MPEG2Source("drive:\path\to\dgindex project.d2v")
AssumeTFF
SeparateFields()
Trim(1, 1000) # from a total of 1000 frames
Weave()
AssumeBFF
Or there is a better way to convert from tff to bff than the method in the above avs script?
2. No. Your sample is not correct. It doesn't change the physical relationship of interlaced fields, it changes only the way an editor or player reads the field order.

Why ?
3. Gonna have to disagree. The posted script implements the SeparateFields().Trim(1,0).Weave() method which does alter the image and not just the metadata. Note, codemaster, that "0" at the end of the Trim command lets you select the last frame of the video without cutting anything.

Are you doing this to align out-of-phase 25i material?
4. I disagree again. If the original field order was really BFF, the results of the routine are an incorrect alteration. The original file doesn't change unless it is overwritten with the new data -- and it's rather difficult with many operating systems to read and write to the same file at the same time. The O.P. didn't say whther a desired correction was being made, therefore my post ended with: "Why?".
5. That script will convert a TFF video to BFF. Another method is to shift the frame up (or down) by one scan line:

Code:
# YUY2 or RGB video
Crop(0,1,-0,-0) # remove top scan line
AddBorders(0,0,0,1) # add one scan line to the bottom
But that doesn't work with YUV 4:2:0 sources, they have to be converted to YUV 4:2:2 or 4:4:4 (or RGB 4:4:4) first, incurring some blurring of the colors:

Code:
# TFF (or BFF) interlaced YV12 video
ConvertToYUY2(interlaced=true)
Crop(0,1,-0,-0) # remove top scan line
AddBorders(0,0,0,1) # add one scan line to the bottom
# TFF converted to BFF (or BFF converted to TFF)
ConvertToYV12(interlaced=true)
6. That's what I was trying to get at. Thanks for the code. I looked everywhere.
7. Originally Posted by sanlyn
Why ?
Because I'm trying to edit a DVD in a NLE such as Premiere or Vegas, and the most popular solution seems to be to transcode to DV, and since standard DV is BFF, I wanted to know how to properly convert from tff to bff, in avisynth, so that I can transcode to DV bff with ffmpeg, using the avs script as input.

I could leave it TFF and transcode to lossless Lagarith, but that means I'll have to use this:
Code:
Levels(0, 1, 255, 16, 235, coring=false)
which reduces the contrast considerably.

I could leave it TFF and not transcode it, but with mpeg 2 clips in Vegas Pro 8, scrubbing is very slow, ram usage is so high that there is not enough ram left for rendering, project opens too slow. And Premiere Pro CS3 accepts the mpeg 2 files, scrubbing is fast, but project opens too slow, some frames have weird green and red artifacts, and Premiere never stops conforming the mpeg files.

Therefore, I arrived at the following conclusion:
- for editing DVD in a NLE on Windows, DV is the best codec to transcode to;
- for editing AVCHD in a NLE on Windows, DNxHD is the best codec to transcode to;
8. Originally Posted by codemaster
I could leave it TFF and transcode to lossless Lagarith, but that means I'll have to use this:
Code:
Levels(0, 1, 255, 16, 235, coring=false)
Why would you have to do that? You should be able to leave the levels just as they are.
9. If I leave the levels just as they are, some detail in the high tones (or superwhites) will be lost. If I transcode to DV, I can recover detail in premiere, by using the fast color corrector to lower the high tones until they reach 100% or 1.0v on the yc waveform. There is something in those superwhites that can be recovered. If I add
Code:
Levels(0, 1, 255, 16, 235, coring=false)
before compressing to lagarith, detail in the superwhites is recovered, but contrast is lowered too much. If I don't add
Code:
Levels(0, 1, 255, 16, 235, coring=false)
in the avs script before compressing to lagarith, contrast is not lowered, but detail in the superwhites is deleted by premiere, and can't be recovered.
10. Originally Posted by codemaster
If I leave them just as they are, some detail in the high tones (or superwhites) will be lost. If I transcode to DV, I can recover detail in premiere, by using the fast color corrector to lower the high tones until they reach 100% or 1.0v on the yc waveform. There is something in those superwhites that can be recovered. If I add
Code:
Levels(0, 1, 255, 16, 235, coring=false)
before compressing to lagarith, detail in the superwhites is recovered, but contrast is lowered too much. If I don't add that line in the avs script before compressing to lagarith, contrast is not lowered, but detail in the superwhites is deleted by premiere, and can't be recovered.
That must be a Premiere issue then. Why don't you leave the black level where it is and just reduce the brights? Something like ColorYUV(gain_y=-20) or Levels(0,1,255,0,235, coring=false).
11. I tried
Code:
Levels(0, 1, 255, 0, 235, coring=false)
and contrast is normal now, but there are some vertical lines in the waveform.

This is without the levels correction:

And this is with levels correction:

Those vertical white lines, ar they indicating a problem ?
12. You're reducing 256 integer values to 236 integer values. There has to be some duplicates in the result. That's what those lines are. You can use SmoothLevels() instead of Levels() to add a little dithering to the results. SmoothLevels() is part of the SmoothAdjust package.
13. levels has a dither=true parameter now in avisynth 2.6.x , works similar to smoothlevels

Levels(0, 1, 255, 0, 235, coring=false, dither=true)
14. Originally Posted by poisondeathray
levels has a dither=true parameter now in avisynth 2.6.x
Thanks for the update.
15. Originally Posted by poisondeathray
levels has a dither=true parameter now in avisynth 2.6.x ...
Yeah, thanks from me too. I didn't know that and I have a project at the moment where I can use that new feature.

Statistics