Log in

View Full Version : Film to PAL conversion


sh0dan
27th November 2002, 09:08
A friend of my does a lot of FILM -> PAL conversion, for commercials, etc. He doesn't want to change the length of the material, so a speedup isn't possible. I would like to hear the best way of doing this.

My suggestion is something like:

vid = Avisource(24p.avi)
interleave(vid,vid) # 48 fps
ChangeFPS(50.0) # duplicates frames to reach 50fps
assumefieldbased()
even=selecteven().verticalreduceby2()
odd=selectodd().crop(0,0,0,-1).addborders(0,1,0,0).verticalreduceby2()
interleave(even,odd)
weave()

The crop/addborders is to get proper field alignment.

Is this the best method?

bb
27th November 2002, 09:34
Why not stay progressive instead of pseudo-interlaced?

vid = Avisource(24p.avi)
ChangeFPS(25.0) # duplicates frames to reach 25fps


bb

sh0dan
27th November 2002, 09:46
@bb: My thoughts was, that staying progressive would give a more visible jerk (approx. 1 frame = 1/25sec non-motion added per 24 frames), instead of fieldbased (approx. 1 fiels = 1/50sec non-motion added per 12 frames). It would seem to me that this would produce a much more fluid playback on TV.

bb
27th November 2002, 12:14
Hmm, true. You know that the best you can do is not to change anything and play at 25fps like PAL DVDs, but you said already that this is not an option.

I'm thinking if your above proposed step could be iterated. I mean, what if you treat the fields as if they were frames and interlace them once more, so that you simulate four fields instead of two (or even eight?).

bb

trbarry
27th November 2002, 15:56
A sneaky way would be to write a filter that looked at every group of 24 frames and duplicated the frame that was most like a still scene, a very fast motion scene, or (best) a scene change. If you didn't bother with any motion comp then the last 2 would look the same but a slow pan longer than 24 frames would still jerk.

It is probably the slow pans that really get you.

Or you could get real clever and skip insertions on the slow pans and wait for a scene change to add more than one frame. I don't think people can track motion quickly at scene changes, there is a moment of disorientation.

- Tom

sh0dan
27th November 2002, 16:22
Yes - it would require twopass, or else it would have to process blocks, where it computes n frames ahead.
Theoretically, a scene change could also be used for frame insertion, duplicating the last frame or the first frame before a scene change.

A good start could be to look at Donalds Dup-filter, which is excellent at detecting frame differences. Also very similar frames react very good at interpolation, so this might be a case where this could be useful - this will make slow pans appear quite fluid.
In my experience interpolation is bad for high motion, but works ok for slow motion.


A motion-estimation algorithm would of course be the best - it could even be used for interpolation.

Wilbert
28th November 2002, 15:59
What about the following script. Of course it is not as good as tbarry's suggestion. The main problem is that there's something wrong with the audio conversion (vdub crashes). Hakko thinks that the problem could be that there isn't enough audio samples in one way or another. I.e. at some point some samples from the end of the movie is discarded, and when we continue to access those corresponding video frames things go wrong.

Sh0dan, can you have a look at AssumeFPS(25,sync_audio=AudioReSync) to see whether it works properly. I also posted this as a bugreport on sourceforge a while back.

# mode have 3 valid values:
# 0 FILM speeded up to PAL (default)
# 1 FILM add field to PAL interlace
# 2 FILM add frame to PAL progressive
# In mode 1 and 2 FILM (and the audio) is speeded up to 24 fps [for maintaining synch. in case of 23.976 --> 24 conversion]
# and frames are added to obtain 25 fps.

function FILM2PAL(clip clip, int "mode", int "a")
{
m = default(mode, 0)
Assert( ((m==0)||(m==1)||(m==2)), "Wrong mode!")
Assert( (a==0)||(a==1), "Must the audio be converted or not!")
AudioSync=( (a==1) ? true : false)
clip1 = clip.AssumeFPS(24,sync_audio=AudioSync)
clip2 = (m==1) ? clip1.Separatefields.SelectEvery(48,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,22,25,24,27,26,29,28,31,30,33,32,35,34,37,36,39,38,41,40,43,42,45,44,47,46,47).Weave : (m==2) ? clip1.SelectEvery(24,0,1,2,3,4,5,6,7,8,9,10,11,12,12,13,14,15,16,17,18,19,20,21,22,23) : clip1
AudioReSync=((a==1)&&(m==0))?true:false
return clip2.AssumeFPS(25,sync_audio=AudioReSync)
}

Wilbert
4th December 2002, 10:50
Sorry for the late response. Result was that the functions are very similar. I got the feeling you already knew that:

# differences frames: 11, 23, 36, 48, ...
# video = AviSource("F:\test4\clip_film.avi")
# subtract(film2pal_2(video), film2pal(video,1,0))

# differences frames: 23, 48, 73, 98, ...
# video = AviSource("F:\test4\clip_film.avi")
# subtract(film2pal_2(video), film2pal(video,1,0)).separatefields

vid = AviSource("F:\test4\clip_film.avi").showframenumber
stackvertical(film2pal_2(vid), film2pal(vid,1,0)).separatefields
# 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,
# 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52
# film2pal_2:
# 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,23,26,25,28,27,30,29,32,
# 31,34,33,36,35,38,37,40,39,42,41,44,43,46,45,48,47,48,49,50
# film2pal:
# 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,21,24,23,26,25,28,27,30,29,32,
# 31,34,33,36,35,38,37,40,39,42,41,44,43,46,45,46,47,48,49,50

My conclusion is that the quality of both functions are the same, and it doesn't matter which one you use.