Tag: video操作

在IOS 9上使用AVPlayer和Swift反向播放video

我有一个录制的video剪辑,我想反向播放。 向前播放是好的,但只要我寻求video文件的结尾,并设置回放速度为-1.0的video剪辑寻求到剪辑的结尾(我看到这在video上方的时间线栏),但确实不能反向播放。 在我介绍播放器视图控制器之后,我检查它是否准备好使用: print("readyForDisplay = \(playerViewController.readyForDisplay)") 这告诉我,所有准备好准备玩。 我检查是否可以反向播放: let reversePlay = playerViewController.player!.currentItem?.canPlayReverse print("reversePlay = \(reversePlay)") 这返回TRUE 然后我寻找剪辑的结尾,并将播放速率设置为-1.0以反向播放。 playerViewController.player!.seekToTime(playerViewController.player!.currentItem!.asset.duration) playerViewController.player!.rate = -1.0 我相信已经有了这个可以玩的地方,因为如果我添加以下内容: let status : AVPlayerItemStatus? = playerViewController.player!.currentItem?.status if status == AVPlayerItemStatus.ReadyToPlay { print("Ready to play") } 它告诉我剪辑已经准备好播放了,所以我假设寻求剪辑结束(只有2秒钟)已经完成。 然后我播放剪辑: playerViewController.player!.play() 如果我不追求最终目标,并试图改变比赛速度来使其反转,那么它就会起作用。 我在这里错过了什么?

在whatsapp – 目标c上分享video

在iOS 7.1.1上,我可以通过Whatsapp上的这段代码分享图片。 if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]){ UIImage * iconImage = [UIImage imageNamed:@"image.png"]; NSString * savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"]; [UIImageJPEGRepresentation(iconImage, 1.0) writeToFile:savePath atomically:YES]; self.docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]]; self.docController.UTI = @"net.whatsapp.image"; self.docController.delegate = self; //[self.docController setAnnotation:@{@"WhatsappCaption" : @"https://itunes.apple.com/us/app/epic-ar/id535122470?ls=1&mt=8"}]; [self.docController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:appDelegate.window.rootViewController.view animated: YES]; } 但我也想分享video,我遵循Wahtsapp教程的教程 但是videopath的代码又怎么样呢? 我的意思是,UIImage对象显示video的替代对象是什么? 另外,我可以分享“链接”? 谢谢,

肖像video播放黑屏

更新 不要使用模拟器来testingvideo翻译 。 但我在这里有另一个问题的编解码器问题。 任何帮助表示赞赏。 我正在使用AVURLAsset来创build我的video,并且只要从画廊中选取的video处于横向模式,它们就能正常工作。 但是,当我使用纵向video时,它会以黑色屏幕(audio播放)播放,或者帧被扭曲(请参阅图像)。 更新:我尝试使用CGAffineTransform仍然没有运气。 代码如下: -(void) createVideo{ AVMutableComposition* mixComposition = [AVMutableComposition composition]; NSDictionary *options = @{AVURLAssetPreferPreciseDurationAndTimingKey:@YES}; _videoAsset = [[AVURLAsset alloc]initWithURL:video_url options:options]; CMTime startTimeV=CMTimeMakeWithSeconds(videoStartTime.floatValue, 1); CMTime endTimeV=CMTimeMakeWithSeconds(videoEndTime.floatValue, 1); CMTimeRange video_timeRange = CMTimeRangeMake(startTimeV,endTimeV); AVMutableCompositionTrack *a_compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; [a_compositionVideoTrack insertTimeRange:video_timeRange ofTrack:[[_videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:nil]; AVMutableVideoCompositionInstruction *mainInstruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; mainInstruction.timeRange = […]

将video添加到启animation面或应用程序的第一个视图(IOS xcode 4.0)

我是IOS的初学者,但是我需要在应用程序启动时显示video。 请你能帮我吗? 如果无法在飞溅视图上实现video,有什么想法来创build? 谢谢。 如果我有字面错误,抱歉我来自西class牙。 ; d

从文档目录中删除video的问题

我正试图从文档目录中删除一个video,但video并未被删除。 以下是我如何删除video: //Delete Video NSError *error = nil; //NSData *videoData = [NSData dataWithContentsOfURL:self.finalURL]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *tempPath = [documentsDirectory stringByAppendingFormat:@"/vid1.mp4"]; [[NSFileManager defaultManager] removeItemAtPath: tempPath error: &error]; UIAlertView *removeSuccessFulAlert=[[UIAlertView alloc]initWithTitle:@"Congratulation:" message:@"Successfully removed" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil]; [removeSuccessFulAlert show];

Androidvideo无法在iOS上播放

我发现使用编解码器H.264, MPEG-4 HE AAC V2video对我的代码没有任何问题。 但是当我使用编解码器H.264, AAC (从Android设备发送)video再次黑色。 现在我的问题是如何将video转换为iOS可玩的编解码器。

iOS应用程序的快速录制

我是OpenGL ES的新手。 我正在尝试编写iOS应用程序的屏幕录制代码,尤其是游戏。 我在这个答案中使用了代码中描述的“渲染到纹理”方法来捕获屏幕并为cocos2d游戏编写video。 我做的一个修改是,当我调用CVOpenGLESTextureCacheCreate然后我使用[EAGLContext currentContext]而不是 [[GPUImageOpenGLESContext sharedImageProcessingOpenGLESContext] context] 它logging的video,但有两个问题 (1) – 开始录制时,屏幕上的新graphics停止。 我希望应用程序继续在屏幕上绘图。 由于我是OpenGL ES的新手,对帧缓冲对象没有深入的了解,所以我很难弄清楚如何同时在屏幕上绘图并捕捉屏幕。 我会欣赏这方面的代码示例。 (2) – 录制的video翻转倒置。 我怎样才能正确的方向? 以前我也考虑过glReadPixels方法,但是这有性能上的缺点。 更新:也想到了一些想法。 根据我的一点理解, 我可以简单地画我的纹理,但不知道如何。 要么 我可以有一个第二FBO,我可以附加纹理,即 glGenFramebuffersOES(1, &textureFrameBuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, textureFrameBuffer); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, CVOpenGLESTextureGetName(renderTexture), 0); //Then I restore the screen FBO. glBindFramebufferOES(GL_FRAMEBUFFER_OES, 1); 但是,如果我这样做,那么我如何将屏幕绘图复制到我的第二FBO?

ios – 从纹理caching创build的video是黑色的

我正在尝试使用Brad Larson的答案在iOS上进行高效的video处理。 这个答案是关于如何在不使用glReadPixels情况下高效地获得像素缓冲区的输出。 据我所知,必须从AVAssetWriterInputPixelBufferAdaptor pixelBufferPool中加载一个像素缓冲区,将其链接起来,然后在每个渲染循环之后调用 CVPixelBufferUnlockBaseAddress(buffer, CVPixelBufferLockFlags(rawValue: 0)) writerAdaptor?.append(buffer, withPresentationTime: currentTime) 但是,当我尝试这样做,输出video是黑色的。 原来的答案显示了代码片段,而不是完整的设置。 我也看过GPUImage,但令人惊讶的是它使用glReadPixels : https : //github.com/BradLarson/GPUImage/blob/167b0389bc6e9dc4bb0121550f91d8d5d6412c53/framework/Source/Mac/GPUImageMovieWriter.m#L501 这里是我想要工作的代码的一个稍微简化的版本: 1)开始摄像机录制 override func viewDidLoad() { // Start the camera recording session = AVCaptureSession() session.sessionPreset = AVCaptureSessionPreset1920x1080 // Input setup. device = AVCaptureDevice.devices(withMediaType: AVMediaTypeVideo).first as? AVCaptureDevice input = try? AVCaptureDeviceInput(device: device) session.addInput(input) // Output setup. let output […]

如何减less手机上通过我的iOS应用程序录制的video的文件大小

我正在制作iOS应用程序(即将推出Android),其中涉及用户通过应用程序在手机上录制video。 但我需要的应用程序来减less这些video的默认大小,以便当他们上传到我的服务器使用较less的带宽,并上传得更快。 什么是最好的方法来做到这一点?

我可以添加UIImage或CGImageRefvideo?

我想在video之间添加图片,就像笑脸或剪贴画一样。 笑脸和剪贴画最有可能有animation。 我提到了在库中查找资产 – 添加到AVMutableComposition – 导出=崩溃 ,还有苹果的ALAssetLibrary 。 但没有任何想法来完成我的要求。 有什么function可以将UIImage和CGImageRef添加到AVMutableComposition吗? 如何将图像添加到video中?