maitrungduc1410 / react-native-video-trim

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

Black screen on trimming and enquiry for min duration #39

Open amosaxe opened 2 months ago

amosaxe commented 2 months ago

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

maitrungduc1410 commented 2 months ago

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

also provide your code

amosaxe commented 2 months ago

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]);
maitrungduc1410 commented 2 months ago

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

iOS works fine?

amosaxe commented 2 months ago

yes iOS works fine.

maitrungduc1410 commented 2 months ago

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

amosaxe commented 2 months ago

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?

maitrungduc1410 commented 2 months ago

yes, high chance.

You can do this to test:

maitrungduc1410 commented 2 months ago

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

amosaxe commented 2 months ago

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
amosaxe commented 2 months ago

Hi @maitrungduc1410 , can you help with this?

maitrungduc1410 commented 2 months ago

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?