
有一个文件夹 folder,里面有若干个子文件夹(命名随机),每个子文件夹里有若干个视频文件,命名随机。 现需要在每个子文件夹内执行如下命令(使用 ffmpeg 合并视频,输出文件保存在原来的文件夹里即可),如何完成?
for f in ./*; do echo "file '$f'" >> mylist.txt;done; ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4; done 感谢各位帮助
1 KevZhi OP 就是在目录下每个子目录内执行一遍如上两行命令,跳出,在下一个子目录执行,跳出... |
2 rwdy2008 2018-03-05 18:15:22 +08:00 cd dir for i in `ls`;do cd dir/$i; 执行你的命令 done 是要这样吗? |
3 afpro 2018-03-05 18:26:37 +08:00 for d in $(ls -d */); do ffmpeg -f concat -safe 0 -i <(ls ${d}*.mp4) -c copy ${d}output.mp4 done 这样可好? |
7 afpro 2018-03-05 18:35:54 +08:00 不对 文件列表还要有个 file for d in $(ls -d */); do ffmpeg -f concat -safe 0 -i <(ls ${d}*.mp4 | xargs -I{} echo "file '{}'") -c copy ${d}output.mp4 done |
8 afpro 2018-03-05 18:36:23 +08:00 这样? 我看你 mylist.txt 里面要 file 开头 |
9 ynyounuo 2018-03-05 18:44:02 +08:00 在最顶层 dir 执行,如果子文件夹只有视频的话,否则将 find 换成需要的文件类别和后缀。 for dir in ./* ; do (cd "$dir"; find * | sed "s/^/'/;s/$/'/;s/^/file /" > tmp.txt; ffmpeg -f concat -safe 0 -i tmp.txt -c copy output.ext); done |