• 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
ACFLACEncoder loses an input frame?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ACFLACEncoder loses an input frame?


  • Subject: ACFLACEncoder loses an input frame?
  • From: "Stephen F. Booth" <email@hidden>
  • Date: Wed, 21 Nov 2007 08:34:17 -0800

I'm not sure if this is an appropriate forum for this message, so apologies in advance if it isn't.

I've been playing with the FLAC codec shipped in /Developer/Examples/ CoreAudio/AudioCodecs. I've noticed several interesting things when using this codec.
1) I am able to use afconvert to convert files into the FLAC format, packaged in a CAF file, and to convert the CAF/FLAC to other formats. Very nice!
2) The encoder appears to throw away a single packet of input (the last packet).


As an example of #2, I have a 5-second mono pink noise sample at 44.1 kHz, so it contains 220500 frames of audio:

Macintosh:Release-Tiger+ me$ ./afinfo ~/Music/Samples/ref_pink.wav
File: /Users/me/Music/Samples/ref_pink.wav
File type ID: WAVE
Data format: 1 ch, 44100 Hz, 'lpcm' (0x0000000C) 16-bit little- endian signed integer
no channel layout.
estimated duration: 5.000 sec
audio bytes: 441000
audio packets: 220500
bit rate: 705600 bits per second
maximum packet size: 2
packet size upper bound: 2
audio data file offset: 44
optimized
Source Has Channel Layout: FALSE
Source Has Region List: FALSE
Source Has Marker List: FALSE
----


I can convert it to CAF/FLAC using:
./afconvert ~/Music/Samples/ref_pink.wav -f 'caff' -d 'flac' /tmp/ ref_pink.caf


but the output file has the following properties:

Macintosh:Release-Tiger+ me$ ./afinfo /tmp/ref_pink.caf
File: /tmp/ref_pink.caf
File type ID: caff
Data format: 1 ch, 44100 Hz, 'flac' (0x00000001) 0 bits/channel, 0 bytes/packet, 4608 frames/packet, 0 bytes/frame
no channel layout.
estimated duration: 4.896 sec
audio bytes: 343688
audio packets: 47
audio 215892 valid frames + 0 priming + 684 remainder = 216576
bit rate: 559864 bits per second
maximum packet size: 13300
packet size upper bound: 13300
audio data file offset: 24576
optimized
Source Has Channel Layout: FALSE
Source Has Region List: FALSE
Source Has Marker List: FALSE
----


It's interesting that the FLAC produced by this codec has 4608 frames/ packet, while FLAC generated by the command line encoder uses 1152. In any case, the original 220500 frames minus a packet of 4608 frames = 215892 frames, which is what the output file contains. So it appears the encoder discards a single packet of output along the way. If I convert the CAF/FLAC back to a WAVE file, the data loss is verified:

Macintosh:Release-Tiger+ me$ ./afinfo /tmp/ref_pink.wav
File: /tmp/ref_pink.wav
File type ID: WAVE
Data format: 1 ch, 44100 Hz, 'lpcm' (0x0000000C) 16-bit little- endian signed integer
no channel layout.
estimated duration: 4.896 sec
audio bytes: 431784
audio packets: 215892
bit rate: 705600 bits per second
maximum packet size: 2
packet size upper bound: 2
audio data file offset: 4096
optimized
Source Has Channel Layout: FALSE
Source Has Region List: FALSE
Source Has Marker List: FALSE
----


I've used Audacity to visually verify that it is the last 4608 frames that are discarded.

I came across this while attempting to write an AudioFile subclass for native FLAC files using this codec. Finally, on to my two questions: should I file a radar on this? Is there any more documentation floating around on writing an AudioFile for a new format besides the RAW component example?

Stephen
_______________________________________________
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


  • Prev by Date: AAC recording issues
  • Next by Date: Anyone know of any pitch recognition DSP libraries ?
  • Previous by thread: Re: AAC recording issues
  • Next by thread: Exclusive application access to audio device
  • Index(es):
    • Date
    • Thread