Skip to content

Commit

Permalink
ExtractSound add
Browse files Browse the repository at this point in the history
  • Loading branch information
黄锐灏 committed Jan 11, 2019
1 parent 72e18a8 commit 731e425
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 43 deletions.
Binary file not shown.
5 changes: 5 additions & 0 deletions WAVideoBox/WAVideoBox/WAAVSeCommand/WAAVSEComposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic , assign) NSInteger videoQuality;

/**
输出文件格式
*/
@property (nonatomic , copy) AVFileType fileType;

/**
视频操作参数数组
*/
Expand Down
2 changes: 1 addition & 1 deletion WAVideoBox/WAVideoBox/WAAVSeCommand/WAAVSEComposition.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@implementation WAAVSEComposition

- (NSMutableArray<AVMutableAudioMixInputParameters *> *)audioMixParam{
- (NSMutableArray<AVMutableAudioMixInputParameters *> *)audioMixParams{
if (!_audioMixParams) {
_audioMixParams = [NSMutableArray array];
}
Expand Down
7 changes: 5 additions & 2 deletions WAVideoBox/WAVideoBox/WAAVSeCommand/WAAVSEExportCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ - (void)performSaveAsset:(AVAsset *)asset byPath:(NSString *)path{
self.composition.presetName = AVAssetExportPresetHighestQuality;
}

if (!self.composition.fileType) {
self.composition.fileType = AVFileTypeMPEG4;
}

self.exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:self.composition.presetName];
self.exportSession.shouldOptimizeForNetworkUse = YES;
self.exportSession.videoComposition = self.composition.mutableVideoComposition;
Expand All @@ -62,10 +66,9 @@ - (void)performSaveAsset:(AVAsset *)asset byPath:(NSString *)path{
}

}


self.exportSession.outputURL = [NSURL fileURLWithPath:path];
self.exportSession.outputFileType = AVFileTypeMPEG4;
self.exportSession.outputFileType = self.composition.fileType;
[self.exportSession exportAsynchronouslyWithCompletionHandler:^(void){

switch (self.exportSession.status) {
Expand Down
18 changes: 18 additions & 0 deletions WAVideoBox/WAVideoBox/WAAVSeCommand/WAAVSEExtractSoundCommand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// WAAVSEExtractSoundCommand.h
// YCH
//
// Created by 黄锐灏 on 2019/1/11.
// Copyright © 2019 黄锐灏. All rights reserved.
//

#import "WAAVSECommand.h"

NS_ASSUME_NONNULL_BEGIN

@interface WAAVSEExtractSoundCommand : WAAVSECommand


@end

NS_ASSUME_NONNULL_END
24 changes: 24 additions & 0 deletions WAVideoBox/WAVideoBox/WAAVSeCommand/WAAVSEExtractSoundCommand.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// WAAVSEExtractSoundCommand.m
// YCH
//
// Created by 黄锐灏 on 2019/1/11.
// Copyright © 2019 黄锐灏. All rights reserved.
//

#import "WAAVSEExtractSoundCommand.h"

@implementation WAAVSEExtractSoundCommand
- (void)performWithAsset:(AVAsset *)asset{
[super performWithAsset:asset];

NSArray *natureTrackAry = [[self.composition.mutableComposition tracksWithMediaType:AVMediaTypeVideo] copy];

for (AVCompositionTrack *track in natureTrackAry) {
[self.composition.mutableComposition removeTrack:track];
}
self.composition.fileType = AVFileTypeAppleM4A;
self.composition.presetName = AVAssetExportPresetAppleM4A;

}
@end
18 changes: 18 additions & 0 deletions WAVideoBox/WAVideoBox/WAVideoBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ typedef NS_ENUM(NSUInteger,WAVideoExportRatio) {
*/
- (BOOL)rangeVideoByTimeRange:(CMTimeRange)range;


/**
视频截取
@param beganPoint 开始的节点
@param endPoint 结束的节点
@return 操作状态
*/
- (BOOL)rangeVideoByBeganPoint:(CGFloat)beganPoint endPoint:(CGFloat)endPoint;

/**
视频旋转
@param degress 角度,内部会调用%90,保证90度的倍数旋转
Expand Down Expand Up @@ -128,6 +138,14 @@ typedef NS_ENUM(NSUInteger,WAVideoExportRatio) {
*/
- (BOOL)dubbedSoundBySoundPath:(NSString *)soundPath volume:(CGFloat)volume mixVolume:(CGFloat)mixVolume insertTime:(CGFloat)insetDuration;

#pragma mark 音频提取

/**
音频提取,操作后视频将变为音频
@return 操作状态
*/
- (BOOL)extractVideoSound;

#pragma mark 处理
/**
异步视频处理
Expand Down
Loading

0 comments on commit 731e425

Please sign in to comment.