> ## Documentation Index
> Fetch the complete documentation index at: https://imsdkdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Sources

Every AI pipeline starts with a data source — the raw video or audio that the model will analyze. QIM SDK uses GStreamer plugins to connect your pipeline to whatever source you're working with: a video file for testing, a USB webcam on your desk, a built-in ISP camera on the device, or a live RTSP stream from a network camera.

Each source type produces frames in a slightly different format, but they all feed into the same pipeline structure. The sections below show the GStreamer snippet for each source type — copy the one that matches your setup and use it as the first stage of your pipeline.

<note>
  The examples on this page run commands on your device. You'll need SSH access with the device's IP address before proceeding. If you haven't done this yet, see the [Installation Guide](../installation).
</note>

<Steps>
  <Step title="Choose your source">
    Paste one of the following `export VIDEO_SOURCE` commands into your device shell:

    <AccordionGroup>
      <Accordion title="File input">
        Use a pre-recorded video file to test your pipeline. This is the easiest way to get started — you can replay the same clip repeatedly to validate your model.

        **1. Download sample video on your host machine**

        | File         | Download                                                                                                                                               | Save as     |
        | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- |
        | Sample video | <a href="https://github.com/qualcomm/sample-apps-for-qualcomm-linux/raw/refs/heads/main/qualcomm-linux/artifacts/videos/demo_samples/">Input video</a> | `video.mp4` |

        Then copy it to your device:

        ```bash SCP (SSH) theme={null}
        ssh <user>@<device-ip> "mkdir -p $HOME/media"
        scp video.mp4  <user>@<device-ip>:$HOME/media/
        ```

        **2. Set the source**

        <CodeGroup>
          ```bash H.264 theme={null}
          export VIDEO_SOURCE="filesrc location=$HOME/media/video.mp4 ! qtdemux ! h264parse ! v4l2h264dec capture-io-mode=4 output-io-mode=4 ! video/x-raw,format=NV12"
          ```

          ```bash H.265 theme={null}
          export VIDEO_SOURCE="filesrc location=$HOME/media/<H.265 encoded mp4 file> ! qtdemux ! h265parse ! v4l2h265dec capture-io-mode=4 output-io-mode=4 ! video/x-raw,format=NV12"
          ```
        </CodeGroup>
      </Accordion>

      <Accordion title="USB Camera">
        USB cameras show up as V4L2 devices (e.g. `/dev/video0`). Run this on the device to find your camera's node:

        ```bash theme={null}
        for dev in /dev/video*; do
          echo "$dev: $(cat /sys/class/video4linux/$(basename $dev)/name)"
        done
        ```

        Then set the source using the device node you identified:

        ```bash theme={null}
        export VIDEO_SOURCE="v4l2src device=/dev/video<#> ! video/x-raw,width=1920,height=1080"
        ```

        **Note**: Adjust the resolution if your camera does not support 1080p.
      </Accordion>

      <Accordion title="Built-in Camera">
        Built-in cameras are accessed using the [`qticamsrc`](../plugin-reference/qticamsrc) plugin, which handles ISP hardware initialization on Qualcomm SoCs.

        ```bash theme={null}
        export VIDEO_SOURCE="qticamsrc camera=0 ! video/x-raw,width=1920,height=1080"
        ```

        **Note**: If multiple cameras are connected, set the `camera` property to select the one you want.
      </Accordion>

      <Accordion title="RTSP (Network) Camera">
        RTSP cameras stream encoded video (H.264 or H.265) over the network. The `rtspsrc` plugin receives the stream and the hardware decoder converts it to NV12 for the pipeline.

        ```bash theme={null}
        export VIDEO_SOURCE="rtspsrc location=<RTSP-URL> ! rtph264depay ! h264parse ! v4l2h264dec capture-io-mode=4 output-io-mode=4 ! video/x-raw,format=NV12"
        ```

        The resolution is determined by the camera and cannot be changed in GStreamer.

        The RTSP URL format varies by manufacturer. Common formats:

        ```
        rtsp://username:password@ip_address:port/stream_path
        rtsp://ip_address:port/h264/ch1/main/av_stream
        rtsp://username:password@ip_address:port/Streaming/Channels/101
        ```

        If you're unsure, search for *"\[your camera model] RTSP URL"* or check the manufacturer's documentation.
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Run example on device">
    <img src="https://mintcdn.com/qimsdk/xdnKhBBjxpS5mUYP/qimsdk-overview/images/datasources.png?fit=max&auto=format&n=xdnKhBBjxpS5mUYP&q=85&s=a2e555af845d8dcc1e1b9ef82b00e6ec" alt="data source" width="1634" height="204" data-path="qimsdk-overview/images/datasources.png" />

    This pipeline captures frames from the video source in NV12 (YUV) format and passes them to `appsink`, which notifies the application when a new frame is available. The `queue` element allows the source and consumer to run in parallel.

    <Tabs>
      <Tab title="GStreamer Command line">
        ```bash theme={null}
        gst-launch-1.0 $VIDEO_SOURCE ! \
          filesink location=$HOME/media/frame.bin
        ```
      </Tab>

      <Tab title="GStreamer Python application">
        * **Python source code:** [gst-video-source.py](https://github.com/qualcomm/gst-plugins-imsdk/tree/main/gst-python-examples/gst-video-source.py)

        * **Run:**

          ```bash theme={null}
          python3 gst-video-source.py -s "$VIDEO_SOURCE"
          ```
      </Tab>

      <Tab title="GStreamer C/C++ application">
        * **Application source code:** [gst-video-source-example](https://github.com/qualcomm/gst-plugins-imsdk/tree/main/gst-sample-apps/gst-video-source-example)

        * **Build your application:**

                  <Tabs>
                    <Tab title="Yocto">
                      <a href="../advanced/yocto-build#steps-to-build-custom-application">
                        Steps to build custom application
                      </a>
                    </Tab>

                    <Tab title="Ubuntu">
                      <a href="../advanced/ubuntu-build#steps-to-build-custom-application">
                        Steps to build custom application
                      </a>
                    </Tab>
                  </Tabs>

        * **Run:**

          ```bash theme={null}
          gst-video-source-example -s "$VIDEO_SOURCE"
          ```
      </Tab>
    </Tabs>
  </Step>
</Steps>
