maitrungduc1410/react-native-video-trim

Black screen on trimming and enquiry for min duration

Closed this issue · 13 comments

For some videos, if it is trimmed from the beginning to length 3sec(min), then the video contains only black frames(fully) but the voice plays.

There is no option to set min duration limit(default is 3 secs but if I use video with length less then 3secs then the trimmer gives error that video shorter than 3sec, can't proceed)

version: latest(1.0.16)
device : android (multiple versions) , both of the issues are not there in iOS

is it possible for you to provide your input video for me to test?

also provide your code

Sure, here it is https://drive.google.com/file/d/1xC-irLvaRgOA174TzSp2ujZFTUcMj8DD/view?usp=sharing

Code:

const handleTrim = async () => {
        if (selectedMediaObj) {
            setIsLoading(true);
            await showEditor(selectedMediaObj?.uri, {
                maxDuration: maxAllowedVideoLength,
                saveToPhoto: false,
            });
        }
    };
useEffect(() => {
        const eventEmitter = new NativeEventEmitter(NativeModules.VideoTrim);
        const subscription = eventEmitter.addListener(
            'VideoTrim',
            async event => {
                switch (event.name) {
                    case 'onShow': {
                        break;
                    }
                    case 'onHide': {
                        break;
                    }
                    case 'onStartTrimming': {
                        break;
                    }
                    case 'onFinishTrimming': {
                        if (mediaObj?.uri) {
                            const obj = { ...mediaObj };
                            obj.uri = `file://${event?.outputPath}`;
                            setMediaObj(obj);

                            setIsLoading(false);
                        } else {
                            onClose();
                        }

                        break;
                    }
                    case 'onCancelTrimming': {
                        setIsLoading(false);
                        break;
                    }
                    case 'onError': {
                        onClose();
                        break;
                    }
                }
            },
        );

        return () => {
            subscription.remove();
        };
    }, [mediaObj]);

@amosaxe can I confirm that your issue happened on Android only.

iOS works fine?

yes iOS works fine.

Hi, I'm trying to reproduce your issue but it's working fine, video saved to Gallery (Photos) with video + audio

Yes it is getting saved but using react-native-video player the video frames remains blank….can it be react-native-video issue, or anything else you are aware of?

yes, high chance.

You can do this to test:

  • do trimming again with same video
  • open the output video in rn-video-trim, it uses VideoView on Android, if it shows okay then I think no issue at all :)

btw, pls upgrade to 1.0.17, I added support for minDuration

Hmm, I tried out the steps as you mentioned, that works. The issue occurs only with those video that are trimmed to 3 second, also that too not with all videos, will look in RN-video side. Thanks

Thanks for the update and support for minDuration, but after the update it comes like below (with or without the usage of the minDuration prop, i tried with minDuration > 0), seems like its a bug.
Screenshot 2024-03-02 at 2 06 30 PM

Hi @maitrungduc1410 , can you help with this?

Hmm, I tried out the steps as you mentioned, that works. The issue occurs only with those video that are trimmed to 3 second, also that too not with all videos, will look in RN-video side. Thanks

Thanks for the update and support for minDuration, but after the update it comes like below (with or without the usage of the minDuration prop, i tried with minDuration > 0), seems like its a bug.

for this issue, what's your code + input video can I get?

hi @amosaxe pls upgrade to v2, Android UI is completely revamped, synced with iOS

Hi @maitrungduc1410, thanks for the update and apologies for not reverting last time, had missed this. Will check it out today. Kudos!