Fix write_videofile error handling and update write_audiofile to be comparable #1164
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.
I found that #890 actually broke the catching of errors under the default settings (ie without a log file). This is because when there is no default settings,
self.logfile
is equal tosp.PIPE
, which is just an integer, so it has noname
attribute. With this PR, we make sure that we only deal withself.logfile
ifproc.communicate()
returnsNone
(if the return is simply empty, it returnsb""
, so that is accounted for).I've included a test for the default case to ensure that this doesn't happen again.
Also, instead of getting the name of the log file and reopening it, I thought that it made more sense to use the existing file handler that is already open and simply
seek
back to the start and read it again.I slightly updated the string handling as well, making it convert to bytes using
.decode()
, and one of the string matchers seemed to be wrong or least outdated (I checked what the actual error ffmpeg returns is), and with my change it matches successfully whenbitrate="1"
).Finally, I've applied #890 and all the above changes to
ffmpeg_audiowriter
as well, so now they should both be directly comparable.tests/
black -t py36
Because this is a small change, I'll merge it myself in a few days, unless anyone else says otherwise.