Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recording square video #20

Closed
sethroot opened this issue Feb 27, 2014 · 12 comments
Closed

Recording square video #20

sethroot opened this issue Feb 27, 2014 · 12 comments

Comments

@sethroot
Copy link

I'm having trouble configuring the recorder to capture and export video cropped to a square aspect ratio. Without expertise in AVFoundation I am having a hard time understanding whether this is currently possible to do. Is this currently a supported feature for iOS?

I can see that Issue #1 relates to this question but it was closed 7 months ago and the codebase has changed since that resolution. Specifically, it seems that the functionality associated with useInputFormatTypeAsOutputType has been rewritten.

I have tried to configure the recorder using the following methods without success:

  • camera.videoEncoder.outputVideoSize
  • camera.sessionPreset
  • [camera setActiveFormatThatSupportsFrameRate:width:andHeight:error:]

Any information on this matter would be greatly appreciated.

@dandoen
Copy link

dandoen commented Feb 28, 2014

I'm having a similar issue.

However, I'm using a fullscreen camera and have two black overlays on top & bottom for esthetic purposes. And I've been playing around with cropping to a square after the video has been recorded with the offset from top as high as my top overlay.

Specifically, in the showVideo method in SCViewController.m I've been playing around with cropping the videoUrl file with AVAssetWriter similar to this: http://stackoverflow.com/questions/17882871/how-to-crop-video-into-square-ios-with-avassetwriter

But to no avail. I'd appreciate any direction on this / advice on a more elegant solution.

@rFlex
Copy link
Owner

rFlex commented Feb 28, 2014

Hey I just fixed that, sorry about that. You can now set the outputVideoSize to the value you want, it will crop the video automatically if the aspect ratio is different than the input aspect ratio from your camera. Though there is still no way of choosing where it should crop, it will be centered automatically.

Could you guys confirm that it works so I can close this issue? Thanks a lot!

@sethroot
Copy link
Author

I'd be happy to, but I'm not seeing any new commits at this point. Can you double check that they were pushed?

@rFlex
Copy link
Owner

rFlex commented Feb 28, 2014

Crap. There you go.

@dandoen
Copy link

dandoen commented Feb 28, 2014

@rFlex thanks!
@sethroot mind sharing the code of the method you end up using?

@sethroot
Copy link
Author

@rFlex thank you! this is working as intended now.

@dandoen i just copy and pasted code from SCViewController in the iOS example project and specified the CGSize for camera.videoEncoder.outputVideoSize. one thing i can suggest is that you probably don't need to use black overlays if you simply set your camera.previewView to a UIView with square dimensions.

@rFlex rFlex closed this as completed Feb 28, 2014
@xhzengAIB
Copy link
Contributor

i will pull request fix this issue.

decapyre notifications@github.com于2014年3月7日星期五写道:

This appears to affect the outputVideo size as stated. How would you
record in square format? Like vine.


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-36906205
.

@rFlex
Copy link
Owner

rFlex commented Mar 6, 2014

You just have to set an outputVideoSize that has the same width and height
(640x640 for instance). Nothing else should be needed.

On Thu, Mar 6, 2014 at 6:43 PM, Jack notifications@github.com wrote:

i will pull request fix this issue.

decapyre notifications@github.com于2014年3月7日星期五写道:

This appears to affect the outputVideo size as stated. How would you
record in square format? Like vine.


Reply to this email directly or view it on GitHub<
https://github.com/rFlex/SCAudioVideoRecorder/issues/20#issuecomment-36906205>

.


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-36914767
.

@xhzengAIB
Copy link
Contributor

@rFlex
OK! thanks you, got it.

@bryanberger
Copy link

yep sorry, I figured this one out. Thanks guys!

@cerupcat
Copy link
Contributor

@rFlex do you know where I'd look if I wanted to try cropping the video from the top instead of the center?

@joshoconnor89
Copy link

#324

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants