Skip to content

Instantly share code, notes, and snippets.

@CarlFK
Created October 2, 2023 06:10
Show Gist options
  • Save CarlFK/53c82b739f7953a504699dcef116768d to your computer and use it in GitHub Desktop.
Save CarlFK/53c82b739f7953a504699dcef116768d to your computer and use it in GitHub Desktop.
python script to generate a2.sh shell script that tests gst v4l2jpegdec with permutations of caps
# a2.sh
set -ex
echo i=0 s='00000'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw, \! fakesink num-buffers=9000
#
echo i=1 s='00001'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=2 s='00010'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,pixel-aspect-ratio=1/1 \! fakesink num-buffers=9000
#
echo i=3 s='00011'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,pixel-aspect-ratio=1/1,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=4 s='00100'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,framerate=30/1 \! fakesink num-buffers=9000
#
echo i=5 s='00101'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,framerate=30/1,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=6 s='00110'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,framerate=30/1,pixel-aspect-ratio=1/1 \! fakesink num-buffers=9000
#
echo i=7 s='00111'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,framerate=30/1,pixel-aspect-ratio=1/1,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=8 s='01000'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,height=720 \! fakesink num-buffers=9000
#
echo i=9 s='01001'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,height=720,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=10 s='01010'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,height=720,pixel-aspect-ratio=1/1 \! fakesink num-buffers=9000
#
echo i=11 s='01011'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,height=720,pixel-aspect-ratio=1/1,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=12 s='01100'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,height=720,framerate=30/1 \! fakesink num-buffers=9000
#
echo i=13 s='01101'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,height=720,framerate=30/1,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=14 s='01110'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,height=720,framerate=30/1,pixel-aspect-ratio=1/1 \! fakesink num-buffers=9000
#
echo i=15 s='01111'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,height=720,framerate=30/1,pixel-aspect-ratio=1/1,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=16 s='10000'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280 \! fakesink num-buffers=9000
#
echo i=17 s='10001'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=18 s='10010'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,pixel-aspect-ratio=1/1 \! fakesink num-buffers=9000
#
echo i=19 s='10011'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,pixel-aspect-ratio=1/1,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=20 s='10100'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,framerate=30/1 \! fakesink num-buffers=9000
#
echo i=21 s='10101'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,framerate=30/1,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=22 s='10110'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,framerate=30/1,pixel-aspect-ratio=1/1 \! fakesink num-buffers=9000
#
echo i=23 s='10111'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,framerate=30/1,pixel-aspect-ratio=1/1,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=24 s='11000'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,height=720 \! fakesink num-buffers=9000
#
echo i=25 s='11001'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,height=720,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=26 s='11010'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,height=720,pixel-aspect-ratio=1/1 \! fakesink num-buffers=9000
#
echo i=27 s='11011'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,height=720,pixel-aspect-ratio=1/1,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=28 s='11100'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,height=720,framerate=30/1 \! fakesink num-buffers=9000
#
echo i=29 s='11101'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,height=720,framerate=30/1,colorimetry=bt709 \! fakesink num-buffers=9000
#
echo i=30 s='11110'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,height=720,framerate=30/1,pixel-aspect-ratio=1/1 \! fakesink num-buffers=9000
#
echo i=31 s='11111'
gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,width=1280,height=720,framerate=30/1,pixel-aspect-ratio=1/1,colorimetry=bt709 \! fakesink num-buffers=9000
#
# python script to generate a2.sh shell script that tests gst v4l2jpegdec with permutations of caps
l = "width=1280,height=720,framerate=30/1,pixel-aspect-ratio=1/1,colorimetry=bt709".split(',')
print(l)
c = len(l)
print(f"{c=}") # hint 5
frames=9000
f=open('a2.sh', 'w')
f.write('set -ex\n\n')
for i in range(2**c):
s = format(i,"05b")
print(s)
l2=[]
for w in range(c):
if s[w]=='1':
l2.append(l[w])
print(l2)
caps = ",".join(l2)
f.write(f"echo {i=} {s=}\n")
f.write(f"gst-launch-1.0 videotestsrc \! jpegenc \! jpegparse \! v4l2jpegdec \! videoconvert \! video/x-raw,{caps} \! fakesink num-buffers={frames} \n")
f.write(f"# \n\n")
f.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment