ios - Iphone Rotate video within current frame -
hi having video of width = 720 height = 1280
so video in portait mode.
i want video rotate 90 degree. want rotated video inside same size of video 720,1280. yes video scaled , need type of rotation .
please check image before , after :
this mine code :
cgaffinetransform rotationtransform = cgaffinetransformmakerotation(degrees_to_radians(90.0)); cgaffinetransform rotatetranslate = cgaffinetransformtranslate(rotationtransform,400,320); [layerinst settransform:rotatetranslate attime:kcmtimezero];
you can use scaling, rotation , translation transform , concat each transform original asset transform. please try below code question
// here assettransform avassettrack preferred transform cgaffinetransform defaulttransfrom = assettransform; // rotate 90 degree cgaffinetransform rotatetransform = cgaffinetransformmakerotation( m_pi_2); //get scale factor of resized video float scalefactor = videosize.width/videosize.height; cgaffinetransform scaletransform = cgaffinetransformmakescale(scalefactor,scalefactor); // blank space @ bottom after rotation , scaling float blankspaceatbottom = (videosize.height-scalefactor*videosize.width); //increase y translation according scaling factor float ytranslation = blankspaceatbottom/2/scalefactor; cgaffinetransform translationtransform = cgaffinetransformmaketranslation(videosize.height,ytranslation); //concat transform cgaffinetransform finaltransform = cgaffinetransformconcat(cgaffinetransformconcat(defaulttransfrom,rotatetransform),translationtransform); finaltransform = cgaffinetransformconcat(finaltransform,scaletransform); //apply final transform layer instruction [layerinstruction settransform:finaltransform attime:kcmtimezero];
please let me know if need more clarification.
Comments
Post a Comment