Comments (16)
Hi! I had the same issue and I think I have a solution to propose.
I added a new ARFrameMode
@objc public enum ARFrameMode: Int {
case auto
case aspectFit
/// Recommended for iPhone X
case aspectFill
case viewAspectRatio
}
And added this code to the bufferSize var in RenderArR.swift (line 40)
case .viewAspectRatio where view is UIView:
let bufferWidth = CVPixelBufferGetWidth(raw)
let bufferHeight = CVPixelBufferGetHeight(raw)
let viewSize = (view as! UIView).bounds.size
let targetSize = AVMakeRect(aspectRatio: viewSize, insideRect: CGRect(x: 0, y: 0, width: bufferWidth, height: bufferHeight)).size
width = Int(targetSize.width)
height = Int(targetSize.height)
In order to use AVMakeRect I imported AVFoundation in the same file.
@AFathi please let me know what you think about my solution. I think that in this way it's easy to support custom sizes of the recording cause the size is calculated based on the aspect ratio of the view.
Regards,
Giacomo Leopizzi
from arvideokit.
@GiacomoLeopizzi, great approach! Can you create a pull request with these changes?
Also the only thing I'd change is this the force wrapping part.
from this:
let viewSize = (view as! UIView).bounds.size
to this:
let viewSize = (view as? UIView)?.bounds.size ?? .zero
or have some kind of a guard statement.
from arvideokit.
@AFathi sure! Iβll do it today.
About the guard, I forced the cast cause I put a where in the case switch. If you think itβs not fine, I can add a guard of course!
from arvideokit.
@kellum42 the issue is solved in current version of the library.
Use:
recorder.contentMode = .viewAspectRatio
To record with same aspect ratio of the view you used to create the RecordAR instance.
Regards,
Giacomo
from arvideokit.
hey, I can't found "viewAspectRatio" in contentMode .
can you help me?
how can able to make the video a square ?
thanks
from arvideokit.
Sure @J-Arji
You should have something like
let view = ARSCNView()
// Add subview, setup constraints, etc
guard let recorder = RecordAR(ARSceneKit: view) else {
// do something...
}
recorder.contentMode = .viewAspectRatio
If you cannot find it please check you have the latest version of the library
from arvideokit.
In contentMode .viewAspectRatio
the output video has the same aspect ratio of the view, so just make sure the view has 1:1 aspect ration and the output will have square frames.
from arvideokit.
i add this line
guard let recorder = RecordAR(ARSceneKit: sceneView) else {
print("can not add recorder ")
return
}
if ratioMode == .normal {
recorder.contentMode = . viewAspectRatio
} else if ratioMode == .story {
recorder.contentMode = .aspectFill
} else {
recorder.contentMode = .auto
}
but when I play record video it's fill
from arvideokit.
You should set the recorder.contentMode to .viewAspectRatio
in order to get the output you want.
from arvideokit.
Of course the view itself has also to be 1:1
from arvideokit.
This should happen cause contentMode is not to .viewAspectRatio
from arvideokit.
but content mode is to .viewAspectRatio
I change it
from arvideokit.
Are you sure it's called? Cause I noticed you have an if block, maybe ratioMode is not .normal
from arvideokit.
when I breakpoint buffer size in write return
but in RanderAr buffersize is 1080,1080
when I call again width and height it's ok
why ??
from arvideokit.
When you call again you mean on next frame or next recording (I mean you stop recording and start it again)?
from arvideokit.
yeah,
I understand why I have a problem.
I set recorder?.onlyRenderWhileRecording = false
when I start and stop is ok
I change onlyRenderWhileRecording
to true and it's ok
but I think this part has a problem.
from arvideokit.
Related Issues (20)
- can not install version 1.6.0 HOT 2
- Black Bars on video output HOT 2
- ARVideoKit forces app into portrait mode when starting from landscape left/right. HOT 3
- ARVideoKit License HOT 3
- Crash - [AVAssetWriterInput initWithMediaType:outputSettings:sourceFormatHint:]
- low FPS while recording videos!! HOT 4
- Recorded video shows flat texture on face tracking HOT 2
- Wrong aspect ratio for initial video recording on on iPhone 12 HOT 1
- Plane detection is shown blank HOT 2
- Person segmentation not being recorded HOT 3
- ARFaceTrackingConfiguration not recorder correctly HOT 4
- pod installation issue HOT 2
- high CPU usage HOT 4
- Surface shader result not recorded. HOT 3
- ARFaceTrackingConfiguration front camera audio recording not working.
- Job Open HOT 1
- Only working on iPhone X.
- App freezes for a moment when starting recording HOT 4
- when use ARVideoKit to record an ARSCNView, the loaded AR object shows black in the scene HOT 4
- Must start a session before appending pixel buffers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arvideokit.