question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CameraRoll.saveToCameraRoll saves local videos as static images, even when video extension is .MOV or .MP4. Fails when passing `video` as type

See original GitHub issue

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment: OS: macOS Sierra 10.12.6 Node: 6.11.3 Yarn: 1.0.2 npm: 5.3.0 Watchman: 4.9.0 Xcode: Xcode 8.3.3 Build version 8E3004b Android Studio: Not Found

Packages: (wanted => installed) react: 16.0.0-alpha.12 => 16.0.0-alpha.12 react-native: 0.48.4 => 0.48.4

Target Platform: iOS (10.2.1)

Steps to Reproduce

  1. Create a new project
  2. Use CameraRoll.getPhotos({first: 20,assetType: 'All'}) to retrieve camera roll items, ensure it works properly
  3. After selecting an item, try saving a new copy to camera roll using CameraRoll.saveToCameraRoll(item)

Expected Behavior

Photo selected from camera roll would be saved as a new image in camera roll.

Video selected from camera roll would be saved as a new video in camera roll.

Actual Behavior

Videos are saved as a static photo. If ‘video’ type is passed to CameraRoll.saveToCameraRoll(item, type) then the video does not get saved at all. The video I’m trying to save is a .MOV file (assets-library://asset/asset.mov?id=A9479A56-998A-4E4D-92BC-97A9F60E3930&ext=mov)

Photos are saved properly as static images.

Reproducible Demo

I created an Expo Snack: https://snack.expo.io/ryJvCtFoW

The above will grab the latest video from your device and attempt to save it to camera roll. It alerts the original URI as well as the newly generated URI to show that a .MOV will be saved as a .JPG.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

3reactions
jordangrantcommented, Feb 26, 2018

Hola amigos, was having issues with downloading a video using react-native-fetch-blob, and then saving to Camera Roll. Here’s how I did it.

  1. Downloading the video to temporary storage
downloadTheVideo() {
    RNFetchBlob
    .config({
      fileCache : true,
      // by adding this option, the temp files will have a file extension
      appendExt : 'mp4'
    })
    .fetch('GET', this.props.video.url)    //<-- url here was like https://aws.s3.videofile.mp4 for example
    .then((res) => {
      this.setState({path: res.path()});
      this.saveToCameraRoll()
    })
  }
  1. Now, the saveToCameraRoll() function I made looks like:
saveToCameraRoll() {
    CameraRoll.saveToCameraRoll(this.state.path).then(Alert.alert('Success', 'Saved to camera roll!'))
  }

Tried a few things, and this is what ended up working for my, so thought I’d share.

2reactions
taftycommented, Jan 9, 2018

@nikhammerellis For the MP4s, I used react-native-fetch-blob to save the MP4 file to the device and then, once the download was complete, passed the file path to saveToCameraRoll with a type of ‘video’.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native - cameraRoll.saveToCameraRoll isn't saving my ...
Same me, but when checklog with Xcode, it show "libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)" error and ...
Read more >
Cant save video to my Camera Roll (iOS 7.1)
Tried saving it from Dropbox but I get error saying "this type of video cannot be saved to this device". I mailed it...
Read more >
CameraRoll - React Native
Saves the photo or video to the camera roll or photo library. On Android, the tag must be a local image or video...
Read more >
How to Play, Record and Merge Videos in iOS and Swift
Learn the basics of working with videos on iOS with AV Foundation in this tutorial. You'll play, record and even do some light...
Read more >
How to change the default video output format on my iPhone ...
I have tried this online conversion tool, and it can still meet some of my daily conversion needs. For MOV to MP4, it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found