#!/bin/bash input_luma="" input_chroma="" offset=0 voffset=() aoffset=() usage() { echo "Example: $(basename "$0") -l /home/test/Videos/video1.mkv -c /home/test/Videos/YUV.bin -o" echo echo "Options:" echo "-l, --luma File generated by the gen_chroma_vid script" echo "-c, --chroma File generated by the GNURadio graph" echo "-o, --offset Use when GNURadio file had to be offset by 2 fields" } if [ "$1" = "" ]; then usage exit 0 fi while [ "$1" != "" ]; do case $1 in -l | --luma) shift input_luma=$1 ;; -c | --chroma) shift input_chroma=$1 ;; -o | --offset) shift offset=1 ;; *) input=$1 ;; esac shift done if [ "$offset" = "1" ]; then voffset+=( "-ss 0.04" ) aoffset+=( "-itsoffset -00:00:00.000" ) else voffset+=( "-ss 0.00" ) aoffset+=( "-itsoffset -00:00:00.000" ) fi if [ -f "$input_luma" ] && [ -f "$input_chroma" ]; then input_stripped=${input_luma%.mkv} ffmpeg -y -f rawvideo -pixel_format yuv444p -color_range tv -color_primaries "bt470bg" -color_trc "gamma28" -colorspace "bt470bg" -video_size 1185x624 -r 25 -i "$input_chroma" $voffset -i "$input_luma" -filter_complex "[0:v]format=yuv444p, crop=928:576:183:46, setdar=1856/1383[chroma]; [1:v]format=yuv422p10le, setdar=1856/1383[luma]; [chroma][luma]mergeplanes=0x100102:yuv422p10le[v]" -map 1:a? -c:a copy -map '[v]' -c:v ffv1 -coder 1 -context 1 -g 25 -level 3 -slices 16 -slicecrc 1 -top 1 $input_stripped"_yuv.mkv" else echo "Cannot find luma or chroma file. Aborting" exit 1; fi