转换 mp4 文件并通过目录复制

转换 mp4 文件并通过目录复制

我需要一个脚本来拍摄相机上录制的全尺寸视频,重新压缩它们,创建压缩版本,然后在转换后将原始文件移动到另一个文件夹。然后我将压缩文件而不是原始文件导入 Lightroom。它运行良好,但我希望它仅在成功创建压缩副本后才移动原始文件。欢迎提出改进此脚本的想法!我使用的是 Mac OS X。

#Convert everything in the subdirectories of a directory called "Unprocessed", storing the converted file in the "Processed/Converted" directory, fixing the 420p issue if the file is an AVI files, then move the original to a corresponding subdirectory of "Processed/Completed" for i in Unprocessed/*/*/*.*; 
do o=$i; 
    echo Target is $o; 
    filename=`echo ${o##*/}`;
    echo Filename is $filename;
    tree=`echo $o | cut -d'/' -f2-3`; 
    echo Tree is $tree;
    echo Directory to create is "Processed/Converted/$tree";
    mkdir -p "Processed/Converted/$tree";
    base=`echo ${filename%.*}`;
    echo Base is $base;
    newfile="Processed/Converted/$tree/$base.mp4";
    echo Newfile is $newfile; 
    ffmpeg -i "$i" -map_metadata 0 -pix_fmt yuv420p "${newfile}"; 
    echo Destination to move to is "Processed/Completed/$tree";
    mkdir -p "Processed/Completed/$tree";
    mv "$i" "Processed/Completed/$tree"; 
done;

相关内容