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

fix: hande different images ratios and audios formats #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

manssorr
Copy link

@manssorr manssorr commented Nov 22, 2024

Changes:

  • change scale=-1:720 to vf scale="trunc(oh*a/2)*2:720"
  • oh is the output height (720 in your case).
  • a is the aspect ratio of the input image.
  • trunc(.../2)*2 ensures the calculated width is divisible by 2.

The scale filter computes the width based on the desired height (720) while maintaining the aspect ratio of the input image. By applying trunc(.../2)*2, the width is forced to be divisible by 2.

  • change -acodec copy to -c:a aac -b:a 192k
  • c:a aac: Specifies the AAC codec for encoding the audio, which is widely supported.
  • b:a 192k: Sets the audio bitrate to 192 kbps for good quality.

Using -acodec copy does not re-encode the audio, which means FFmpeg won't fix any compatibility issues between the input audio and output container, so solution is encode the audio stream instead of copying it.

FYI

Supported Formats with -c:a aac

When encoding audio as AAC, you can use the following common output file formats:

  1. MP4 (.mp4)
  • One of the most widely supported formats.
  • Commonly used for online video platforms, mobile devices, and streaming.
  • Compatible with most players like VLC, QuickTime, and web browsers.
  1. M4A (.m4a)
  • Audio-only version of MP4.
  • Frequently used for music and podcasts.
  • Supported by media players like iTunes and portable devices.
  1. MOV (.mov)
  • Apple’s video format, often used in professional environments.
  • Supported by QuickTime and editing software like Final Cut Pro.
  1. MKV (.mkv)
  • Open-source multimedia container.
  • Often used for high-quality video and audio files.
  • Compatible with VLC, MPC-HC, and other modern players.
  1. TS (.ts)
  • Transport Stream format used in broadcasting.
  • Suitable for streaming applications.
  1. FLV (.flv)
  • Flash Video format, commonly used in legacy streaming.
  • Still supported by players like VLC.
  1. WebM (.webm)
  • Open-source format designed for web use.
  • Supported by modern web browsers and video players.

Playback Compatibility

AAC is supported by most modern devices and platforms, including:

  • Mobile Devices: iOS, Android, and Windows devices.
  • Web Browsers: Chrome, Firefox, Safari, and Edge.
  • Streaming Services: YouTube, Netflix, and others use AAC for audio encoding.
  • Media Players: VLC, QuickTime, Windows Media Player (with proper codecs), and others.

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.

1 participant