How do I get the dimensions of video file, I am using <Video /> in expo-av

Please provide the following:

  1. SDK Version: 5.0.3
  2. Platforms: all
  3. Regarding Video in expo-av.

Is there a way to get the original dimensions of the file i am about to play?

I have tried onLoad in the props but the response does not contain any dimension information:

onLoad={(response) => {

gets me:

Object {
  "androidImplementation": "SimpleExoPlayer",
  "didJustFinish": false,
  "durationMillis": 2834,
  "isBuffering": true,
  "isLoaded": true,
  "isLooping": true,
  "isMuted": true,
  "isPlaying": true,
  "playableDurationMillis": 2800,
  "positionMillis": 0,
  "progressUpdateIntervalMillis": 0,
  "rate": 1,
  "shouldCorrectPitch": false,
  "shouldPlay": true,
  "uri": "/assets/video/myVideo.mp4",
  "volume": 1,

Any suggestions?

You can get the dimensions of videos from expo-image-picker of videos on MediaLibrary.

let result = await ImagePicker.launchImageLibraryAsync({
    mediaTypes: ImagePicker.MediaTypeOptions.Videos,
    allowsEditing: true, // works on iOS
    quality: 1,
    base64: true,

let videoHeight = result.height;
let videoWidth = result.width;

But since you are using asset files and ImagePicker doesn’t have access to assets, you can hardcode the dimensions beforehand in the code itself, because the asset files are static and don’t change.

Hi @mrbestrongr

This is probably overkill and I have not tried this myself, but you could possibly use FFmpegKit to get the dimensions.

Here’s how you could install it along with the config plugin:

There are some examples here, including some FFprobe ones:

The following Stack overflow answer shows how you can do this on the command line, which I think should give you an idea of how to do it using FFmpegKit:

You might also find useful examples in the FFmpegKit ReactNative test app code, for example these.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.