You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extra frames sometimes appear at the end of split videos #93
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 default behaviour of PySceneDetect now is what precise mode was before. Scenes should be split accurately and re-encoded by ffmpeg when using the split-video command. To disable this and go back to the old behaviour, supply the -c/--copy flag to the split-video command.
Are you seeing a different/unexpected result? How many frames are overlapping? Could you provide some more details, like the complete command/example output?
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 ffmpeg installed for precise cutting to work.
I had installed ffmpeg when I was doing the tests. I'm sorry for the delayed answer but since I was in a hurry I just used another solution to split the videos manually. My config is OS X 10.13.6 and I think I used default flags. In the split videos, I saw frames from the previous scene just for the first or two frames. The codec was h264 and the format was mp4. If you want I can perform a test on a video (or a link) you provide and send you back what I get then you can compare results?
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...)
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 resources branch.
Downloads % scenedetect --input goldeneye.mp4 detect-content split-video
Traceback (most recent call last):
File "/Users/bman/.pyenv/versions/3.8.2/bin/scenedetect", line 5, in <module>
from scenedetect import main
File "/Users/bman/.pyenv/versions/3.8.2/lib/python3.8/site-packages/scenedetect/__init__.py", line 52, in <module>
from scenedetect.scene_manager import SceneManager
File "/Users/bman/.pyenv/versions/3.8.2/lib/python3.8/site-packages/scenedetect/scene_manager.py", line 56, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
Downloads % pip install opencv
ERROR: Could not find a version that satisfies the requirement opencv (from versions: none)
ERROR: No matching distribution found for opencv
zsh: no matches found: scenedetect[opencv,progress_bar]
bman@Bahmans-MacBook-Pro Downloads % pip install scenedetect[opencv,progress_bar]
zsh: no matches found: scenedetect[opencv,progress_bar]
@typoman Interesting, I was able to just install it on a new Linux system without issue... I think the package is called opencv-python, can you try installing that one? (e.g. pip install opencv-python)
(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)
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!
Downloads % scenedetect -v debug -l BUG_REPORT.txt --input goldeneye.mp4 detect-content split-video
Traceback (most recent call last):
File "/Users/bman/.pyenv/versions/3.8.2/bin/scenedetect", line 8, in <module>
sys.exit(main())
File "/Users/bman/.pyenv/versions/3.8.2/lib/python3.8/site-packages/scenedetect/__main__.py", line 58, in main
cli.main(obj=cli_ctx) # Parse CLI arguments with registered callbacks.
File "/Users/bman/.pyenv/versions/3.8.2/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Users/bman/.pyenv/versions/3.8.2/lib/python3.8/site-packages/click/core.py", line 1268, in invoke
Command.invoke(self, ctx)
File "/Users/bman/.pyenv/versions/3.8.2/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/bman/.pyenv/versions/3.8.2/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Users/bman/.pyenv/versions/3.8.2/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/Users/bman/.pyenv/versions/3.8.2/lib/python3.8/site-packages/scenedetect/cli/__init__.py", line 261, in scenedetect_cli
logfile = ctx.obj.get_output_file_path(logfile)
AttributeError: 'CliContext' object has no attribute 'get_output_file_path'
Downloads %
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
Here is a sample code that I created to show the extra frames error
Please let me know if you need more information that might assist in helping to solve the issue.
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?
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 tmp.zip
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 get(cv2.CAP_PROP_FRAME_COUNT) may return a number lower than the actual number of frames in a video). I verified this by using ffmpeg to extract all frames from the video you provided:
ffmpeg -i [video.mp4] thumb%04d.jpg
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 split-images for you to compare on your machine: last-10-frames.zip save-images-output.zip
Note that the numbers in the last-10-frames.zip start from 1 instead of 0, so in the .CSV, you have to add +1 to the starting frame to get the filename. You can also verify the splits are correct using the save-images command.
Activity
Breakthrough commentedon Feb 10, 2019
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
split-videocommand. To disable this and go back to the old behaviour, supply the-c/--copyflag to thesplit-videocommand.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!
Breakthrough commentedon Apr 14, 2019
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
ffmpeginstalled for precise cutting to work.Thanks!
typoman commentedon Apr 15, 2019
Hi @Breakthrough,
I had installed
ffmpegwhen I was doing the tests. I'm sorry for the delayed answer but since I was in a hurry I just used another solution to split the videos manually. My config is OS X 10.13.6 and I think I used default flags. In the split videos, I saw frames from the previous scene just for the first or two frames. The codec was h264 and the format was mp4. If you want I can perform a test on a video (or a link) you provide and send you back what I get then you can compare results?Breakthrough commentedon Apr 15, 2019
Hi @typoman;
You can try with the goldeneye.mp4 file from here:
https://github.com/Breakthrough/PySceneDetect/tree/resources/tests/goldeneye
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!
typoman commentedon Apr 20, 2019
I can't share my files but I encounter the same issue with your sample. The command I used:
scenedetect --input goldeneye.mp4 detect-content split-videoWhen 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:
Archive.zip
Breakthrough commentedon Apr 20, 2019
@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.
typoman commentedon Apr 28, 2019
Bug/Issue Description:
A clear and concise description of what the bug or issue is - in other words, what the unexpected behavior or output is.
Imprecise cutting (as mentioned above)
Required Information:
Provide the following information to assist with reporting the bug:
scenedetect -v debug -l BUG_REPORT.txt --input goldeneye.mp4 detect-content split-videoOutput:
-v debug -l BUG_REPORT.txtto the beginning of the command, then re-run PySceneDetect and attach the generatedBUG_REPORT.txtfile.Expected Behavior:
A clear and concise description of what you expected to happen.
Precise cutting!
Computing Environment:
BUG_REPORT.txt
Breakthrough commentedon Jul 21, 2019
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
resourcesbranch.36 remaining items
typoman commentedon Jul 2, 2020
Hey I tried to use it but I get this:
I'm on Catalina and a new system.
Breakthrough commentedon Jul 2, 2020
@typoman Interesting, I was able to just install it on a new Linux system without issue... I think the package is called
opencv-python, can you try installing that one? (e.g.pip install opencv-python)(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)
typoman commentedon Jul 6, 2020
Hey I installed the opencv and it works now. Unfortunately I still get the extra frames at the end of some segments.
Breakthrough commentedon Jul 7, 2020
@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!
typoman commentedon Jul 9, 2020
Here is the command I used with pip installed version and the output. Source is the golden eye video:
The splitted output:
goldeneye.zip
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.
typoman commentedon Jul 9, 2020
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.
goldeneye2.zip
Breakthrough commentedon Jul 9, 2020
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.
adibMosharrof commentedon Feb 5, 2021
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
Here is a sample code that I created to show the extra frames error
Please let me know if you need more information that might assist in helping to solve the issue.
Breakthrough commentedon Feb 6, 2021
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!
adibMosharrof commentedon Feb 6, 2021
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
tmp.zip
Breakthrough commentedon Feb 6, 2021
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
get(cv2.CAP_PROP_FRAME_COUNT)may return a number lower than the actual number of frames in a video). I verified this by usingffmpegto extract all frames from the video you provided: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
split-imagesfor you to compare on your machine:last-10-frames.zip
save-images-output.zip
Note that the numbers in the
last-10-frames.zipstart from 1 instead of 0, so in the .CSV, you have to add +1 to the starting frame to get the filename. You can also verify the splits are correct using thesave-imagescommand.Thanks!
adibMosharrof commentedon Feb 6, 2021
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.