-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extra frames sometimes appear at the end of split videos #93
Comments
Hi @typoman; The default behaviour of PySceneDetect now is what precise mode was before. Scenes should be split accurately and re-encoded by ffmpeg when using the Are you seeing a different/unexpected result? How many frames are overlapping? Could you provide some more details, like the complete command/example output? Thanks! |
Hi @typoman; Were you able to validate that frame cuts were correct or not with the new version? I forgot to mention, you also need to have Thanks! |
Hi @Breakthrough, I had installed |
Hi @typoman; You can try with the goldeneye.mp4 file from here: It should match the expected output on the examples page on readthedocs. Would you be able to share with me one of the files where you're experiencing this behaviour? Is the video fixed-framerate or variable framerate? (One thing PySceneDetect does not deal with is varaible framerate videos...) Thank you! |
I can't share my files but I encounter the same issue with your sample. The command I used:
When I open the first scene in QuickTime it contains two frames of the the next scene at the end. Here is the result of all scenes: |
@typoman can you also provide all other information as per this link (e.g. operating system, output log in debug mode)? You can copy and paste the template into a comment here, or attach the relevant information to the first post. Thank you. |
Bug/Issue Description: Imprecise cutting (as mentioned above) Required Information:
Output:
Expected Behavior: Precise cutting! Computing Environment:
|
Hi @typoman; I've submitted an updated version of PySceneDetect, v0.5.1, which includes various bugfixes. My apologies however, but I'm having trouble replicating the behavior you're seeing (I'm only able to test on Windows/Linux). Can you double-check if this issue is fixed in v0.5.1 on OSX? Thank you! Edit: Would you also be able to provide the output scene list, in .csv format, for goldeneye.mp4? I would like to compare the detected cut positions to those in the |
The result is bigger than it could be uploaded here, so here is a temporary link: If there is something missing, please tell me what command to use and I will send you the result. |
Hi @typoman; Thanks for the response. Am looking at the files now, and they seem correct - are there any files in particular where you're noticing the 1-2 frames at the beginning, or is it in every file? (I'm just looking at them visually, but to double check, I'll run them through ffmpeg to export each frame just to be sure.) Can you add the This will help me to narrow down where this issue is being caused. Right now I think it might have to do with either timecode misalignment between PySceneDetect and ffmpeg, or ffmpeg is including extra frames at the beginning due to differences in seeking between versions (might affect I/B/P frame seeks). Once you provide the Thank you for your help! |
I see a frame from the next scene in the last frames of the file "goldeneye-Scene-001.mp4". I use QuickTime to check the files. What app do you use to see the frames? |
@typoman I see now, I was looking at the beginning of the videos not the end. That being said, at first glance, this just looks like it has to do with how ffmpeg splits up the videos, or possibly due to a timecode conversion error (when passing the frame number to ffmpeg). I only say this because not all scenes exhibit this problem, thus the error doesn't add up like I would expect if the actual detection was wrong (or it was an off-by-one in which case every video would be affected). Thanks for the report, will definitely have to do some more investigation into this. If anyone has any feedback or possible causes for this issue, it would be much appreciated. |
split-video
split-video
Also @typoman, do you not see this behavior using an older version of PySceneDetect in particular? (e.g. v0.5-beta-1) |
I haven't used that version but I can test if you tell me how can I install it. |
@typoman Sorry I thought you meant you initially used an old version that did not have the behavior you were experiencing. If that's not the case than don't worry - I don't think anything has changed to make this any different, I think this was how it always was. BTW, to install an older version, first uninstall PySceneDetect via pip, then download a development release, extract it, and type If anyone has any ideas why ffmpeg might be including the extra frames at the end, it would be much appreciated, because at the moment I'm not really sure why this is happening to be honest. |
Hey all; I've just released v0.5.2 which has a fix for the improper starting timecode being passed to ffmpeg. This resolves all of the issues I was able to see in the original issue reported by @typoman (thanks again for providing the video output for me to compare against). Grab the latest version from Thank you all for your assistance! If this crops up again, feel free to post a new comment here, or re-open a new issue. |
Looks like this is cropping up again for some reason. If anyone still runs into this, feel free to provide an update in #159 (discussion will continue there). |
Times are now passed to ffmpeg in seconds, not the previous HH:MM:SS.nnnn format. This seems to improve accuracy and reduce the chance of extra frames showing up at the end of a particular video. See #93.
Hey all; I pushed one more fix for this issue to master just now, it seems in some cases the actual timecode formatting was skewing the end time by an extra frame. This should reduce the occurrences of this issue significantly. Note that it has not been completely resolved, so if this does still happen to anyone, I encourage you to provide more test cases to validate against, and provide any additional details you can. I've identified some options that can be added to
Where VIDEO_FRAMERATE must be set to the exact framerate of the video. If you are still experiencing this issue but this command resolves it, please let me know by responding to this issue or #159. Thank you all for your assistance and patience with this issue. |
Thanks for the update and the fix, I'll try it out soon ! |
@typoman Not sure how I was able to replicate this on my end - I tried with both an old and new version of ffmpeg on my system (Windows) just now, and don't see the same output (I get frame perfect cuts on the Goldeneye test clip). Starting to wonder if this only affects a particular version of ffmpeg or a particular OS/distribution. I definitely see the 1-2 extra frames in the output you provided me, am just having trouble replicating that on my end for some reason. Would you be able to re-run that test with PySceneDetect v0.5.2, as well as a newer version of ffmpeg? Thanks! Edit: Will try to run this on Linux instead now to see if that changes anything. Edit: Same result on both Windows/Linux using PySceneDetect v0.5.2... |
Hey I tried to use it but I get this:
I'm on Catalina and a new system. |
@typoman Interesting, I was able to just install it on a new Linux system without issue... I think the package is called (The "option" I added to PySceneDetect is called just openCV, but if it's causing an issue like this, I'll rename it to match the opencv-python package name) |
Hey I installed the opencv and it works now. Unfortunately I still get the extra frames at the end of some segments. |
@typoman Could you test the development version of v0.6 ( https://github.com/Breakthrough/PySceneDetect/archive/v0.6.x.zip )? It includes another potential fix for this issue related to the audio encoding. Also which media were you testing with, the Goldeneye test video, or just your own media? Could you share the results you're getting as well as the source material if possible? Thank you so much for your assistance! Please provide as much info as you can where possible, I really want to fix this for the next release! |
Here is the command I used with pip installed version and the output. Source is the golden eye video:
The splitted output: When I use the debuggin mode I get this:
I will post the second try with the zipped version you linked in the next comment. |
Here is the output from the development version of v0.6. Everything looks correct this time except one cut was missed in the goldeneye-Scene-017.mp4. At least no extra frames anymore.
|
Awesome, that is exactly the expected result. Thank you so much for your assistance @typoman, I really appreciate it! This confirms that #166 closes this issue (#93), as well as #159. Also thanks for letting me know about the issues using debug mode, I've opened up a new defect to track that (#169). If you run into any other issues, or this happens to reoccur in the future, please feel free to create a new defect again. Thank you all so much for your assistance in closing this one out, will try to get a maintenance release out before v0.6 officially into pip as soon as possible. |
I am facing the problem where extra frames appear at the end of detect scenes. I am using PySceneDetect v0.5.4, Python 3.7.7 |
Hi @adibMosharrof; Hmm I see, do you mean in the video files it generates, or images? In your script, it looks like you're comparing the frame index to the total number of frames. The last index will always be one less than the total # of frames, because if we have a 1-frame video, it starts and ends at frame 0. However, I will try to replicate this on my end with the video you provided first. Would you be able to upload it to this issue directly? I want to make sure I'm using the exact same source input as you. If you could also zip and attach the output from PySceneDetect showing the extra frames, that would also be helpful. Lastly, could you also provide the version of ffmpeg you have installed? Thank you! |
Hello @Breakthrough Thank you very much for the quick response. I took a look at the indexes. The starting frame number of the first scene that is detected has a frame number of 0, and the ending frame number of the last scene that is detected has a frame number 1799, whereas the total number of frames in the video was 1788. I am not using ffmpeg, when i check my pip env for ffmpeg -version, i get ffmpeg command not found. As for the outputs, do you want me to provide a csv file for the scenes that were generated? I can provide that as well as the video that I am using to this issue |
Hi @adibMosharrof; How are you validating the output? I know that the OpenCV frame count isn't 100% accurate for every single type of video/container (i.e. calling
This resulted in exactly 1799 frames being extracted. Looking frame by frame, the cuts PySceneDetect provided in the CSV you gave seem accurate to me. I've attached a .ZIP containing the last 10 frames as well as the output from Note that the numbers in the Thanks! |
Thank you very much for the response and debugging the example video. I think I will have to switch to ffmpeg for extracting frames instead of opencv. |
First of all thank you for such a great tool! It seems that the precise flag (-p or --precise) has been changed to preset and does not work anymore although it's still written in the readme of the repo. I used the content detect option but still the cuts are not precise and there are some frames that overlap with the previous scene. Is there any way to cut the scenes more precisely?
The text was updated successfully, but these errors were encountered: