title: PNG sequence to MP4 while looping the animation
body: <p>So, I'm trying to convert a PNG sequence to an MP4 and loop the animation about 100 times, the only problem is my script doesn't seem to be working properly.</p>
  
  <p>What the script is supposed to do is get the number of PNG files in the frames directory, and send them to FFMPEG 100 times. Only problem is my script isn't working right. Here's the code.</p>
  
  <pre><code>#!/bin/bash
  
  loopcode()
  {
  tmpdir=frames
  picext=png
  one=$(ls -l ${tmpdir}/*.png  | wc -l)
  two=$(echo "${one}+0" | bc -l)
  three=0
  while [ ! ${loopi} -eq ${looper} ]; do
    while [ ! ${three} -eq ${two} ]; do
      three=$(printf "%09d" ${two})
      echo ${tmpdir}/${three}.${picext}
      two=$(echo "${two}+1" | bc -l)
    done
    two=0
    loopi=$(echo "${loopi}+1" | bc -l)
  done
  }
  
  looper=100
  loopi=0
  outfile=output.mp4
  fps=5
  convert frames/*.png frames/%09d.jpeg
  loopcode &amp;&amp; sleep 5
  cat $(loopcode) | ffmpeg -framerate 1/5 -i - -c:v libx264 -r 30 -pix_fmt yuv420p "${outfile}"
  </code></pre>