research pipelines

This commit is contained in:
Artur 2025-09-18 21:45:25 +03:00
parent d3ce6e0eef
commit 11096da4e3
2 changed files with 56 additions and 31 deletions

17
ffmpeg-psnr-check.sh Normal file → Executable file
View File

@ -1,23 +1,24 @@
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <input_video> <reference_video>"
exit 1
fi
if ! command -v ffmpeg &> /dev/null
then
echo "ffmpeg could not be found, please install it."
exit 1
fi
name=nvv4l2h264enc
specific=eleph-pr-baseline-preset1-cbr-hqp-10
#
#this script checks the PSNR between two video streams using ffmpeg
# one video stream is the reference and the other is the test stream both are recorded files
ffmpeg -f rawvideo -video_size 1920x1080 -pixel_format yuv444p -color_range pc -framerate 30 -i "$1" -i "$2" -filter_complex "psnr" -f null /dev/null
ffmpeg -f rawvideo -video_size 1920x1080 -pixel_format yuv420p -color_range tv -framerate 60 -i base-${name}-${specific}.yuv -i encoded-${name}-${specific}.mp4 -filter_complex "psnr" -f null /dev/null
# example working:
# ffmpeg -f rawvideo -video_size 1920x1080 -pixel_format yuv444p -color_range pc -framerate 30 -i base.yuv -i test.mp4 -filter_complex "psnr" -f null /dev/null
# ffmpeg -f rawvideo -video_size 1920x1080 -pixel_format yuv420p -color_range tv -framerate 60 -i base-${name}-${specific}.yuv -i encoded-${name}-${specific}.mp4 -filter_complex "psnr" -f null /dev/null
# ffmpeg -f rawvideo -video_size 1920x1080 -pixel_format nv12 -color_range tv -framerate 60 -i base-${name}-${specific}.yuv -i encoded-${name}-${specific}.mp4 -filter_complex "psnr" -f null /dev/null
# ffmpeg -f rawvideo -video_size 1920x1080 -pixel_format yuv420p -color_range pc -framerate 60 -i base.yuv -i test.mp4 -filter_complex "psnr" -f null /dev/null
#this script checks the SSIM between two video streams using ffmpeg
ffmpeg -f rawvideo -video_size 1920x1080 -pixel_format yuv444p -color_range pc -framerate 30 -i "$1" -i "$2" -filter_complex "[0:v][1:v]ssim=stats_file=ssim_results.txt" -f null /dev/null
ffmpeg -f rawvideo -video_size 1920x1080 -pixel_format yuv420p -color_range tv -framerate 60 -i base-${name}-${specific}.yuv -i encoded-${name}-${specific}.mp4 -filter_complex "[0:v]fps=60[v0];[1:v]fps=60[v1];[v0][v1]ssim=stats_file=ssim_results.txt" -f null /dev/null
# ffmpeg -f rawvideo -video_size 1920x1080 -pixel_format yuv422p -color_range pc -framerate 30 -i base.yuv -i test.mp4 -filter_complex "[0:v][1:v]ssim=stats_file=ssim_results.txt" -f null /dev/null

View File

@ -5,34 +5,58 @@
# First stream is coming from decklinkvideosrc
# Second stream is same decklinkvideosrc but encoded using x264enc
# Both streams are saved to files using mp4mux and filesink
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <reference_video_file> <test_video_file> <optional: DEBUG>"
exit 1
fi
if ! command -v gst-launch-1.0 &> /dev/null
then
echo "gstreamer could not be found, please install it."
exit 1
fi
# Record both streams in one run
if [ "$3" == "DEBUG" ]; then
gst-launch-1.0 -e \
videotestsrc pattern=smpte ! \
capsfilter caps="video/x-raw,format=UYVY,width=1920,height=1080,framerate=30/1" ! \
videoconvert ! queue ! tee name=t \
t. ! queue ! filesink location="$1" \
t. ! queue ! x264enc bitrate=20000 speed-preset=ultrafast tune=zerolatency ! h264parse ! mpegtsmux ! filesink location="$2"
exit 0
src='decklinkvideosrc device-number=1 connection=1 mode=1080p60 drop-no-signal-frames=true !'
if [ "$1" == "DEBUG" ]; then
src='videotestsrc pattern=smpte !'
fi
gst-launch-1.0 -e \
decklinkvideosrc \
device-number=1 \
connection=1 \
mode=auto \
drop-no-signal-frames=true ! videoconvert ! queue ! tee name=t \
t. ! queue ! mpegtsmux ! filesink location="$1" \
t. ! queue ! x264enc bitrate=20000 speed-preset=ultrafast tune=zerolatency ! mpegtsmux ! filesink location="$2"
name=nvv4l2h264enc
specific=eleph-pr-baseline-preset1-cbr-lossless-10
echo $src
GST_DEBUG_COLOR_MODE=off \
GST_TRACERS="latency(flags=pipeline+element)" \
GST_DEBUG="GST_TRACER:7" \
GST_DEBUG_FILE=latency_traces-${name}-${specific}.log \
gst-launch-1.0 -e \
$src \
capsfilter caps="video/x-raw,format=UYVY,width=1920,height=1080,framerate=60/1" ! \
videoconvert ! capsfilter caps="video/x-raw,format=I420,width=1920,height=1080,framerate=60/1" ! queue ! tee name=t \
t. ! queue ! filesink location="base-${name}-${specific}.yuv" \
t. ! queue ! nvvideoconvert ! \
capsfilter caps="video/x-raw(memory:NVMM),format=I420,width=1920,height=1080" ! \
${name} bitrate=10000000 profile=0 preset-id=1 control-rate=1 tuning-info-id=4 ! \
capsfilter caps="video/x-h264,profile=baseline" ! h264parse ! mpegtsmux ! filesink location="encoded-${name}-${specific}.mp4"
# GST_DEBUG_COLOR_MODE=off \
# GST_TRACERS="latency(flags=pipeline+element)" \
# GST_DEBUG="GST_TRACER:7" \
# GST_DEBUG_FILE=latency_traces-${name}-${specific}.log \
# gst-launch-1.0 -e \
# $src \
# capsfilter caps="video/x-raw,format=UYVY,width=1920,height=1080,framerate=60/1" ! \
# videoconvert ! queue ! tee name=t \
# t. ! queue ! filesink location="base-${name}-${specific}.yuv" \
# t. ! queue ! x264enc bitrate=10000 speed-preset=ultrafast tune=zerolatency sliced-threads=true ! \
# capsfilter caps="video/x-h264,profile=baseline" ! h264parse ! mpegtsmux ! filesink location="encoded-${name}-${specific}.mp4"
# GST_DEBUG_COLOR_MODE=off \
# GST_TRACERS="latency(flags=pipeline+element)" \
# GST_DEBUG="GST_TRACER:7" \
# GST_DEBUG_FILE=latency_traces-${name}-${specific}.log \
# gst-launch-1.0 -e \
# $src \
# capsfilter caps="video/x-raw,format=UYVY,width=1920,height=1080,framerate=60/1" ! \
# videoconvert ! capsfilter caps="video/x-raw,format=NV12,width=1920,height=1080,framerate=60/1" ! queue ! tee name=t \
# t. ! queue ! filesink location="base-${name}-${specific}.yuv" \
# t. ! queue ! ${name} bitrate=10000 preset=5 rc-lookahead=0 rc-mode=2 zerolatency=true ! \
# capsfilter caps="video/x-h264,profile=baseline" ! h264parse ! mpegtsmux ! filesink location="encoded-${name}-${specific}.mp4"