On Jan 19, 2015, at 15:31 , Kevin Meaney <[email protected]> wrote:
>
> If I'm reading frames from a HD video, doing some processing of those frames
> and writing a HD video with those frames there is a good chance input and
> output are using the same profile. When that is the case I'd like not to do
> unnecessary color space conversions.
“HD video” is too unspecific to make it knowable whether color conversions are
needed.
The heart of the matter is “doing some processing of those frames”. The primary
consideration is what pixel format that implies. The colorspace is a secondary
consideration. (If you’re asking AVFoundation to convert between pixel formats,
colorspace conversion is probably not what’s going to limit your performance,
or image fidelity, anyway.)
Assuming you are using an asset reader and an asset writer, as described in the
AVFoundation Programming Guide:
https://developer.apple.com/library/mac/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/05_Export.html
<https://developer.apple.com/library/mac/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/05_Export.html>
then you can configure both the asset reader and the asset writer to do no
conversions (pass ‘nil’ for the relevant “outputSettings” parameters), but if
that means the pixel buffers appear in a format you can’t use (such as YCrCB,
perhaps), then that’s no help. If you need ARGB, you’re going to have to do a
pixel format conversion, and that may *require* color information such as
whether the data is R.601 or R.709. But you need to know what the input is, in
order to know what to tell AVFoundation to do.
You may be able to deduce this knowledge from the video itself, or you may have
to find out externally. (For an example of how precarious this is, Blu-ray
video uses YCrCb, but the color conversion is R.709 or R.601 according to the
frame size of the video — 720p and up is HD, smaller frame sizes are SD. You
wouldn’t know this unless you know this. And kittens.)
I suggest you work through the re-encoding sample code in the above-linked
document. Remove all the stuff you definitely don’t need, and see how close you
are to your goal.
One final, additional caution: Even though AVFoundation has all those
definitions for pixel formats, that doesn’t necessarily mean it can convert
between all combinations. In my case, I actually had AYCrCb data, but
AVFoundation was not able to encode H.264 with an alpha channel. I was forced
to use a ProRes format to get the alpha channel. You may end up doing a pixel
format conversion simply because AVFoundation can’t get from point A to point B
in one step.
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]