title: bash while loop and ffmpeg
body: <p>Sorry for this questions I imagine the answer is pretty straightforward however I have had a search and I haven't found anything that answers it. </p>
  
  <p>I have written the following:</p>
  
  <pre><code>while read p                        # reads in each line of the text
  do                                  # file- folder_list.txt each iteration.
      echo "$p"                       # print out current line
      if [ -f  $p/frame_number1.jpg ] # checks if the image exists in the specific folder
      then
          echo "$p"                   #prints specific folder name
          sleep 1                     #pause for 1 second
          ffmpeg -f image2 -r 10 -i $p/frame_number%01d.jpg -r 30 $p/out.mp4  #create video
       fi                             # end if statement
  done &lt;folder_list.txt               #end of while loop
  </code></pre>
  
  <p>The script is supposed to read a text file which contains the folder tree structure, then check if the folder contains the specified JPEG if it does then the code should create a video from the images contained within the specified folder.</p>
  
  <p>However what appears to be happening is the script skips whole folders that definitely contain images. I was wondering if the while loop is continuing to iterate whilst the video is being created or if something else is happening?</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Many thanks in advance </p>
  
  <p>Laurence </p>