Tag: avfoundation

与AVPlayer的平移手势

这个function对我的应用程序非常重要,并且真的很想帮助一下。 基本上,我想添加一个UIPanGestureRecognizer到video播放器,以便用户可以用手势快进/倒带video。 苹果有一些使用Swift 3的示例代码,并且已经创build了整个video播放器。 唯一缺less的是UIPanGestureRecognizer 。 这是链接: https : //developer.apple.com/library/content/samplecode/AVFoundationSimplePlayer-iOS/Introduction/Intro.html#//apple_ref/doc/uid/TP40016103 在viewWillAppear我添加了这样的手势: let panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture)) view.addGestureRecognizer(panGesture) 这是有点工作的代码。 目前正在擦洗。 问题是,每次我开始平移手势,video跳到中间,我从那里开始。 而不是从当前video的快进/快退,平移手势将video跳到中间,然后允许我快进/快退,这是不好的。 func handlePanGesture(sender: UIPanGestureRecognizer) { switch sender.state { case .began, .changed: let translation = sender.translation(in: self.view) var horizontalTranslation = Float(translation.x) let durationInSeconds = Float(CMTimeGetSeconds(player.currentItem!.asset.duration)) // Using 275 as the limit for delta along […]

在AVMutableComposition中使用AVMutableCompositionTrack合并video和图像,而不是AVVideoCompositionCoreAnimationTool?

以下代码使用AVMutableComposition导出video。 但在导出的video中,如果要在源video结束后显示图像3秒钟,是否有办法使用AVMutableCompositionTrack执行该操作,还是需要在video结束后添加图像层并为其外观制作animation? 最终目标是将任意数量的图像和video合并为一个主video。 不幸的是,在testing期间, AVVideoCompositionCoreAnimationTool似乎严重降低了导出过程(从<1秒到10-20秒),因此如果可能的话,目标是避免AVVideoCompositionCoreAnimationTool 。 // Create composition object let composition = AVMutableComposition() let compositionVideoTrack = composition.addMutableTrackWithMediaType(AVMediaTypeVideo, preferredTrackID: CMPersistentTrackID(kCMPersistentTrackID_Invalid)) let compositionAudioTrack = composition.addMutableTrackWithMediaType(AVMediaTypeAudio, preferredTrackID: CMPersistentTrackID(kCMPersistentTrackID_Invalid)) var insertTime = kCMTimeZero // Extract tracks from slice video let videoURL = NSURL(fileURLWithPath: videoPath) let videoAsset = AVURLAsset(URL: videoURL, options: nil) let sourceVideoTrack = videoAsset.tracksWithMediaType(AVMediaTypeVideo)[0] let sourceAudioTrack = […]

如何将audio效果应用于文件并写入文件系统 – iOS

我正在构build一个应用程序,允许用户将audiofilter应用于录制的audio,如混响,增强。 我无法find有关如何将filter应用于文件本身的任何可行的信息源,因为需要稍后将处理的文件上载到服务器。 我目前正在使用AudioKit进行可视化,而且我知道它可以进行audio处理,但只能用于播放。 请提供进一步研究的build议。

点产品和亮度/ Findmyicone

所有, 我有一个基本的问题,我正在这里挣扎。 当您查看WWDC 2010的findmyicone示例代码时,您将看到: static const uint8_t orangeColor[] = {255, 127, 0}; uint8_t referenceColor[3]; // Remove luminance static inline void normalize( const uint8_t colorIn[], uint8_t colorOut[] ) { // Dot product int sum = 0; for (int i = 0; i < 3; i++) sum += colorIn[i] / 3; for (int j = 0; j […]

iOS AVAudioSession中断通知不按预期工作

我想知道什么时候我的AVAudioRecorder无法访问(例如,当音乐开始播放)。 由于audioRecorderEndInterruption将被弃用与iOS 9我专注于AVAudioSession的中断通知(但都没有按预期工作)。 问题是,如果应用程序在中断发生时仍处于前台,中断通知从不会被调用。 例如:用户启动和停止播放音乐,而不将应用程序移动到后台。 要检测我正在使用的任何中断: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioSessionWasInterrupted:) name:AVAudioSessionInterruptionNotification object:nil]; … – (void)audioSessionWasInterrupted:(NSNotification *)notification { if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) { NSLog(@"Interruption notification"); if ([[notification.userInfo valueForKey:AVAudioSessionInterruptionTypeKey] isEqualToNumber:[NSNumber numberWithInt:AVAudioSessionInterruptionTypeBegan]]) { NSLog(@"InterruptionTypeBegan"); } else { NSLog(@"InterruptionTypeEnded"); } } } 如预期的那样,我得到InterruptionTypeBegan ,但是如果应用程序仍处于前台(即在应用程序放置在后台并返回前台之前不会调用),则不会调用InterruptionTypeEnded 。 在应用程序处于前台时发生中断时,如何接收InterruptionTypeEnded通知?

AVAudioSession操作声音输出

我使用AVSoundSession来configuration声音, AVAudioPlayer播放不同的声音。 我搜查了很多,找不到任何东西。 我怎样操纵输出源? 我需要一个在我的SoundManager中的方法,我可以切换电话扬声器和扬声器之间的输出。 success = [session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&error]; 使用这个我可以将声音传送到扬声器,但是没有办法将它移动到电话扬声器。 有人可以帮我吗?

如何将mov转换为MP4设备上的iOS

我正在写ios应用程序,应该将mov文件转换为mp4。 有什么办法使用AVFoundation或类似的东西? 我会很感激你的帮助! 谢谢!

如何在iOS应用程序中播放m3uaudiostream

我正在尝试使用Xcode 4.5.2创buildiOS / iPhone广播应用程序。 我想播放@“http://xx.xxxxxxx.com/8111/radio.m3u”播放,暂停,音量控制,并能够在后台function/多任务处理上播放。 AVFoundation ,我已经添加了AVFoundation , Mediaplayer和AudioToolBox框架。 我添加了play,暂停和滑块对象到xib。 ViewController.h @interface ViewController : UIViewController @property (strong,nonatomic) MPMoviePlayerController *myPlayer; @property (weak, nonatomic) IBOutlet UISlider *myslider; – (IBAction)playButtonPressed; – (IBAction)myslider:(id)sender; @end ViewController.m #import "ViewController.h" #import <MediaPlayer/MediaPlayer.h> @interface ViewController () { UISlider *volumeSlider; } @end @implementation ViewController – (void)viewDidLoad { [super viewDidLoad]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; UIBackgroundTaskIdentifier newTaskId […]

iOS:错误__connection_block_invoke_2:连接中断

控制台中的Xcode / iOS 8 / AVFoundation相关的错误: error in __connection_block_invoke_2: Connection interrupted 我只是将AVCaptureVideoDataOutput添加到苹果的示例应用程序“AVCamManualUsingtheManualCaptureAPI” 我补充说的是: // CoreImage wants BGRA pixel format NSDictionary *outputSettings = @{ (id)kCVPixelBufferPixelFormatTypeKey : [NSNumber numberWithInteger:kCVPixelFormatType_32BGRA]}; // create and configure video data output AVCaptureVideoDataOutput *videoDataOutput = [[AVCaptureVideoDataOutput alloc] init]; videoDataOutput.videoSettings = outputSettings; videoDataOutput.alwaysDiscardsLateVideoFrames = YES; [videoDataOutput setSampleBufferDelegate:self queue:sessionQueue]; 上面的代码插入到示例项目中: – (void)viewDidLoad { [super viewDidLoad]; […]

Apple Swift 3&Xcode 9 GM的Mach-O Linker(ld)错误组

这是运行良好,直到通用Xcode(和iOS 11)。 现在我得到这些错误: Apple Mach-O Linker (ld) Error Group "__T0So20AVCapturePhotoOutputC12AVFoundation01_abC16SwiftNativeTypesACWP", referenced from: xxxxxxxxxx "__T012AVFoundation37_AVCapturePhotoOutputSwiftNativeTypesPAAE012availableRawc11PixelFormatG0SaySo8NSNumberCGfg", referenced from: xxxxxxxxx " "__T0So22AVCapturePhotoSettingsC12AVFoundation01_abC16SwiftNativeTypesACWP", referenced from: xxxxxxxxxx ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) 它指向的一些行是: photoSettings = AVCapturePhotoSettings(rawPixelFormatType: OSType(self.photoOutput.availableRawPhotoPixelFormatTypes.first!)) photoSettings.previewPhotoFormat = [kCVPixelBufferPixelFormatTypeKey as String: photoSettings.availablePreviewPhotoPixelFormatTypes.first!.uint32Value, kCVPixelBufferWidthKey […]