Skip to content
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

Use audio_codec option even if audio is given as filename #1906

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

zalgo3
Copy link

@zalgo3 zalgo3 commented Jan 30, 2023

moviepy.video.VideoClip.write_videofile ignores audio_codec when audio is a file name. I have fixed it in this PR.

  • I have provided code that clearly demonstrates the bug and that only works correctly when applying this fix
    • moviepy.video.VideoClip.write_videofile("output.mp4", audio="input.wav", fps=60, audio_codec="aac") have run ffmpeg with -acodec copy. With this PR, it will run the command with -acodec aac.
  • I have added suitable tests demonstrating a fixed bug or new/changed feature to the test suite in tests/
  • I have properly documented new or changed features in the documentation or in the docstrings
  • I have properly explained unusual or unexpected code in the comments around it

@coveralls
Copy link

coveralls commented Feb 6, 2023

Coverage Status

Coverage: 83.988% (-0.8%) from 84.751% when pulling e7cbfd3 on zalgo3:use-audio-codec-for-existing-audiofile into 86fd511 on Zulko:master.

@keikoro
Copy link
Collaborator

keikoro commented Feb 22, 2023

Thanks for your PR.

I think I might nab just the black formatting fixes for now to prevent our checks from failing (even though they don't even fail consistently...).

@keikoro keikoro mentioned this pull request Feb 22, 2023
@@ -81,6 +84,7 @@ def __init__(
fps,
codec="libx264",
audiofile=None,
audio_codec=None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not default to "copy" directly here ?

Copy link
Author

@zalgo3 zalgo3 Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your question! The default value of audio_codec in VideoClip.write_videofile is None, so I also adapted FFMPEG_VideoWriter to that.

audio_codec=None,

This pull request intends that in VideoClip.write_videofile, if a filename is given for the audio argument and a codec name is given for audio_codec, then it will be encoded according to that codec, but If audio_codec=None, I thought it would be better to have it copy as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants