5 Replies
      Latest reply: Sep 21, 2016 3:35 AM by eskimo RSS
      JP46 Level 1 Level 1 (0 points)

        How i can save video from photo library in Core Data?

         

        When i want to save images, i use UIImagePNGRepresentation and save in Core Data like a data binary, but videos?

        • Re: Saving videos to Core Data?
          KMT Level 8 Level 8 (9,675 points)

          I would save them elsewhere and only add a link string into your db.

          • Re: Saving videos to Core Data?
            JP46 Level 1 Level 1 (0 points)

            Any help?

              • Re: Saving videos to Core Data?
                eskimo Apple Staff Apple Staff (7,835 points)

                How big do you expect these videos to be?  If they’re even remotely large (at most 64 KiB) you really do want to store them in an external file and reference them from Core Data as suggested by KMT.

                Share and Enjoy

                Quinn “The Eskimo!”
                Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                let myEmail = "eskimo" + "1" + "@apple.com"

                  • Re: Saving videos to Core Data?
                    JP46 Level 1 Level 1 (0 points)

                    The videos would be recorded with the iPhone camera so they will be larger than 64KiB.

                    What can i do?

                    Store in a cloud or device?

                    And how?

                    Thanks.

                      • Re: Saving videos to Core Data?
                        eskimo Apple Staff Apple Staff (7,835 points)

                        Store in a cloud or device?

                        It seems like you should base that decision on the user experience you want, which isn’t something I can advise you on.

                        What can i do?

                        There’s two basic strategies here:

                        • Core Data has the notion of attributes that use external storage.  This is a good way to store large, relatively immutable chunks of data in your Core Data store.

                        • Alternatively, you could manage the videos as an entirely separate file and just save a reference to that file; this could be as simple as putting all the files in a known directory and storing the file name in the Core Data store.

                        For large videos I’d probably go with the second choice because you’re never going to want to load this context into memory en masse.

                        Share and Enjoy

                        Quinn “The Eskimo!”
                        Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                        let myEmail = "eskimo" + "1" + "@apple.com"