Skip to content

Commit 208a2ed

Browse files
authored
[camera_android_camerax] Modify plugin to assume mp4 format for captured videos (#10273)
Changes the plugin to assume that recorded videos come in the mp4 format instead of using .temp, which we originally set because we aren't 100% sure of the file format. This is an executive decision I want to make because: 1. The CameraX team directly told me this is safe and they have not experienced any issues with this technique (see flutter/flutter#148335 (comment) for the details on our discussion). 2. If for some reason we do experience issues, we can build a case for getting the container format exposed via the CameraX library (the team suggested this, as well). Fixes flutter/flutter#148335. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 5502041 commit 208a2ed

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

packages/camera/camera_android_camerax/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.24
2+
3+
* Change plugin to assume mp4 format for capture videos.
4+
15
## 0.6.23+5
26

37
* Fixes `IllegalArgumentException` that could occur during image streaming when using NV21.

packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ class AndroidCameraCameraX extends CameraPlatform {
11811181

11821182
videoOutputPath = await systemServicesManager.getTempFilePath(
11831183
videoPrefix,
1184-
'.temp',
1184+
'.mp4',
11851185
);
11861186
pendingRecording = await recorder!.prepareRecording(videoOutputPath!);
11871187

packages/camera/camera_android_camerax/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_android_camerax
22
description: Android implementation of the camera plugin using the CameraX library.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.6.23+5
5+
version: 0.6.24
66

77
environment:
88
sdk: ^3.9.0

packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3311,7 +3311,7 @@ void main() {
33113311
camera.captureOrientationLocked = true;
33123312

33133313
// Tell plugin to create detached Observer when camera info updated.
3314-
const String outputPath = '/temp/REC123.temp';
3314+
const String outputPath = '/temp/REC123.mp4';
33153315
camera.proxy = CameraXProxy(
33163316
newObserver:
33173317
<T>({
@@ -3350,7 +3350,7 @@ void main() {
33503350
when(
33513351
mockSystemServicesManager.getTempFilePath(
33523352
camera.videoPrefix,
3353-
'.temp',
3353+
'.mp4',
33543354
),
33553355
).thenAnswer((_) async => outputPath);
33563356
return mockSystemServicesManager;
@@ -3480,7 +3480,7 @@ void main() {
34803480
camera.captureOrientationLocked = true;
34813481

34823482
// Tell plugin to create detached Observer when camera info updated.
3483-
const String outputPath = '/temp/REC123.temp';
3483+
const String outputPath = '/temp/REC123.mp4';
34843484
camera.proxy = CameraXProxy(
34853485
newObserver:
34863486
<T>({
@@ -3519,7 +3519,7 @@ void main() {
35193519
when(
35203520
mockSystemServicesManager.getTempFilePath(
35213521
camera.videoPrefix,
3522-
'.temp',
3522+
'.mp4',
35233523
),
35243524
).thenAnswer((_) async => outputPath);
35253525
return mockSystemServicesManager;
@@ -3607,7 +3607,7 @@ void main() {
36073607
verify(
36083608
camera.systemServicesManager.getTempFilePath(
36093609
camera.videoPrefix,
3610-
'.temp',
3610+
'.mp4',
36113611
),
36123612
).called(1);
36133613
verifyNoMoreInteractions(camera.systemServicesManager);
@@ -3650,7 +3650,7 @@ void main() {
36503650
camera.captureOrientationLocked = true;
36513651

36523652
// Tell plugin to create detached Analyzer for testing.
3653-
const String outputPath = '/temp/REC123.temp';
3653+
const String outputPath = '/temp/REC123.mp4';
36543654
camera.proxy = CameraXProxy(
36553655
newObserver:
36563656
<T>({
@@ -3689,7 +3689,7 @@ void main() {
36893689
when(
36903690
mockSystemServicesManager.getTempFilePath(
36913691
camera.videoPrefix,
3692-
'.temp',
3692+
'.mp4',
36933693
),
36943694
).thenAnswer((_) async => outputPath);
36953695
return mockSystemServicesManager;
@@ -3807,7 +3807,7 @@ void main() {
38073807
camera.enableRecordingAudio = false;
38083808

38093809
// Tell plugin to mock call to get current video orientation and mock Camera2CameraInfo retrieval.
3810-
const String outputPath = '/temp/REC123.temp';
3810+
const String outputPath = '/temp/REC123.mp4';
38113811
camera.proxy = CameraXProxy(
38123812
newObserver:
38133813
<T>({
@@ -3848,7 +3848,7 @@ void main() {
38483848
when(
38493849
mockSystemServicesManager.getTempFilePath(
38503850
camera.videoPrefix,
3851-
'.temp',
3851+
'.mp4',
38523852
),
38533853
).thenAnswer((_) async => outputPath);
38543854
return mockSystemServicesManager;
@@ -4354,7 +4354,7 @@ void main() {
43544354
when(
43554355
mockSystemServicesManager.getTempFilePath(
43564356
camera.videoPrefix,
4357-
'.temp',
4357+
'.mp4',
43584358
),
43594359
).thenAnswer((_) async => outputPath);
43604360
return mockSystemServicesManager;
@@ -4696,7 +4696,7 @@ void main() {
46964696
when(
46974697
mockSystemServicesManager.getTempFilePath(
46984698
camera.videoPrefix,
4699-
'.temp',
4699+
'.mp4',
47004700
),
47014701
).thenAnswer((_) async => outputPath);
47024702
return mockSystemServicesManager;
@@ -7600,7 +7600,7 @@ void main() {
76007600
camera.captureOrientationLocked = true;
76017601

76027602
// Tell plugin to create detached Observer when camera info updated.
7603-
const String outputPath = '/temp/REC123.temp';
7603+
const String outputPath = '/temp/REC123.mp4';
76047604
camera.proxy = CameraXProxy(
76057605
newObserver:
76067606
<T>({
@@ -7639,7 +7639,7 @@ void main() {
76397639
when(
76407640
mockSystemServicesManager.getTempFilePath(
76417641
camera.videoPrefix,
7642-
'.temp',
7642+
'.mp4',
76437643
),
76447644
).thenAnswer((_) async => outputPath);
76457645
return mockSystemServicesManager;
@@ -7744,7 +7744,7 @@ void main() {
77447744
camera.captureOrientationLocked = true;
77457745

77467746
// Tell plugin to create detached Observer when camera info updated.
7747-
const String outputPath = '/temp/REC123.temp';
7747+
const String outputPath = '/temp/REC123.mp4';
77487748
camera.proxy = CameraXProxy(
77497749
newObserver:
77507750
<T>({
@@ -7783,7 +7783,7 @@ void main() {
77837783
when(
77847784
mockSystemServicesManager.getTempFilePath(
77857785
camera.videoPrefix,
7786-
'.temp',
7786+
'.mp4',
77877787
),
77887788
).thenAnswer((_) async => outputPath);
77897789
return mockSystemServicesManager;
@@ -7888,7 +7888,7 @@ void main() {
78887888
camera.captureOrientationLocked = true;
78897889

78907890
// Tell plugin to create detached Observer when camera info updated.
7891-
const String outputPath = '/temp/REC123.temp';
7891+
const String outputPath = '/temp/REC123.mp4';
78927892
camera.proxy = CameraXProxy(
78937893
newObserver:
78947894
<T>({
@@ -7927,7 +7927,7 @@ void main() {
79277927
when(
79287928
mockSystemServicesManager.getTempFilePath(
79297929
camera.videoPrefix,
7930-
'.temp',
7930+
'.mp4',
79317931
),
79327932
).thenAnswer((_) async => outputPath);
79337933
return mockSystemServicesManager;
@@ -8037,7 +8037,7 @@ void main() {
80378037
camera.captureOrientationLocked = true;
80388038

80398039
// Tell plugin to create detached Observer when camera info updated.
8040-
const String outputPath = '/temp/REC123.temp';
8040+
const String outputPath = '/temp/REC123.mp4';
80418041
camera.proxy = CameraXProxy(
80428042
newAnalyzer:
80438043
({
@@ -8091,7 +8091,7 @@ void main() {
80918091
when(
80928092
mockSystemServicesManager.getTempFilePath(
80938093
camera.videoPrefix,
8094-
'.temp',
8094+
'.mp4',
80958095
),
80968096
).thenAnswer((_) async => outputPath);
80978097
return mockSystemServicesManager;
@@ -8205,7 +8205,7 @@ void main() {
82058205
camera.captureOrientationLocked = true;
82068206

82078207
// Tell plugin to create detached Observer when camera info updated.
8208-
const String outputPath = '/temp/REC123.temp';
8208+
const String outputPath = '/temp/REC123.mp4';
82098209
camera.proxy = CameraXProxy(
82108210
newAnalyzer:
82118211
({
@@ -8259,7 +8259,7 @@ void main() {
82598259
when(
82608260
mockSystemServicesManager.getTempFilePath(
82618261
camera.videoPrefix,
8262-
'.temp',
8262+
'.mp4',
82638263
),
82648264
).thenAnswer((_) async => outputPath);
82658265
return mockSystemServicesManager;
@@ -8365,7 +8365,7 @@ void main() {
83658365
camera.captureOrientationLocked = true;
83668366

83678367
// Tell plugin to create detached Observer when camera info updated.
8368-
const String outputPath = '/temp/REC123.temp';
8368+
const String outputPath = '/temp/REC123.mp4';
83698369
camera.proxy = CameraXProxy(
83708370
newAnalyzer:
83718371
({
@@ -8419,7 +8419,7 @@ void main() {
84198419
when(
84208420
mockSystemServicesManager.getTempFilePath(
84218421
camera.videoPrefix,
8422-
'.temp',
8422+
'.mp4',
84238423
),
84248424
).thenAnswer((_) async => outputPath);
84258425
return mockSystemServicesManager;

0 commit comments

Comments
 (0)