So I'm trying to extract every frame of a video, then use ffprobe to see when each frame is played within a video, then be able to stitch that video back together using those extracted images and ffprobe output.
Right now, I have this batch file:
for %%a in (*.mp4) do (
mkdir "%%~na_images" > NUL
ffmpeg.exe -hide_banner -i "%%a" -t 100 "%%~na_images\image-%%d.png"
ffprobe.exe "%%a" -hide_banner -show_entries frame=coded_picture_number,best_effort_timestamp_time -of csv > "%%~na_frames.txt"
)
First, a directory is made for the images. Then ffmpeg extracts all the frames of the video to individual PNG files, which are numbered appropriately. Lastly, ffprobe sees when each frame is first shown within that video (IE: frame 1 is shown at 0 seconds, but at say 60fps then frame 2 is played at 0.016667 seconds in the video). The output looks like this:
frame,0.000000,0
frame,0.000000
frame,0.017000,1
frame,0.023220
Where the first number (IE 0.17000 is the time the second frame appears) and the 2nd number is the frame number. Now my problem is using ffmpeg to take each frame and place it in the proper time within the video. I can do this using another language (probably Python), but my best guess is to make a loop to iterate through the ffprobe output file, get the frame time and image number, place that frame at the points that it appears, then move on to the next frame and time placement. Looking at the frame data I used as an example above, it 'd be something like this:
for line in lines:
mySplit = line.split(',')
# Get image number 0 and insert at time 0.000000
This is the part that I'm not sure how to do in a coding sense. I can read in and parse the lines of the ffprobe output text file, but I have no idea how to insert the frames at certain points in a video using ffmpeg or similar solutions.