BTW, your approach will leave the frames looking very wrong, which would be bad if you ran any filters on the video between colorspace conversions.
A better approach might be something like:
Code:
function YV12toYUY2(clip last) {
y = Tweak(sat=0, coring=false).ConvertToYUY2()
uy = UtoY()
vy = VtoY()
u = Interleave(uy, uy).AssumeFieldBased().Weave().ConvertToYUY2()
v = Interleave(vy, vy).AssumeFieldBased().Weave().ConvertToYUY2()
return YtoUV(u, v, y)
}
function YUY2toYV12(clip last) {
y = Tweak(sat=0, coring=false).ConvertToYV12()
u = UtoY().AssumeFrameBased().SeparateFields().SelectEven().ConvertToYV12()
v = VtoY().AssumeFrameBased().SeparateFields().SelectEven().ConvertToYV12()
return YtoUV(u, v, y)
}
which duplicates chroma samples instead of using blank ones (and is what I expected the internal ConvertToYV12() and ConvertToYUY2() to do).