libvlc: Is there a method to get data buffer before decoding? - vlc

I want to parse mpeg user data and use it for specific purpose.
I've successufully have been able to get decoded frames from libvlc,
using libvlc_video_set_callbacks(). But it is pixel data after "decoding".
I want to get data before decoding, i.e., an encoded data buffer.
Is there an API in libvlc?
Thanks.

No, there is no API in libvlc to get access to the raw buffers it reads from input media. Patch welcome!

Related

How to read .eeg file from BrainVision Core Data Format in python?

I have a dataset in BrainVision Core Data Format which consists of the header file (.vhdr), marker file (.vmrk), and raw EEG data (.eeg) file for each subject. I know that python has mne.io.read_raw_brainvision() function which reads header file and returns a raw object containing BrainVision data. I do not know how to proceed after that or how can I read .eeg file. Thanks
Overall, MNE Python has a great tutorial on handling raw EEG data: https://mne.tools/stable/auto_tutorials/raw/10_raw_overview.html#the-raw-data-structure-continuous-data
You can follow this tutorial and use the file loading with mne.io.read_raw_brainvision() as used in this more specific tutorial that happens to work with sample data in the BrainVision Core Data Format: https://mne.tools/stable/auto_tutorials/time-freq/50_ssvep.html#frequency-tagging-basic-analysis-of-an-ssvep-vssr-dataset

How to read binary QR Code with AVFoundation?

Is it possible to read a binary encoded QR Code with AVFoundation?
I can get a AVMetadataMachineReadableCodeObject object of .type AVMetadataObjectTypeQRCode, however this only has a stringValue property, which won't work, because the data contained in the QR Code can't be converted to a string friendly representation.
Should I use ZXing instead?
Thanks.
The raw data does exist in your AVMetadataMachineReadableCodeObject, but it's not available through a public getter.
However, you can use KVO to extract it, but Apple might reject your app. Also, future iOS versions might change their private APIs and your code could become invalid (because of the hardcoded private keys).
Swift:
readableCodeObject.valueForKeyPath("_internal.basicDescriptor")!["BarcodeRawData"]
Objective-C
[readableCodeObject valueForKeyPath:#"_internal.basicDescriptor"][#"BarcodeRawData"];
I tested this for iOS 8 and 9.
I was able to solve this issue by Base64 encoding the data in the QR code.
This obviously won't work if you're not also generating the QR codes but could be option for people that are.
We were running into the upper limit of data that can be stored in a QR code but by compressing the data (we used zlib) and then Base64 encoding the compressed data, so long as your data compresses to less than 75% of its original size you get some additional capacity and can use the stringValue property to get your data back out, you just have to Base64 decode and then decompress to get the original data back.
Even if you're starting with binary data that isn't very compressible, so long as you can handle the overhead of Base64 and still be within the limitations of QR codes this may be a viable option that avoids working around the fact that AVMetadataMachineReadableCodeObject seems to want to work with string values.
You can use a CIDetector to get to a CIQRCodeFeature which has a symbolDescriptor which has a errorCorrectedPayload which contains the data.
Only problem is that this data still includes QR code headers, like ECI etc... so you still need to interpret the bits.
I summed it up in a post here.
Inspired by previous answers and other sites, I have created a gist that allows to extract binary from QR code or Aztec code, without using private APIs nor other library. It is a AVMetadataMachineReadableCodeObject extension presenting a binaryValue.
However, it only runs on iOS 11 and later, because of the CIQRCodeDescriptor use.
It is available here : https://gist.github.com/PetrusM/267e2ee8c1d8b5dca17eac085afa7d7c
For QR codes, it works only with 100% binary ones. But if they contain further parts, you can easily adapt it.

Accessing and Sending raw image data to API

I need to be able to access the raw image data from a loaded photo. Originally we were supposed to use Base64, however the API creator has changed it to raw image data.
In SWIFT, how would I accomplish the following?
I'm currently using Alamofire for my networking, but I'm not sure that it will work for this part of the API.
I already have the image resource as a variable to access, I just need to know how to get the raw data, and then formulate a POST request with just that data as the body of the request. A method with a callback would be awesome.
UIImagePNGRepresentation
UIImageJPEGRepresentation
These method can encode a UIImage to NSData.
upload code:
Alamofire.upload(.POST, "http://your.org/upload", data: imageData)

Getting the raw base64 content out of an attachment in Indy?

So I have an attachment on my incoming Pop3 message,
Msg.MessageParts.Items[msgpart] as TidAttachmentFile
but, is it possible to get the content of this attached file in the format specified by Msg.MessageParts.Items[msgpart].ContentTransfer (so base64 ascii) instead of creating a temp file, calling SaveToFile, and then re-reading the file and re-connverting back to base64?
If TIdMessage.NoDecode is set to False, then no, it is not possible. When NoDecode is False, TIdMessageClient decodes the email as it is being read off the socket and places decoded binary data into attachment objects. The only way to get the original base64 data is to set TIdMessage.NoDecode to True and parse the raw email data manually (it is stored as-is in the TIdMessage.Body) as you would effectively be disabling TIdMessageClient's entire decoding system.
On the other hand, if you just want to avoid the temp file, you can use the TIdMessage.OnCreateAttachment event to have Indy create TIdAttachmentMemory objects instead of the default TIdAttachmentFile objects. The base64 will still be auto-decoded and stored as binary in the attachment, but at least the attachment would be solely in memory so your re-encode would be faster.

What is the difference between AudioFileOpenURL and ExtAudioFileOpenURL?

If I use ExtAudioFile in conjunction with a remoteIO audio unit, I can use ExtAudioFileSetProperty with kExtAudioFileProperty_ClientDataFormat to convert the audio format read from disk into a device native format (with canonical au tags).
It seems when I use AudioFileOpenURL and related methods I can't use AudioFileSetProperty with kAudioFilePropertyDataFormat in the same way.
Why can't I convert any audio file to the client data format through this slightly higher level api?
The AudioFile API came first, and is the lower-level of the two. ExtAudioFile is essentially a wrapper around an AudioFile and an associated AudioConverter. It is ExtAudioFile's internal AudioConverter that provides the functionality to convert to a specific client format.

Resources