LiTr icon indicating copy to clipboard operation
LiTr copied to clipboard

FileNotFoundException when transforming the video

Open RishabJaiswal opened this issue 2 years ago • 9 comments

I am getting the following error java.io.FileNotFoundException: /storage/emulated/0/Movies/MyApp/video.mp4: open failed: EEXIST (File exists)

This happens while using the below api specifically on Android Devices above Android 10. It works fine below Android 10.

 MediaTransformer.transform(@NonNull String requestId,
                          Uri inputUri,
                          String outputFilePath,
                          MediaFormat targetVideoFormat,
                          MediaFormat targetAudioFormat,
                          TransformationListener listener,
                          TransformationOptions transformationOptions) 

Inside the above api MediaTargetException is thrown

com.linkedin.android.litr.exception.MediaTargetException: java.io.FileNotFoundException: /storage/emulated/0/Movies/MyApp/video.mp4: open failed: EEXIST (File exists)Media transformation failed for job id: null
Failed to open the media target for write.
Output file path or Uri encoded string: /storage/emulated/0/Movies/MyApp/video.mp4
MediaMuxer output format: 0

I believe this might have to do with the new File system changes introduced from Android 10

RishabJaiswal avatar Mar 15 '22 10:03 RishabJaiswal

Thank you for reporting this! We will look into it.

izzytwosheds avatar Mar 17 '22 10:03 izzytwosheds

I think we should open a FileOutputStream or provide FileDescriptor just like the android-transcoder library does. Please find it here

RishabJaiswal avatar Mar 17 '22 11:03 RishabJaiswal

Yes, I am planning to use a FileDescriptor as well.

izzytwosheds avatar Mar 17 '22 11:03 izzytwosheds

There is a PR in flight, that should help. We already use FileDescriptor in MediaMuxerTarget but it was not exposed via transform method. It is now: https://github.com/linkedin/LiTr/pull/182 Let me know if this solves your issue.

izzytwosheds avatar Mar 25 '22 16:03 izzytwosheds

Thank you so much! Are we expecting a new release for the SDK with this fix?

RishabJaiswal avatar Mar 30 '22 06:03 RishabJaiswal

Yes. We are preparing a new release. Meanwhile, you can try a snapshot release by adding following to your gradle build files (I didn't try it myself yet): repositories { maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } }

izzytwosheds avatar Mar 30 '22 11:03 izzytwosheds

Thank you !

RishabJaiswal avatar Mar 30 '22 11:03 RishabJaiswal

Can't find the snapshot. Please help.

RishabJaiswal avatar Mar 30 '22 12:03 RishabJaiswal

Version 1.5.0 is being released now. Let me know if it fixes your issue.

izzytwosheds avatar Apr 01 '22 20:04 izzytwosheds