2

In my app a video is recorded by the user. When the user finishes recording, the video is then compressed using a compression algorithm which returns the video as NSData. I am then writing the data to a file and saving it to my server.

I am retrieving the saved videos and displaying them on a tableView. In theory there could be dozens of videos on the feed.

When I retrieve a video from the server and decompress it, I am stuck with an NSData object.

I am looking for help turning this object into an AVAsset without saving the file to the device.

Any help is appreciated

bobawgg
  • 107
  • 5
  • 1
    you don't need to save it to a file, you can directly convert NSData to AVAsset, but then you would need to keep the assets in ram and if you have a dozen if them then you might run into memory issues. so it would be best to keep them in a file and convert them to AVAsset if needed – Mohsen Shakiba Jul 26 '16 at 06:38
  • 2
    Ive been struggling trying to convert the NSData object into an AVAsset.. If you wouldn't mind, could you give me an example of how you would do that? – bobawgg Jul 27 '16 at 23:43
  • 1
    I would like a solution for this too. That way I can use App Slicing from Asset Catalogs on video files. Otherwise this would lose the point to do it, if I had to write temporary files from Asset Catalog data. Since Asset Catalog data is accessed over `NSDataAsset`, I see no way to get URL from it. – Legoless Sep 05 '17 at 23:08

1 Answers1

0

I extended NSDataAsset to conform to AVAssetResourceLoaderDelegate protocol and I extended AVURLAsset to init using a NSDataAsset.

You can find my solution in this thread: https://stackoverflow.com/a/69298570/15042552