MoeFwacky / vhstools

A set of python scripts with various video tools, including editing, automatic scene detection and splitting, and posting random clips to social media platforms
GNU General Public License v3.0
5 stars 0 forks source link

Scanner - Many files hang at 100% #2

Open dege13 opened 1 year ago

dege13 commented 1 year ago

Many of the videos I have cause the scanner to hang at 100%. The frame counter never reaches the end.

Example from another video where the issue happened:

image
2023-02-18 11-05-16 - Polaoid Supercolor - Bluegrass Part 2.mkv
|████████████████████████████████████████| ▁▃▅ 582618/582619 [100%] in 37:54 (~0s, 256.2/s)

Example small file that reproduces the issue: 2022-11-26 00-09-42 - JVC #42 - Devil's Dorway, Little Big Man, River of No Return.mp4_trim_smallsample2.mkv.zip

These files are normally MKV, but the same happens when I tried converting to MP4 with OBS Studio's remux, and FFMPEG to try re-encoding with the flags -err_detect ignore_err -i video.mp4 -c copy video_fixed.mp4

dege13 commented 1 year ago

With the smaller file, it hangs at 97%, on frame 1742 of 1800. I added logging to the "while f < int(round(totalFrames)):" loop and to the exception on the try. The result is:

on 1738: DEBUG: Current Frame 1738
on 1739: DEBUG: Current Frame 1739
on 1740: DEBUG: Current Frame 1740
on 1741: DEBUG: Current Frame 1741
on 1741: DEBUG: video.read exception. Current Frame 1741
on 1742: DEBUG: Current Frame 1742
|██████████████████████████████████████▊ | ▁▃▅ 1742/1800 [97%] in 2:16 (~5s, 12.8/s)

I don't yet know what this means, but I am defiantly no expert at python, ffmpeg or ffprobe.

dege13 commented 1 year ago

With the small test video, when I extract the frames from 1738 to 1800 with ffmpeg, I only get 3 images.

ffmpeg -i "C:\videotools\1-input\2022-11-26 00-09-42 - JVC #42 - Devil's Dorway, Little Big Man, River of No Return.mp4_trim_smallsample2.mkv" -vf select='between(n\,1738\,1800)' -vsync 0 "C:\videotools\1-input\frame%d.png"

To me, this means that out total frames count is wrong which is causing the issue.

MoeFwacky commented 1 year ago

I believe this issue to be resolved with the latest update, though there are known issues with the fix detailed in the update notes. Please re-open this issue if it recurs.

dege13 commented 1 year ago

Doing some testing, I found that about 50% of the time, I could fix the issue by trimming off the last 1 second end of the video with ffmpeg. If the trim didn't fix the issue, I would remove another second and try again. I don't know if that helps at all, but it definitely leads me to believe it has something to do with the data at the end of the video in some way.

I have no idea why I was only able to comment with closing the issue. I am using my phone to add the comments and I don't seem to have an option to comment without a close or open action. Weird.

dege13 commented 1 year ago

I can still reproduce this issue, fyi. It is also happening on newly recorded videos (at one time I thought it could only be files I trimmed with FFMPEG, but it is not).

2023-04-10 13-47-13 - Polaroid Supercolor #9.mkv
[ACTION] Extracting audio track from video file
[ACTION] Splitting audio into 548177 chunks
[INFO] elapsed time: 154.75 seconds
[ACTION] Processing Frames
on 548173: list index out of range
on 548174: axis 0 is out of bounds for array of dimension 0
|████████████████████████████████████████| █▆▄ 548175/548176 [100%] in 17:50 (~0s, 512.5/s)
2023-05-04 16-34-20 - TDK Super Avilyn T-120 #31 - Cary - In a Childs Name.mkv
[ACTION] Extracting audio track from video file
[ACTION] Splitting audio into 212789 chunks
[INFO] elapsed time: 39.01 seconds
[ACTION] Processing Frames
on 212785: list index out of range
on 212786: axis 0 is out of bounds for array of dimension 0
|████████████████████████████████████████| ▄▂▂ 212787/212788 [100%] in 4:06 (~0s, 866.8/s)
2023-04-25 14-40-59 - Maxell High Grade red #110.mkv
[ACTION] Extracting audio track from video file
[ACTION] Splitting audio into 503834 chunks
[INFO] elapsed time: 201.53 seconds
[ACTION] Processing Frames
on 503830: list index out of range
on 503831: axis 0 is out of bounds for array of dimension 0
|████████████████████████████████████████| ▆▄▂ 503832/503833 [100%] in 52:33 (~0s, 159.8/s)