<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 29, 2024 at 3:09 PM John Pilkington <<a href="mailto:johnpilk222@gmail.com">johnpilk222@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 26/01/2024 00:01, John Pilkington wrote:<br>
<br>
{{{<br>
lag=4        #  In frames.  Best value might depend on recording source, <br>
MythTV version and seektable history.<br>
scope=2000   #  Sometimes h264 keyframes in the wild are much more <br>
widely spaced than expected.<br>
               #  This might only have been true for 'rebuilt' <br>
seektables, but the large value should do no harm.<br>
<br>
for frame in $(cat revedlist$$)<br>
do<br>
      i=$((${frame} - ${lag}))<br>
      j=$((${i}))<br>
      k=$((${i} + ${scope}))<br>
      echo  "select `offset`, mark from recordedseek<br>
      where chanid=$chanid and starttime='$starttime' and type=9<br>
      and mark >= ${j} and mark < ${k}  order by `offset` limit 3 ;" |<br>
      mysql -N -u${DBUserName} -p${DBPassword} -h${DBLocalHostName} <br>
${DBName}<br>
done > tmp0$$<br>
<br>
echo "Full results of DB read:"<br>
cat tmp0$$<br>
cat tmp0$$  | sed -n '1,${p;n;n;}' > tmp1$$  # select lines 1,4,7...<br>
cat tmp0$$  | sed -n '2,${p;n;n;}' > tmp2$$  # 2,5,8...<br>
cat tmp0$$  | sed -n '3,${p;n;n;}' > tmp3$$<br>
rm tmp0$$<br>
<br>
echo<br>
<br>
<br>
That script snippet aims to find the byte-offsets of keyframes near to <br>
frame numbers read from the cutlist.<br>
<br>
MariaDB 10.6.12 in ubuntu 22.04 failed with it, although I have been <br>
using similar code for years with earlier versions of mysql.<br>
<br>
It's working now after some changes:  essentially using  " select * " <br>
and "order by mark" in the sql query, so avoiding mentioning the newly <br>
reserved sql word "offset" altogether.<br>
<br>
  echo "select * from recordedseek<br>
         where chanid=$chanid and starttime='$starttime' and type=9<br>
         and mark >= ${j} and mark < ${k} order by mark limit 3 ;"<br>
         | ${mysqlconnect}<br>
<br>
That changes the content of tmp0$$, the queries output file, and the <br>
details of its unpacking.  I have related scripts that have been <br>
prettified and intend to do the same here.<br>
<br>
}}}<br>
<br>
John P<br>
<br></blockquote><div><br></div><div>You need to escape the backticks in the mysql command:<br></div><div><span style="font-family:monospace"><font size="4"><i>echo "<span class="gmail-im">select \`offset\`, mark from recordedseek where.... "</span></i></font></span></div><div><span class="gmail-im">otherwise bash thinks it is a command. Try on the command line</span></div><div><span class="gmail-im"><font size="4"><i><span style="font-family:monospace">$ echo "`pwd`" </span></i></font></span></div><div><span class="gmail-im"><font size="2"><span style="font-family:arial,sans-serif">and</span></font></span></div><div><span class="gmail-im"><font size="4"><i><span style="font-family:monospace">$ echo "\`pwd\`"</span></i></font></span></div><div><span class="gmail-im"><font size="4"><i><span style="font-family:monospace"><br></span></i></font></span></div><div><span class="gmail-im"><br></span></div><div><span class="gmail-im">Roland<br></span></div><div><span class="gmail-im"><br></span></div><div><font size="4"><i><br></i></font></div></div></div>