MPMediaItem get EXACT file size - ios

There is quite a lot posts out there that shows how to get the ESTIMATED file size of a MPMediaIteme. Such methods of using AVAssetExportSession gives a file size that is really off from the real size, like a file of 3M shows up as 10M. As there is no way to directly access a ipod-library:// schemed URL(at least not that I know of), I think I'm stuck with getting the file size indirectly.
I guess that the size is off because I set the preset to M4A when exporting, which may cause some transcoding when exporting, but if I set the preset to Passthrough, even with the timeRange set, the estimated size of the exporter will always give me zero.
How should I get the EXACT file size of a MPMediaItem in bytes?

As there is no way to directly access a ipod-library:// schemed URL(at least not that I know of)
So long as the asset is actually a file in the library (i.e. it's not something in the cloud), its asset URL is its assetURL. That is as close as you can get to a pointer to the file in storage; remember, you are sandboxed (the system is not going to let you mess about directly inside the directory where the user's songs are stored).

Related

Edit Photos via Photoshop on a server

I wart to create a web app where a user enters certain data via a form and then receives a custom rendered image. The image is from a smart object in a psd. It's kind of like a mock-up which definitely requires needs some photoshop filters to be properly rendered.
This should all happen in real time and should be doable from my understanding since the rendering of a single images doesn't need much computing power
I've done some research and haven't really found a solution the matches my problem. Is it necessary to run Photoshop on a server and then remotely run a photoshop script and then upload the generated image somewhere else?
I've used The After Effects Plugin Template by DataClay in the past which offers similar functionality but for video.
Looking forward to hearing your ideas.
Thanks
You can use the Dataclay plugin to handle still image exports out of After Effects. Make a single-frame duration composition in After Effects and rig the layers with the Templater plugin. Then use the PNG Sequence output module to render out a single frame.
From Dataclay's forums:
Exporting
A few extra steps are required to correctly render a project file as a PNG sequence using Templater. By default, a file rendered as a PNG sequence will have the frame number appended to the end of the file name, i.e.:
filename.png00000, filename.png00001, filename.png00002, etc.
In order to designate where in the filename the frame number should be added, we’ll need to use the output column. First, add a column named output to your data source. Next, add a filename with a set of brackets with five # signs to designate where the frame numbering should be added. For example:
filename[#####] would result in filename00001.png
or
[#####]filename would result in 00001filename.png

How do I write a newly-created AVMutableComposition to disk with minimal recompression?

I've built an AVMutableComposition with a video track and audio track, and concatenated (sequentially inserted) AVAssets from bunch of .mp4 files I've loaded from disk into it.
Now I want to write out the resulting composition to disk, using the exact same settings as the source material (they are all generated by the same app, a security camera system).
AVAssetExportSession demands a named preset. I could just choose something like AVAssetExportPresetHEVCHighestQuality but that implies a re-encoding, and I feel there should be a way to do this in a much more lossless way.
When I check the presets compatible with my composition, I get
["AVAssetExportPreset1920x1080", "AVAssetExportPresetLowQuality",
"AVAssetExportPresetAppleM4V720pHD",
"AVAssetExportPresetAppleM4VAppleTV", "AVAssetExportPresetAppleM4A",
"AVAssetExportPresetHEVCHighestQuality", "AVAssetExportPreset640x480",
"AVAssetExportPresetAppleProRes422LPCM",
"AVAssetExportPreset3840x2160", "AVAssetExportPresetHEVC3840x2160",
"AVAssetExportPresetAppleM4VWiFi",
"AVAssetExportPresetHighestQuality",
"AVAssetExportPresetAppleM4VCellular", "AVAssetExportPreset1280x720",
"AVAssetExportPresetMediumQuality",
"AVAssetExportPresetAppleM4V1080pHD",
"AVAssetExportPresetAppleM4V480pSD", "AVAssetExportPreset960x540",
"AVAssetExportPresetAppleM4ViPod", "AVAssetExportPresetHEVC1920x1080"]
Is there a better way?
Try using AVAssetExportPresetPassthrough.
As the documentation states, it does not show up in results from exportPresetsCompatibleWithAsset (for reasons not mentioned), but it generally works when writing mp4s or movs from compatible source assets, and it just collects and writes the sample data without any re-encoding.

Hybris Backoffice Maximum Upload Size

I am trying to upload a media file to its container.
Default value of maximum file size for uploading is 10 MB and it is defined at ext-backoffice\backoffice\project.properties like this :
# Constraint for maximum upload file size (in KB)
backoffice.fileUpload.maxSize=10000
How can i override this value?
After some research i found this link .
But sadly it does not work for me. Do you have any idea?
You can change the value of this property (or any property) on the hAC (if you are an admin). But the value will stay until the server is restarted
the best approach is to add the property backoffice.fileUpload.maxSize= the value you want on the local.properties so the server read it every time it starts

How to include a photo in Moderncv Casual

Well, to start with, I don't know much about Latex. I am failing to include a picture in to the document using "Moderncv Casual". A lot of the CV's and cover letter's template using:
\photo[64pt][0.4pt]{filename}
What's the deal with this? Is it not just to type the pictures's filename, compile, and the picture should be added to the document?
That's exactly it. The \photo macro is set up in such a way that it stores your input and makes it part of the CV title (set with \makecvtitle).
The reasoning behind this is to provide the end-user with a generic command to would capture a picture. However, depending on the template used, this picture may appear on the left/right/middle (or wherever). The generic input abstracts this placement from the rest of the code.
Specific to the command \photo; it is defined inside the class moderncv.cls file as:
\NewDocumentCommand{\photo}{O{64pt}O{0.4pt}m}
{\def\#photowidth{#1}\def\#photoframewidth{#2}\def\#photo{#3}}
An input like
\photo[64pt][0.4pt]{filename}
defines the photo to be kept in \#photo - it references the image file filename (with an image extension) - to have a width of 64pt (stored in \#photowidth) and frame width 0.4pt (stored in \#photoframewidth).

How can I extend the length of a memory-mapped file?

In Delphi 7, I open a file with CreateFileMapping then get a pointer by using MapViewOfFile.
How can I expand the memory and add some characters to the memory and have it saved to that file?
I have already opened the file with appropriate modes (fmOpenReadWrite, PAGE_READWRITE),
and if I overwrite the characters, it gets saved to the file, but I need to add extra values in the middle of the file.
If the file mapping is backed by an actual file and not a block of memory, then you can resize the file in one of two ways:
call CreateFileMapping() with a size that exceeds the current file size. The file will be resized to match the new mapping.
use SetFilePointer() and SetEndOfFile() to resize the file directly, then call CreateFileMapping() with the new size.
Both conditions are described in the documentation for CreateFileMapping().
You cannot resize file mapping created with CreateFileMapping when it's already created. See earlier discussion on the topic: Windows: Resize shared memory .

Resources