What I would like to achieve is that a script runs through a folder of video files e.g.
001.mp4 002.mp4 003.mp4
and cuts these video according to a .csv or .xls or .txt with the timestamp e.g:
001.mp4, 00:00:00 - 00:00:03, 00:05:01 - 00:09:56, 002.mp4, 00:03:00 - 00:04:01, 00:06:01 - 00:08:00,
I would also like this to be as accurate as possible and wonder what the best approach is to get frame accuracy. I don't fully understand this, but some research suggests that the best would be to force keyframes at the edit points before cutting it.
The output should be named according to the video file name and cut times.
New folder: 001_000000_000003.mp4 001_000501_000956.mp4
so in pseudo code I would think the following:
for i in *.mov; do ffmpeg -i "$i" - force_key_frames-at-all-cut-points-according-to-csv file outputfile.mov (same as start file ?) ffmpeg -i "$i" - cut-video-according-to-cut-points "$i"+startpoint+endpoint.mov
In a next step it would be great to create these timestamps (with any software, ideally ffmpeg) by clicking and creating markers for in and out.
Any idea how I could achieve the first step would be great. Also if there is already a ready script/software(open source) that can do this it would be great.
Thank you for your help.
I now have a .txt file with timestamps that I can extract automatically (every line a value in second like this):
timestamp0 (00:00) timestamp1 (3.3 seconds) timestamp2 (10.2 seconds) timestamp3 (16.7 seconds)
Now I would like to parse always two pairs (e.g. timestamp0, timestamp1; timestamp2, timestamp3 ) and cut them from the larger video file and save them in a file with the seconds like this:
ffmpeg -ss timestamp0 -i inputfile.mp4 -t timestamp1 -c copy inputfile_time0_time1.mp4
How can I iterate over all the files in the directory, apply the cuts and save them to file ? Or if that is too difficult, how can I do this for one video ?