The following text file ("myTextFile.txt") is used to cut a video into chunks
00:00:00.0 video_name_1.mp4
00:10:00.1 video_name_2.mp4
00:20:00.1 video_name_3.mp4
First columns are time stamps of cutting points [HH:MM:SS.millis].
I use the following command to read the txt file and cut a video called "input_video.mp4" into clips of 10 seconds each
while read line ; do
start_time=$(echo $line | cut -d' ' -f1);
output_name=$(echo $line | cut -d' ' -f2);
ffmpeg -ss $start_time -t 00:00:10.0 -i input_video.mp4 ${output_name};
done < myTextFile.txt
but it's not working. The output filenames are corrupt and I don't know why. I'm not using any special characters in the output filenames. Why is this happening?
My current work around is printing the last line ("ffmpeg ...") into the console and then paste all commands into the console command and thereby executing them...
-nostdindoes the trick!ffmpegreads standard input, which causes problem toread line. You can check by removing-nostdinoption and addingffmpeg ... < /dev/null, which should work as well.