bash while循环和ffmpeg

bash while循环和ffmpeg,bash,ffmpeg,while-loop,Bash,Ffmpeg,While Loop,对不起,我想这个问题的答案很简单,但是我已经搜索过了,我还没有找到任何答案 我写了以下内容: while read p # reads in each line of the text do # file- folder_list.txt each iteration. echo "$p" # print out current li

对不起,我想这个问题的答案很简单,但是我已经搜索过了,我还没有找到任何答案

我写了以下内容:

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 <folder_list.txt               #end of while loop
whileread p#读取文本的每一行
每次迭代执行#file-folder_list.txt。
回显“$p”#打印当前行
if[-f$p/frame_number1.jpg]#检查图像是否存在于特定文件夹中
然后
echo“$p”#打印特定的文件夹名称
睡眠1#暂停1秒
ffmpeg-f image2-r10-i$p/frame_编号%01d.jpg-r30$p/out.mp4#创建视频
fi#end if语句

完成可能是因为某些文件夹包含空格或其他奇怪的字符

尝试以下方法(除大多数情况外,不适用于所有情况):


您缺少使用
围绕变量。谢谢,这两种方法似乎都有效。有什么sudo问题吗?如果它跳过一些文件夹而不是其他文件夹。。。尝试用sudoI运行脚本,但我发现了问题。在一些文件夹中已经有一个以前创建的.mp4文件,出于某种原因,这会对迭代产生影响。我解决这个问题的方法是添加yes指令,即:yes y | ffmpeg-f image2-r 10-I$p/frame_number%01d.jpg-r 30$p/out.mp4#从图像创建视频感谢您花时间评论。@Larry#b这告诉您需要在脚本中添加调试输出和测试。
while read p            # reads in each line of the text file- folder_list.txt
do                      #each iteration
   echo "$p"               #print out current line
   if [  -f   "${p}/frame_number1.jpg"  ] #checks wether the image exists in the specific folder
   then echo "$p"      #printsout 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 <folder_list.txt   #end of while loop
ls -ald  /some/ok/dir     /some/NOTOK/dir #will show which directories belong to who
id  #will tell us which user you are using, so we can compare to the previous and find out why you can't access some