Cut pow/resume and postprocess video - #225
Merged
Merged
Conversation
pharmapsychotic
approved these changes
May 9, 2023
Comment on lines
+211
to
+233
| def extract_frames_from_video(video_path: str, frames_subdir: str='frames'): | ||
| """ | ||
| Extracts all frames from a video to a subdirectory of the video's parent folder. | ||
| :param video_path: A path to the video. | ||
| :param frames_subdir: Name of the subdirectory to save the frames into. | ||
| :return: The frames subdirectory path. | ||
| """ | ||
| out_dir = os.path.join(os.path.dirname(video_path), frames_subdir) | ||
| if not os.path.exists(out_dir): | ||
| os.mkdir(out_dir) | ||
|
|
||
| cmd = [ | ||
| 'ffmpeg', | ||
| '-i', video_path, | ||
| os.path.join(out_dir, "frame_%05d.png"), | ||
| ] | ||
| process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
| _, stderr = process.communicate() | ||
| if process.returncode != 0: | ||
| raise RuntimeError(stderr) | ||
|
|
||
| return out_dir | ||
|
|
Contributor
There was a problem hiding this comment.
create_video_from_frames lives in animation.py and I think it would make sense to have frames -> video and video -> frames both live in the same place.
Contributor
There was a problem hiding this comment.
maybe we should move create_video_from_frames to utils then?
|
Kudos, SonarCloud Quality Gate passed!
|
pharmapsychotic
approved these changes
May 10, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








resumeoption is selected, the animation will be continued from the last existing frame ifresume_from=-1, or any specific positive frame number.Inputtab, because they kind of overwrite init image, but it's up for discussionPosttab because it is input, but it's also up for a discussion.FileandUploadButtonallow to use file manager to navigate to a video instead of specifying its path, but for some reason they both were freezing the notebook rendering for me. I haven't tried running it in colab, and haven't played around it much, but decided to go for a simpler (although a bit less convenient) solution, especially since thevideo_input_pathis a Text also.