Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
dz_TZImagePickerController
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shuijing
dz_TZImagePickerController
Commits
5b6ff817
Commit
5b6ff817
authored
Jun 03, 2017
by
yuzheng.tz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复视频转向方法中可能发生的内存泄漏问题
parent
e3a95ad9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
TZImagePickerController/TZImagePickerController/TZImageManager.m
...PickerController/TZImagePickerController/TZImageManager.m
+7
-6
No files found.
TZImagePickerController/TZImagePickerController/TZImageManager.m
View file @
5b6ff817
...
@@ -835,29 +835,30 @@ static CGFloat TZScreenScale;
...
@@ -835,29 +835,30 @@ static CGFloat TZScreenScale;
NSArray
*
tracks
=
[
videoAsset
tracksWithMediaType
:
AVMediaTypeVideo
];
NSArray
*
tracks
=
[
videoAsset
tracksWithMediaType
:
AVMediaTypeVideo
];
AVAssetTrack
*
videoTrack
=
[
tracks
objectAtIndex
:
0
];
AVAssetTrack
*
videoTrack
=
[
tracks
objectAtIndex
:
0
];
AVMutableVideoCompositionInstruction
*
roateInstruction
=
[
AVMutableVideoCompositionInstruction
videoCompositionInstruction
];
roateInstruction
.
timeRange
=
CMTimeRangeMake
(
kCMTimeZero
,
[
videoAsset
duration
]);
AVMutableVideoCompositionLayerInstruction
*
roateLayerInstruction
=
[
AVMutableVideoCompositionLayerInstruction
videoCompositionLayerInstructionWithAssetTrack
:
videoTrack
];
if
(
degrees
==
90
)
{
if
(
degrees
==
90
)
{
// 顺时针旋转90°
// 顺时针旋转90°
translateToCenter
=
CGAffineTransformMakeTranslation
(
videoTrack
.
naturalSize
.
height
,
0
.
0
);
translateToCenter
=
CGAffineTransformMakeTranslation
(
videoTrack
.
naturalSize
.
height
,
0
.
0
);
mixedTransform
=
CGAffineTransformRotate
(
translateToCenter
,
M_PI_2
);
mixedTransform
=
CGAffineTransformRotate
(
translateToCenter
,
M_PI_2
);
videoComposition
.
renderSize
=
CGSizeMake
(
videoTrack
.
naturalSize
.
height
,
videoTrack
.
naturalSize
.
width
);
videoComposition
.
renderSize
=
CGSizeMake
(
videoTrack
.
naturalSize
.
height
,
videoTrack
.
naturalSize
.
width
);
[
roateLayerInstruction
setTransform
:
mixedTransform
atTime
:
kCMTimeZero
];
}
else
if
(
degrees
==
180
){
}
else
if
(
degrees
==
180
){
// 顺时针旋转180°
// 顺时针旋转180°
translateToCenter
=
CGAffineTransformMakeTranslation
(
videoTrack
.
naturalSize
.
width
,
videoTrack
.
naturalSize
.
height
);
translateToCenter
=
CGAffineTransformMakeTranslation
(
videoTrack
.
naturalSize
.
width
,
videoTrack
.
naturalSize
.
height
);
mixedTransform
=
CGAffineTransformRotate
(
translateToCenter
,
M_PI
);
mixedTransform
=
CGAffineTransformRotate
(
translateToCenter
,
M_PI
);
videoComposition
.
renderSize
=
CGSizeMake
(
videoTrack
.
naturalSize
.
width
,
videoTrack
.
naturalSize
.
height
);
videoComposition
.
renderSize
=
CGSizeMake
(
videoTrack
.
naturalSize
.
width
,
videoTrack
.
naturalSize
.
height
);
[
roateLayerInstruction
setTransform
:
mixedTransform
atTime
:
kCMTimeZero
];
}
else
if
(
degrees
==
270
){
}
else
if
(
degrees
==
270
){
// 顺时针旋转270°
// 顺时针旋转270°
translateToCenter
=
CGAffineTransformMakeTranslation
(
0
.
0
,
videoTrack
.
naturalSize
.
width
);
translateToCenter
=
CGAffineTransformMakeTranslation
(
0
.
0
,
videoTrack
.
naturalSize
.
width
);
mixedTransform
=
CGAffineTransformRotate
(
translateToCenter
,
M_PI_2
*
3
.
0
);
mixedTransform
=
CGAffineTransformRotate
(
translateToCenter
,
M_PI_2
*
3
.
0
);
videoComposition
.
renderSize
=
CGSizeMake
(
videoTrack
.
naturalSize
.
height
,
videoTrack
.
naturalSize
.
width
);
videoComposition
.
renderSize
=
CGSizeMake
(
videoTrack
.
naturalSize
.
height
,
videoTrack
.
naturalSize
.
width
);
[
roateLayerInstruction
setTransform
:
mixedTransform
atTime
:
kCMTimeZero
];
}
}
AVMutableVideoCompositionInstruction
*
roateInstruction
=
[
AVMutableVideoCompositionInstruction
videoCompositionInstruction
];
roateInstruction
.
timeRange
=
CMTimeRangeMake
(
kCMTimeZero
,
[
videoAsset
duration
]);
AVMutableVideoCompositionLayerInstruction
*
roateLayerInstruction
=
[
AVMutableVideoCompositionLayerInstruction
videoCompositionLayerInstructionWithAssetTrack
:
videoTrack
];
[
roateLayerInstruction
setTransform
:
mixedTransform
atTime
:
kCMTimeZero
];
roateInstruction
.
layerInstructions
=
@[
roateLayerInstruction
];
roateInstruction
.
layerInstructions
=
@[
roateLayerInstruction
];
// 加入视频方向信息
// 加入视频方向信息
videoComposition
.
instructions
=
@[
roateInstruction
];
videoComposition
.
instructions
=
@[
roateInstruction
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment