Skip to content

Public CI Video Decode and Encode Shell Scripts. #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions Runner/suites/Multimedia/Video/README_Video.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# Iris V4L2 Video Test Scripts for Qualcomm Linux based platform (Yocto)

## Overview

Video scripts automates the validation of video encoding and decoding capabilities on the Qualcomm Linux based platform running a Yocto-based Linux system. It utilizes iri_v4l2_test test app which is publicly available @https://github.com/quic/v4l-video-test-app

## Features

- V4L2 driver level test
- Encoding YUV to H264 bitstream
- Decoding H264 bitstream to YUV
- Compatible with Yocto-based root filesystem

## Prerequisites

Ensure the following components are present in the target Yocto build:

- `iris_v4l2_test` (available in /usr/bin/) - this test app can be compiled from https://github.com/quic/v4l-video-test-app
- input json file for iris_v4l2_test app
- input bitstream for decode script
- input YUV for encode script
- Write access to root filesystem (for environment setup)

## Directory Structure

```bash
Runner/
├── suites/
│ ├── Multimedia/
│ │ ├── Video/
│ │ │ ├── iris_v4l2_video_encode/
│ │ │ │ ├── H264Encoder.json
│ │ │ │ ├── run.sh
│ │ │ ├── iris_v4l2_video_decode/
│ │ │ │ ├── H264Decoder.json
│ │ │ │ ├── run.sh
```

## Usage

1. Copy repo to Target Device: Use scp to transfer the scripts from the host to the target device. The scripts should be copied to the /var directory on the target device.

2. Verify Transfer: Ensure that the repo have been successfully copied to the /var directory on the target device.

3. Run Scripts: Navigate to the /var directory on the target device and execute the scripts as needed.

Run a specific test using:
---
Quick Example
```
git clone <this-repo>
cd <this-repo>
scp -r common Runner user@target_device_ip:/var
ssh user@target_device_ip
cd /var/Runner && ./run-test.sh iris_v4l2_video_encode
```
Sample output:
```
sh-5.2# cd /var/Runner && ./run-test.sh iris_v4l2_video_encode
[Executing test case: /var/Runner/suites/Multimedia/Video/iris_v4l2_video_encode] 1980-01-08 22:22:15 -
[INFO] 1980-01-08 22:22:15 - -----------------------------------------------------------------------------------------
[INFO] 1980-01-08 22:22:15 - -------------------Starting iris_v4l2_video_encode Testcase----------------------------
[INFO] 1980-01-08 22:22:15 - Checking if dependency binary is available
[PASS] 1980-01-08 22:22:15 - Test related dependencies are present.
...
[PASS] 1980-01-08 22:22:17 - iris_v4l2_video_encode : Test Passed
[INFO] 1980-01-08 22:22:17 - -------------------Completed iris_v4l2_video_encode Testcase----------------------------
```
3. Results will be available in the `Runner/suites/Multimedia/Video/` directory under each usecase folder.

## Notes

- The script does not take any arguments.
- It validates the presence of required libraries before executing tests.
- If any critical tool is missing, the script exits with an error message.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"ExecutionMode": "Sequential",
"TestCases": [
{
"Name" : "Decoder Testcase",
"TestConfigs" : {
"Domain": "Decoder",
"InputPath": "./simple_AVC_720p_10fps_90frames.264",
"NumFrames": -1,
"CodecName": "AVC",
"PixelFormat": "NV12",
"Width": 1280,
"Height": 720,
"Outputpath": "./output_simple_nv12_720p_90frms.yuv",
"InputBufferCount": 16,
"OutputBufferCount": 16
}
}
]
}
23 changes: 16 additions & 7 deletions Runner/suites/Multimedia/Video/iris_v4l2_video_decode/run.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
#!/bin/sh

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# Import test suite definitions
/var/Runner/init_env
TESTNAME="video_decode"
# shellcheck source=../../../../init_env
. "${PWD}"/init_env
TESTNAME="iris_v4l2_video_decode"
TAR_URL="https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/IRIS-Video-Files-v1.0/video_clips_iris.tar.gz"

#import test functions library
. $TOOLS/functestlib.sh
# shellcheck source=../../../../utils/functestlib.sh
. "${TOOLS}"/functestlib.sh
test_path=$(find_test_case_by_name "$TESTNAME")
log_info "-----------------------------------------------------------------------------------------"
log_info "-------------------Starting $TESTNAME Testcase----------------------------"

log_info "Checking if dependency binary is available"
check_dependencies iris_v4l2_test
extract_tar_from_url "$TAR_URL"

# Run the first test
iris_v4l2_test --config /Video/DEC_AVC_NV12_BASIC_CFG.json --loglevel 15 >> video_dec.txt
iris_v4l2_test --config "${test_path}/h264Decoder.json" --loglevel 15 >> "${test_path}/video_dec.txt"

if grep -q "Test Passed" "video_dec.txt"; then
if grep -q "SUCCESS" "${test_path}/video_dec.txt"; then
log_pass "$TESTNAME : Test Passed"
echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res
echo "$TESTNAME PASS" > "$test_path/$TESTNAME.res"
else
log_fail "$TESTNAME : Test Failed"
echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
fi

log_info "-------------------Completed $TESTNAME Testcase----------------------------"
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"ExecutionMode": "Sequential",
"TestCases": [
{
"Name" : "Encoder Testcase",
"TestConfigs" : {
"Domain": "Encoder",
"InputPath": "./simple_nv12_720p_90frms.yuv",
"NumFrames": -1,
"CodecName": "AVC",
"PixelFormat": "NV12",
"Width": 1280,
"Height": 720,
"Outputpath": "./output_simple_AVC_720p_10fps.h264",
"InputBufferCount": 32,
"OutputBufferCount": 32,
"OperatingRate": 10,
"FrameRate": 10,
"StaticControls": [
{"Id": "Profile", "Vtype": "String", "Value": "BASELINE"},
{"Id": "Level", "Vtype": "String", "Value": "5.0"},
{"Id": "FrameRC", "Vtype": "Int", "Value": 1},
{"Id": "BitRate", "Vtype": "Int", "Value": 18000000},
{"Id": "BitRateMode", "Vtype": "String", "Value": "CBR"},
{"Id": "PrefixHeaderMode", "Vtype": "String", "Value": "JOINED"}
]
}
}
]
}
23 changes: 16 additions & 7 deletions Runner/suites/Multimedia/Video/iris_v4l2_video_encode/run.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
#!/bin/sh

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# Import test suite definitions
/var/Runner/init_env
TESTNAME="video_encode"
# shellcheck source=../../../../init_env
. "${PWD}"/init_env
TESTNAME="iris_v4l2_video_encode"
TAR_URL="https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/IRIS-Video-Files-v1.0/video_clips_iris.tar.gz"

#import test functions library
. $TOOLS/functestlib.sh
# shellcheck source=../../../../utils/functestlib.sh
. "${TOOLS}"/functestlib.sh
test_path=$(find_test_case_by_name "$TESTNAME")
log_info "-----------------------------------------------------------------------------------------"
log_info "-------------------Starting $TESTNAME Testcase----------------------------"

log_info "Checking if dependency binary is available"
check_dependencies iris_v4l2_test
extract_tar_from_url "$TAR_URL"

# Run the first test
iris_v4l2_test --config /Video/ENC_AVC_NV12_BASIC_CFG.json --loglevel 15 >> video_enc.txt
iris_v4l2_test --config "${test_path}/h264Encoder.json" --loglevel 15 >> "${test_path}/video_enc.txt"

if grep -q "Test Passed" "video_enc.txt"; then
if grep -q "SUCCESS" "${test_path}/video_enc.txt"; then
log_pass "$TESTNAME : Test Passed"
echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res
echo "$TESTNAME PASS" > "$test_path/$TESTNAME.res"
else
log_fail "$TESTNAME : Test Failed"
echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
fi

log_info "-------------------Completed $TESTNAME Testcase----------------------------"
89 changes: 89 additions & 0 deletions Runner/utils/functestlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,92 @@ functestlibdoc()
done
echo "Note, these functions will probably not work with >=32 CPUs"
}

# Function is to check for network connectivity status
check_network_status() {
echo "[INFO] Checking network connectivity..."

# Get first active IPv4 address (excluding loopback)
ip_addr=$(ip -4 addr show scope global up | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n 1)

if [ -n "$ip_addr" ]; then
echo "[PASS] Network is active. IP address: $ip_addr"

if ping -c 1 -W 2 8.8.8.8 >/dev/null 2>&1; then
echo "[PASS] Internet is reachable."
return 0
else
echo "[WARN] Network active but no internet access."
return 2
fi
else
echo "[FAIL] No active network interface found."
return 1
fi
}

# If the tar file already exists,then function exit. Otherwise function to check the network connectivity and it will download tar from internet.
extract_tar_from_url() {
local url="$1"
local filename
local extracted_files

# Extract the filename from the URL
filename=$(basename "$url")
if check_tar_file "$filename"; then
echo "[PASS] file already exists, Hence skipping downloading"
return 0
fi

check_network_status
network_status=$?
if [ $network_status -ne 0 ]; then
extract_tar_from_url "$TAR_URL"
fi

# Download the file using wget
echo "[INFO] Downloading $url..."
wget -O "$filename" "$url"

# Check if wget was successful
if [ $? -ne 0 ]; then
echo "[FAIL] Failed to download the file."
return 1
fi

# Extract the tar file
echo "[INFO] Extracting $filename..."
tar -xvf "$filename"

# Check if tar was successful
if [ $? -ne 0 ]; then
echo "[FAIL] Failed to extract the file."
return 1
fi

# Check if any files were extracted
extracted_files=$(tar -tf "$filename")
if [ -z "$extracted_files" ]; then
echo "[FAIL] No files were extracted."
return 1
else
echo "[PASS] Files extracted successfully:"
echo "[INFO] $extracted_files"
return 0
fi
}

# Function to check if a tar file exists
check_tar_file() {
local url="$1"
local filename
local extracted_files

# Extract the filename from the URL
filename=$(basename "$url")
if [ -f "$filename" ]; then
return 0
else
return 1
fi
}
Loading