Open sindresorhus opened 1 year ago
Apple reply:
Is the AVAsset a QuickTime movie file (.mov) or an MPEG file (e.g., .mp4)? These correspond to the UTI types AVFileTypeQuickTimeMovie and AVFileTypeMPEG4.
If so, have you tried:
rewrite the movie header back to the file using the AVMovie method defined in AVMovie.h:
Use the AVMovieWritingAddMovieHeaderToDestination AVMovieWritingOptions value to rewrite the header to the movie file while leaving existing media data in place. You may want to do this in a copy of the source media file.
There’s a WWDC 2015 session video “Editing Movies in AVFoundation” that introduces the API at https://developer.apple.com/wwdc15/506.
If the AVAsset is for other kinds of files than movie files, please let us know the kinds of assets that are important to you for such support.
My reply:
Thanks for sharing. That is very useful. My use-case is editing the metadata of audio (M4A) files. I’ll try to see if it works with audio-only files too.
I do think it would be useful to have an easy to use API on AVAsset for this (and for video). For example, await AVAsset.setMetadata([AVMetadataItem], for url: URL)
.
Description
It’s currently very difficult to simply modify some metadata of an existing video/audio file. You first have to load the file and then use a bunch of complicated APIs to export a new file with the new metadata. In addition, the process is extremely slow. It would be nice if you could simplify modify the metadata directly and AVFoundation would only modify the metadata part of the file. For example, AVAudioRecorder doesn’t support adding metadata, so if you want to add some metadata, you first have to record, then load the file, then add metadata nad export a new file. That’s a lot of wasted developer effort and wasted CPU and energy.