maitrungduc1410 / react-native-video-trim

Video trimmer for React Native App
MIT License
37 stars 14 forks source link

Question: How can we delete files created after trimming. #21

Closed AnsOfficial closed 2 months ago

AnsOfficial commented 4 months ago

How can we delete files created after trimming because I noticed increased App data @maitrungduc1410

maitrungduc1410 commented 4 months ago

At the moment files stored in cache and auto deleted after sometime

But I'll push update to support manually delete files

ibelgin commented 3 months ago

@maitrungduc1410 In Android there is an issue with this. when I navigate to the next screen. the file gets deleted and I get the below error message.

Image source "/storage/emulated/0/Android/data/io.icare/cache/trimmedVideo_20240119_205159.mp4" doesn't exist

but it's working fine on iOS. is there any solution for this getting autodeleted?

maitrungduc1410 commented 3 months ago

@maitrungduc1410 In Android there is an issue with this. when I navigate to the next screen. the file gets deleted and I get the below error message.

Image source "/storage/emulated/0/Android/data/io.icare/cache/trimmedVideo_20240119_205159.mp4" doesn't exist

but it's working fine on iOS. is there any solution for this getting autodeleted?

I'm working on some major update which will resolve this issue

maitrungduc1410 commented 3 months ago

Hi @AnsOfficial @ibelgin , please upgrade to 1.0.12, remember to re-run pod install

From now on for iOS + Android, file will be stored in app storage instead of cached dir, and it won't be deleted by system anymore.

Also you have control of listing+deleting any file you want using:

cleanFiles() // delete all files in app storage
deleteFile(someFilePath) // delete a file in app storage
listFiles() // list all files in app storage

You can also auto delete output file from app storage after it has been saved in Photo Library:

showEditor(url, {
  removeAfterSavedToPhoto: true,
})

Checkout README for usage

ibelgin commented 3 months ago

@maitrungduc1410 Thank you. Let me check on it.

ibelgin commented 3 months ago

@maitrungduc1410 right now I'm getting this error.

Screenshot 2024-01-22 at 14 53 10
maitrungduc1410 commented 3 months ago

Hi @ibelgin

rc (return code) is 1, which is unsuccessful.

Can you try with another video? Also please try on real device instead

If possible can you provide me the input file which is having issue?

ibelgin commented 3 months ago

Sure.

ibelgin commented 3 months ago

@maitrungduc1410 It's working on Android but the issue is with ios now I gave the maxDuration as 5 but the video is getting trimmed to 6 seconds the first second is black.

Screenshot 2024-01-24 at 15 53 15 Screenshot 2024-01-24 at 15 53 36
maitrungduc1410 commented 3 months ago

@ibelgin this is known issue when trimming using FFMPEG: https://superuser.com/questions/1222801/black-frames-at-beginning-of-video-file-when-file-cut

basically it happens in some cases when the starting time does not correspond to an I-frame

I'm trying to resolve this, will update once done

ibelgin commented 3 months ago

@maitrungduc1410 Thank you.

ibelgin commented 3 months ago

@maitrungduc1410 can this issue be resolved ?

maitrungduc1410 commented 2 months ago

hi @ibelgin I fixed the issue, it's working now, please upgrade to 1.0.16 and try again.

this is what I figured out when using FFMPEG:

# before 1.0.16, has black frames
ffmpeg -i input.MOV -ss 00:00:00 -to 00:00:30 -c copy output1.mp4

# new in 1.0.16, works, no black frame
ffmpeg -ss 00:00:00 -to 00:00:30 -i input.MOV -c copy output2.mp4

Original can be found here

ibelgin commented 2 months ago

@maitrungduc1410 Hey Thank you! it's working perfectly.