English 中文(简体)
M.m4a 失修图书馆的原始数据
原标题:.m4a raw data from iPod Library not playing

因此,我面临一个非常令人厌恶和奇怪的问题,并想知道是否有其他人来处理这个问题。 我从手机音乐图书馆获得MPMediaItem的原始数据,然后通过吉卜赛人协会将其送往其他地方。 在我提出问题时,我是从一卷零4a号档案中收集原始数据,看来是遗漏的。 例如,如果我从旁听的原始档案是7.4mb,那么从我的法典中发现的病情是7.3mb。 我做了一些研究,发现一个m4a文档实际上是一种cap,我认为,我没有仅仅依靠原始音乐数据,因此无法辨认。 我的守则给我提供了MPMediaItem的原始音乐数据。

                    NSError * error = nil;
                    MPMediaQuery *query = [MPMediaQuery albumsQuery];
                    NSArray * songs = query.items;  
                    MPMediaItem * song = [songs objectAtIndex:socket_data_index];  
                    AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL:[song valueForProperty:MPMediaItemPropertyAssetURL] options:nil];
                    AVAssetReader * reader = [[AVAssetReader alloc] initWithAsset:songAsset error:&error];                  
                    AVAssetTrack * songTrack = [songAsset.tracks objectAtIndex:0];
                    AVAssetReaderTrackOutput * output = [[AVAssetReaderTrackOutput alloc] initWithTrack:songTrack outputSettings:nil];
                    [reader addOutput:output];                         
                    [output release]; 



                    [reader startReading];

                    while (reader.status == AVAssetReaderStatusReading)
                    {                            
                        AVAssetReaderTrackOutput * trackOutput = (AVAssetReaderTrackOutput *)[reader.outputs objectAtIndex:0];
                        CMSampleBufferRef sampleBufferRef = [trackOutput copyNextSampleBuffer];                            
                        if (sampleBufferRef)
                        {
                            CMBlockBufferRef blockBufferRef = CMSampleBufferGetDataBuffer(sampleBufferRef);

                            size_t length = CMBlockBufferGetDataLength(blockBufferRef);
                            NSMutableData * data = [[NSMutableData alloc] initWithLength:length];
                            CMBlockBufferCopyDataBytes(blockBufferRef, 0, length, data.mutableBytes);

                            [data_to_return appendData:data];
                            [data release];

                            CMSampleBufferInvalidate(sampleBufferRef);
                            CFRelease(sampleBufferRef);
                        }
                    }

                    if (reader.status == AVAssetReaderStatusFailed || reader.status == AVAssetReaderStatusUnknown)
                    {
                        // Something went wrong. Handle it.
                    }

                    if (reader.status == AVAssetReaderStatusCompleted)
                    {                         

                       return [[[HTTPDataResponse alloc] initWithData:data_to_return] autorelease];
                    }

                    [reader release];

我确实并且将获得有关电话图书馆的p.mp3文档的正确数据,但就m4a而言,似乎有些部分缺失。

再次感谢你们花时间帮助我。

问题回答

我也遇到了同样的问题。 AVAssetReader只回收原始视听数据。 由于档案格式只是一个包含所有参与者需要击退档案的 frames方。 您可能注意到,出口档案中所有id3信息都缺失。

.m4a audio files are containers that wrap around aac audio data. You received only the audio data, without further information i.e. samplerate or the seek-table.

解决你的问题的办法是利用AVAssetExportSession将AVAssetTrack出口到电话档案中,并从那里将档案输入。 我对此事进行了具体审理,并撰写了一份工作文件。

The following Code is based on 果树例子:如何出口三毫米的音频资产:

// create the export session
AVAssetExportSession *exportSession = [AVAssetExportSession
                                       exportSessionWithAsset: songAsset
                                       presetName:AVAssetExportPresetAppleM4A];
if (nil == exportSession)
    NSLog(@"Error");

// configure export session  output with all our parameters
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
NSString *filePath = [NSString stringWithFormat: @"%@/export.m4a", basePath];

exportSession.outputURL = [NSURL fileURLWithPath: filePath]; // output path
exportSession.outputFileType = AVFileTypeAppleM4A; // output file type

[exportSession exportAsynchronouslyWithCompletionHandler:^{
    if (AVAssetExportSessionStatusCompleted == exportSession.status)
    {
        NSLog(@"AVAssetExportSessionStatusCompleted");
    }
    else if (AVAssetExportSessionStatusFailed == exportSession.status)
    {
        // a failure may happen because of an event out of your control
        // for example, an interruption like a phone call comming in
        // make sure and handle this case appropriately
        NSLog(@"AVAssetExportSessionStatusFailed");
    }
    else
    {
        NSLog(@"Export Session Status: %d", exportSession.status);
    }
}];

解决办法的下部分是,文件必须放在软盘上。 我仍在寻找更好的办法处理Mm4a档案。





相关问题
The codec could not be accessed. (-66672)

I am trying to convert caf file to m4a file using AudioUnit. I have implemented the code to convert. When I tried to run the application, I am getting following error message; couldn t set ...

what is AudioStreamBasicDescription for m4a file format

I have tried with more AudioStreamBasicDescription for m4a file format. Still I am getting some issues with that. Please anyone tell me the exact AudioStreamBasicDescription for m4a file format.

How to record voice in .m4a format

Already I have created an iPhone application to record. It will record in .caf file. But I want to record in .m4a format. Please help me to do this. Thanks.

flash audio player for m4a (AAC) audio file embedded in html

I m looking for a (free) flash player that I can embed in my site and use to play a .m4a (.mp4 with AAC audio) file that will be obtained using a URL (i.e. it s not local to the server hosting the web ...

WPF MediaElement: SpeedRatio not working for .m4a files?

I m working with a simple mediaplayer based on this msdn example where the user can control volume, playback speed (SpeedRatio) and seek (Position) using 3 sliders. Everything works correctly when I ...

How to read tags out of m4a files in .NET?

I ve got some heavily modified code that ultimately came from the Windows Media SDK that works great for reading tags out of MP3 and WMV files. Somewhere along the line, Windows Media Player added ...

热门标签