Skip to main content

Play Video Files on i.MX 8M Plus

You can upload .mp4 video files to your virtual i.MX 8M Plus board or provide a URL to play videos in a loop. This page contains the following sections that explain the process:

Open the GStreamer Multimedia Application

To open GStreamer:

  1. Create a virtual i.MX 8M Plus board running Yocto Linux version 2.2.0.

    Create i.MX 8M Plus Board

  2. Open the Terminal by clicking the second icon in the top-left of the device's display. You may prefer to open the display to a new window by clicking Pop Out towards the top-right.

    Open Terminal

  3. Run the following command in Terminal to launch GStreamer.

    gst-launch-1.0 v4l2src device=/dev/video4 ! waylandsink

    Terminal Command

  4. After a few seconds, you should see the video player open along with a message that your camera is not enabled.

    GStreamer Opened

  5. Open the Camera & Microphone settings under the Sensors tab and enable the sensors.

Play Video Using the Web Interface

The i.MX 8M Plus device supports video playback from your webcam, by uploading a file, or by sharing the video's URL.

Use Your Webcam

To use your webcam:

  1. After you enable the camera and microphone sensors, allow the browser to access your computer's built-in webcam and microphone. (This process will vary depending on your browser.)

  2. Confirm that you can see your computer's sensors appear under CAMERA and MICROPHONE.

    Confirm sensors

  3. You should see your webcam video appear on GStreamer.

Upload a File - Web Interface

To upload a file using the web interface:

  1. After enabling the virtual camera and microphone in the Sensors tab, upload the .mp4 video file. You do not need to allow the browser to access your local computer's physical camera and microphone.

    Upload the `.mp4` video file

  2. When the upload completes, click PLAY VIDEO. The video should play on GStreamer in a loop.

To link to a URL using the web interface:

  1. After enabling the camera and microphone in the Sensors tab, enter a URL to a .mp4 video and click PLAY VIDEO. You do not need to allow the browser to access your local computer's physical camera and microphone.

    Enter a URL

  2. The video should play on GStreamer in a loop.

Play Videos Using API and POST Requests

You can also use the command line to play multimedia files.

Start with GStreamer opened (gst-launch-1.0 v4l2src device=/dev/video4 ! waylandsink).

Upload a File - API and POST Requests

To upload a file using the AVH API:

  1. Use the AVH API to acquire the device instance.

  2. Upload the .mp4 file to that instance.

    const videoImage = await instance.uploadImage('media', $LOCATION_OF_AN_MP4_ON_YOUR_LOCAL_DISK, '$ANY_ARBITRARY_STRING')
  3. Note the imageId that is returned.

  4. Make a POST request to /api/v1/instances/${instanceId}/play with the following body.

    {
    instanceId,
    imageId
    }
  5. Verify that you can see the video playing.

Link to a URL - API and POST Requests

To link to a URL using the AVH API:

  1. Use the AVH API to acquire the device instance.

  2. Make a POST request to /api/v1/instances/${instanceId}/play with the video URL in the body.

    {
    instanceId,
    url: 'http://null.to/test.mp4'
    }
  3. Verify that you can see the video playing.