-
Notifications
You must be signed in to change notification settings - Fork 275
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
WIP: add destructor to FFmpegWriter #429
Open
chad3814
wants to merge
5
commits into
OpenShot:develop
Choose a base branch
from
chad3814:FFmpegWriter-memory
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0964939
add destructor to FFmpegWriter
d522e7e
move the resource freeing to a separate method, and call it from both…
3dc444a
Merge branch 'develop' into FFmpegWriter-memory
ferdnyc c04d670
FFmpegWriter_Tests: Add Close-reopen unit test
ferdnyc d26aafb
Merge branch 'develop' into FFmpegWriter-memory
ferdnyc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only just taken a cursory look at this, but one thing I will say: If at all possible, it would be better to avoid calling
Close()
in the destructor. There's too much of that already in libopenshot, and we need to avoid it because ourClose()
methods are waaaay too heavy. They do a lot of housekeeping "stuff" in preparation for being reopened again, which of course makes no sense in a destructor.See the discussion at #378, and in particular #378 (comment), for more on that.
It may mean having to reimplement some parts of
Close()
in the destructor, or separate them out into a new method (Finalize()
?) thatClose()
also calls, but it would be good to avoid all of the unnecessary "stuff" inClose()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. FFmpegWriter's
Close()
is actually pretty good, as libopenshotClose()
methods go. It doesn't do too much rearranging of deck chairs on the Titanic, as the saying goes, and most of what it does is properly conditional.It does unconditionally do this, though:
libopenshot/src/FFmpegWriter.cpp
Lines 1020 to 1022 in 49972b2
...which may be a problem in a destructor, if there is no valid
oc
to free. May be as simple as slapping anif (oc)
around it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also calls ZeroMQ as its very last action:
libopenshot/src/FFmpegWriter.cpp
Line 1030 in 49972b2
which DEFINITELY should not be done from a destructor. But since that's just a debug
printf()
with no useful information, really it can just be removed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I take it back.
Close()
itself is fairly lightweight, but the methods it calls are WAY too heavy.WriteTrailer()
,close_video()
,close_audio()
, they all do a lot of processing that will bite us in a destructor.If the video file hasn't been successfully written by the time the destructor is called, I don't think it's realistic for the destructor to try and complete the encoding process before it goes away. That's what an explicit
Close()
is for, and if the caller hasn't called it by the time the FFmpegWriter object is being destroyed, IMHO it should just close the output stream and drop everything on the floor, not try and write it all out first.