小编Muh*_*han的帖子

在资产库中编写视频然后获取其属性的正确方法是什么

我正在使用[library writeVideoAtPathToSavedPhotosAlbum:movieUrl completionBlock:^(NSURL*assetURL,NSError*error)块在资源库中编写视频,在视频完全写入资产库之前给出了url.当我枚举块内的库以获取视频的属性时,我没有得到任何视频来反对上面的块给出的url.如果我使用相同的URL手动重新枚举资产库3或4次,我将获得视频属性.这个问题主要发生在我制作持续时间超过5分钟的视频时我的代码是:

    library = [[ALAssetsLibrary alloc] init];
    [library writeVideoAtPathToSavedPhotosAlbum:movieUrl completionBlock:^(NSURL *assetURL, NSError *error)
    {   
        savedAssetURL = assetURL;
        [self assetsEmumeration:assetURL];
        NSLog(@"asset url %@",assetURL);
        if(error) 
        {
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Failed" message:[error localizedDescription] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:Nil];
            [alertView show];
        }
    }];

    -(void) assetsEmumeration:(NSURL *)_url 
    {   
    NSLog(@"assets enumeration ");
    ALAssetsLibrary *al;    
    void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
    {
        [group setAssetsFilter:[ALAssetsFilter allVideos]] ;
        [group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop)
         {
             if (asset) 
             {
                 ALAssetRepresentation *representation = [asset defaultRepresentation]; …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios

5
推荐指数
1
解决办法
3849
查看次数

以mp3格式从视频中提取音频

目标:我想从mp3格式的视频中提取音频.视频可以采用任何iOS支持的格式

我尝试了以下技术来实现上述目标,我使用的是lame库:

步骤1:通过将源文件URL传递给它来创建AVURLAsset对象.

步骤2:创建一个AVAssetExportSession对象,源资源将其outputfileType设置为m4a.

第3步:提取其音频,之后我尝试将其转换为mp3格式.

这是我用过的代码:

NSURL *videoFileUrl = [NSURL fileURLWithPath:originalVideoPath];
AVURLAsset *anAsset = [[AVURLAsset alloc] initWithURL:videoFileUrl options:nil];

exportSession=[AVAssetExportSession exportSessionWithAsset:anAsset presetName:AVAssetExportPresetPassthrough];

[exportSession determineCompatibleFileTypesWithCompletionHandler:^(NSArray *compatibleFileTypes) {
    NSLog(@"compatiblefiletypes: %@",compatibleFileTypes);
}];

NSURL *furl = [NSURL fileURLWithPath:tmpVideoPath];
exportSession.outputURL = furl;
exportSession.outputFileType=AVFileTypeAppleM4A;

CMTime duration = anAsset.duration;
CMTimeRange range = CMTimeRangeMake(kCMTimeZero, duration);
exportSession.timeRange = range;

[exportSession exportAsynchronouslyWithCompletionHandler:^{
    dispatch_async(dispatch_get_main_queue(), ^{
        [SVProgressHUD dismiss];
    });
    switch (exportSession.status)
    {
        case AVAssetExportSessionStatusCompleted:
        {
            dispatch_async(dispatch_get_main_queue(), ^{
                    [SVProgressHUD showProgress:0 status:@"Converting..." maskType:SVProgressHUDMaskTypeGradient];
                    [self performSelector:@selector(convertToMp3) withObject:nil afterDelay:0.3f];       
            });
            break;
        }
        case …
Run Code Online (Sandbox Code Playgroud)

iphone audio objective-c lame ios

5
推荐指数
1
解决办法
1648
查看次数

Crashlytics 围绕 Maps SDK、gmscore::renderer::GLState::Flush() 的崩溃报告

据 crashlytics 报告,我们的应用程序发生了很多用户崩溃的情况,但我们无法在我们这边重现这些崩溃。这是完整的崩溃报告:

    Crashed: com.apple.main-thread
0  TheBarCode                     0x100ccc2d8 gmscore::renderer::GLState::Flush() + 16388
1  TheBarCode                     0x100cd7630 gmscore::renderer::GLScopedContext::~GLScopedContext() + 31600
2  TheBarCode                     0x100d3a314 -[GMSEntityRendererView setFrame:] + 436308
3  TheBarCode                     0x100d82578 -[GMSVectorMapView setFrame:] + 184912
4  UIKitCore                      0x18f6af878 -[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] + 576
5  UIKitCore                      0x18f6b0510 -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 236
6  CoreFoundation                 0x18b18195c __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ + 16
7  CoreFoundation                 0x18b084fb0 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 416
8  UIKitCore                      0x18f6af5e4 -[UIView(Geometry) resizeSubviewsWithOldSize:] + 156
9  UIKitCore                      0x18f6b082c -[UIView(Geometry) setBounds:] + 688
10 UIKitCore                      0x18f6b00e0 -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:] + 528
11 …
Run Code Online (Sandbox Code Playgroud)

ios google-maps-sdk-ios swift

5
推荐指数
1
解决办法
888
查看次数

标签 统计

ios ×3

iphone ×2

objective-c ×2

audio ×1

google-maps-sdk-ios ×1

lame ×1

swift ×1