π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] Preserve stream offsets when changing video speed
r4khul4a287dc1d5b7
diff --git a/mobile/apps/photos/lib/ui/tools/editor/export_video_service.dart b/mobile/apps/photos/lib/ui/tools/editor/export_video_service.dartindex 35dac68bd6..67598d41fd 100644--- a/mobile/apps/photos/lib/ui/tools/editor/export_video_service.dart+++ b/mobile/apps/photos/lib/ui/tools/editor/export_video_service.dart@@ -174,7 +174,7 @@ List<String> buildFfmpegVideoFilters({}filters.add('scale=trunc(iw/2)*2:trunc(ih/2)*2');if (speed != 1.0) {- filters.add('setpts=(PTS-STARTPTS)/$speed');+ filters.add('setpts=PTS/$speed');}return filters;}@@ -196,5 +196,6 @@ List<String> buildFfmpegAudioTempoFilters(double speed) {remaining /= 2.0;}filters.add('atempo=$remaining');+ filters.add('asetpts=PTS-STARTPTS+STARTPTS/$speed');return filters;}diff --git a/mobile/apps/photos/test/ui/tools/editor/video_editor_contract_test.dart b/mobile/apps/photos/test/ui/tools/editor/video_editor_contract_test.dartindex 18103284e9..0a2eede7f4 100644--- a/mobile/apps/photos/test/ui/tools/editor/video_editor_contract_test.dart+++ b/mobile/apps/photos/test/ui/tools/editor/video_editor_contract_test.dart@@ -60,16 +60,26 @@ void main() {expect(buildFfmpegVideoFilters(crop: null, rotation: 90, speed: 2), ['transpose=1','scale=trunc(iw/2)*2:trunc(ih/2)*2',- 'setpts=(PTS-STARTPTS)/2.0',+ 'setpts=PTS/2.0',]);});});- test('audio tempo chains supported filters for quarter speed', () {- expect(buildFfmpegAudioTempoFilters(0.25), ['atempo=0.5', 'atempo=0.5']);- expect(buildFfmpegAudioTempoFilters(2), ['atempo=2.0']);- expect(buildFfmpegAudioTempoFilters(1), isEmpty);- });+ test(+ 'audio tempo scales the initial offset without stretching samples twice',+ () {+ expect(buildFfmpegAudioTempoFilters(0.25), [+ 'atempo=0.5',+ 'atempo=0.5',+ 'asetpts=PTS-STARTPTS+STARTPTS/0.25',+ ]);+ expect(buildFfmpegAudioTempoFilters(2), [+ 'atempo=2.0',+ 'asetpts=PTS-STARTPTS+STARTPTS/2.0',+ ]);+ expect(buildFfmpegAudioTempoFilters(1), isEmpty);+ },+ );test('FFmpeg plan preserves file paths as structured arguments', () {final controller = VideoEditorController.file(@@ -102,12 +112,15 @@ void main() {plan.arguments,containsAllInOrder(['-vf',- 'scale=trunc(iw/2)*2:trunc(ih/2)*2,setpts=(PTS-STARTPTS)/0.25',+ 'scale=trunc(iw/2)*2:trunc(ih/2)*2,setpts=PTS/0.25',]),);expect(plan.arguments,- containsAllInOrder(['-af', 'atempo=0.5,atempo=0.5']),+ containsAllInOrder([+ '-af',+ 'atempo=0.5,atempo=0.5,asetpts=PTS-STARTPTS+STARTPTS/0.25',+ ]),);});}