Support orientation as a parameter to startRecording
This commit is contained in:
parent
1312c5be53
commit
19bf300bbe
@ -27,10 +27,11 @@ class ChunkedRecordingManager(private val encoder: MediaCodec, private val outpu
|
||||
bitRate: Int,
|
||||
options: RecordVideoOptions,
|
||||
outputDirectory: File,
|
||||
iFrameInterval: Int = 3
|
||||
iFrameInterval: Int = 5
|
||||
): ChunkedRecordingManager {
|
||||
val mimeType = options.videoCodec.toMimeType()
|
||||
val orientationDegrees = cameraOrientation.toDegrees()
|
||||
val cameraOrientationDegrees = cameraOrientation.toDegrees()
|
||||
val recordingOrientationDegrees = (options.orientation ?: Orientation.PORTRAIT).toDegrees();
|
||||
val (width, height) = if (cameraOrientation.isLandscape()) {
|
||||
size.height to size.width
|
||||
} else {
|
||||
@ -54,11 +55,13 @@ class ChunkedRecordingManager(private val encoder: MediaCodec, private val outpu
|
||||
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, iFrameInterval)
|
||||
format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate)
|
||||
|
||||
Log.i(TAG, "Video Format: $format, orientation $cameraOrientation")
|
||||
Log.d(TAG, "Video Format: $format, camera orientation $cameraOrientationDegrees, recordingOrientation: $recordingOrientationDegrees")
|
||||
// Create a MediaCodec encoder, and configure it with our format. Get a Surface
|
||||
// we can use for input and wrap it with a class that handles the EGL work.
|
||||
codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE)
|
||||
return ChunkedRecordingManager(codec, outputDirectory, 0, iFrameInterval, callbacks)
|
||||
return ChunkedRecordingManager(
|
||||
codec, outputDirectory, recordingOrientationDegrees, iFrameInterval, callbacks
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ class RecordVideoOptions(map: ReadableMap) {
|
||||
var videoCodec = VideoCodec.H264
|
||||
var videoBitRateOverride: Double? = null
|
||||
var videoBitRateMultiplier: Double? = null
|
||||
var orientation: Orientation? = null
|
||||
|
||||
init {
|
||||
if (map.hasKey("fileType")) {
|
||||
@ -25,5 +26,8 @@ class RecordVideoOptions(map: ReadableMap) {
|
||||
if (map.hasKey("videoBitRateMultiplier")) {
|
||||
videoBitRateMultiplier = map.getDouble("videoBitRateMultiplier")
|
||||
}
|
||||
if (map.hasKey("orientation")) {
|
||||
orientation = Orientation.fromUnionValue(map.getString("orientation"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user