mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.5k stars 1.09k forks source link

✨ Return mime (content type) from video recordings #153

Open jphilipstevens opened 3 years ago

jphilipstevens commented 3 years ago

What

I noticed that the Video File object does not include the mime type. Including it in the VideFile would benefit those using the video to send over networks.

Alternatives/Workarounds

I am going to use https://www.npmjs.com/package/react-native-mime-types in order to get the mime from the file

import * as mime from "react-native-mime-types";

camera.current.startRecording({
    flash: flash,
    onRecordingError: (error) => {
        onStoppedRecording();
    },
    onRecordingFinished: (video) => {
        const videoSource = {
            path: video.path,
            mimeType: mime.lookup(video.path),
        };
        onMediaCaptured(video, "video");
        onStoppedRecording();
    },
});
jphilipstevens commented 3 years ago

threw this one in quickly. Let me know if you need more details

mrousavy commented 3 years ago

I believe videos are always mov on iOS and mp4 on Android, but that's a good feature request - I'll take a look when I can 👍

jphilipstevens commented 3 years ago

@mrousavy point me to the native code where I set this and I can code it locally. We use patch-project so I think I could make some tweaks on 1.x and experiment. After a few weeks of making sleep optional, I may finally have some time to experiment hahahaha

erennyuksell commented 1 year ago

@mrousavy can we add this feature?

mrousavy commented 1 year ago

@erennyuksell you can add this feature if you want yes

mrousavy commented 9 months ago

Hey @jphilipstevens - what approach did you go for? I'm not sure how I would get the mime-type, but effectively it just always is video/${codec}, where codec is either mp4 or mov, right?

maxbbb commented 7 months ago

Came across this looking into something unrelated, but wanted to note the mime-type for mov is video/quicktime, not video/mov. So for iOS it would be video/quicktime and Android video/mp4