• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AVAssetReader how to get file size
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AVAssetReader how to get file size


  • Subject: Re: AVAssetReader how to get file size
  • From: Andy Davidson <email@hidden>
  • Date: Thu, 16 Jun 2016 15:28:42 -0700
  • Thread-topic: AVAssetReader how to get file size

Hi Kevin

The following code works

Thanks 
Andy

    [assetWriterInput requestMediaDataWhenReadyOnQueue:mediaInputQueue

                                            usingBlock: ^

     {

         // NSLog (@"top of block");

         while (assetWriterInput.readyForMoreMediaData) {

             CMSampleBufferRef nextBuffer = [assetReaderOutput copyNextSampleBuffer];

             if (nextBuffer) {

                 // append buffer

                 [assetWriterInput appendSampleBuffer: nextBuffer];

                 

                 convertedByteCount += CMSampleBufferGetTotalSampleSize (nextBuffer);

                 

                 // http://stackoverflow.com/questions/19119422/convert-caf-file-to-wav-file-with-progress-bar-in-ios

                 CMTime progressTime = CMSampleBufferGetPresentationTimeStamp(nextBuffer);

                 

                 CMTime sampleDuration = CMSampleBufferGetDuration(nextBuffer);

                 if (CMTIME_IS_NUMERIC(sampleDuration))

                     progressTime= CMTimeAdd(progressTime, sampleDuration);

                 float dProgress= CMTimeGetSeconds(progressTime) / CMTimeGetSeconds(songAsset.duration);

                 NSLLog(@"progress:%f",dProgress);

                 


             } 


From: Kevin Dixon <email@hidden>
Date: Thursday, June 16, 2016 at 1:15 PM
To: Andrew Davidson <email@hidden>
Cc: coreaudio-api <email@hidden>
Subject: Re: AVAssetReader how to get file size

You will have to represent your progress bar with the duration I think. You can look at the current format settings (e.g. Sample Rate, etc) to determine how much data you've pulled out with copyNextBuffer as you go as a percentage of duration

Kevin

On Tue, Jun 14, 2016 at 12:33 PM, Andy Davidson <email@hidden> wrote:
I need to read an asset from a users iPod library and convert it to LPCM. I want put up an import progress bar. Any idea how I can find the number of bytes I need to read? PMediaItemPropertyPlaybackDuration returns the play back duration in sec. 



    AVAssetReader *assetReader = [[AVAssetReader assetReaderWithAsset:songAsset

                                                                error:&assetError]

                                  retain];

   AVAssetReaderOutput *assetReaderOutput = [[AVAssetReaderAudioMixOutput

                                               assetReaderAudioMixOutputWithAudioTracks:songAsset.tracks

                                               audioSettings: nil]

                                              retain];

    if (! [assetReader canAddOutput: assetReaderOutput]) {

        return;

    }

    [assetReader addOutput: assetReaderOutput];



    fileSize = [assetReader ????]
Thanks in advance

Andy

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >AVAssetReader how to get file size (From: Andy Davidson <email@hidden>)
 >Re: AVAssetReader how to get file size (From: Kevin Dixon <email@hidden>)

  • Prev by Date: Re: AVAssetReader how to get file size
  • Next by Date: Re: pthread_cond_signal and priority inversion
  • Previous by thread: Re: AVAssetReader how to get file size
  • Next by thread: Audio Unit Extension using an audio graph
  • Index(es):
    • Date
    • Thread