问题
Is it possible to crop the video by dimension and play only cropped portion programmatically? For an example, I have 100x100 full video but I want to play only (0,0) to (25,25) portion of this video. How could I do it?
Basically I am trying to implement something similar to matrix of iPads video available here.
回答1:
Number of options here - since you generally play video back in a view, you can attempt to use the standard UIView
content scaling modes along with the specific movie scaling mode additions to MPMoviePlayerController
to try and mask correctly. You can imagine how you could set the movie to MPMovieScalingModeFill
, set the view's frame to double that of your video's dimensions, and then adjust the origin position accordingly.
Or you could mask it using other views, or even go quite low level and try something a little more complex (my approach above talks about MPMoviePlayerController
, because it's the highest level and easiest way to play a video back. But there are other options that give you more control).
来源:https://stackoverflow.com/questions/8387756/ipad-crop-the-video-and-play-cropped-portion-only