Skip to content

Add set_log_level on ffmpeg#46

Open
kipcole9 wants to merge 1 commit intoelixir-webrtc:masterfrom
kipcole9:loglevel
Open

Add set_log_level on ffmpeg#46
kipcole9 wants to merge 1 commit intoelixir-webrtc:masterfrom
kipcole9:loglevel

Conversation

@kipcole9
Copy link
Copy Markdown
Contributor

Per issue #45, here is a proposed PR to allow setting the ffmpeg log level with either Xav.Reader.set_log_level/1. Compiled and tested on my MacBook Pro with ffmpeg@7.

Summary

Adds a thin Elixir wrapper around FFmpeg's av_log_set_level(int). Also adds an application-env-driven default so applications can configure the level once in config/runtime.exs instead of calling the setter from their own Application.start/2. You may want to remove the second part.

Background

libswscale prints informational lines to stderr at FFmpeg's default log level (AV_LOG_INFO) whenever it falls back to a generic C conversion path instead of a SIMD-optimised one, for example:

[swscaler @ 0x1490a0000] No accelerated colorspace conversion found from yuv420p to rgb24.

Today there is no way to silence the notices from Elixir code because Xav does not expose av_log_set_level/1. Users have to either redirect stderr wholesale (which also hides real errors) or rebuild FFmpeg with the missing SIMD paths.

Design

  • Wrapper lives on Xav.Reader to keep it next to the most obvious caller, even though av_log_set_level/3 is process-global and affects every libav* call made from the VM (reader, decoder, encoder).

  • Accepts atoms: (:quiet | :panic | :fatal | :error | :warning | :info | :verbose | :debug | :trace) rather than FFmpeg's integer constants, so callers don't need to know the magic numbers. The atom → integer mapping is the Elixir side; the NIF itself just takes an int.

  • Application-env default: A new Xav.Application module reads Application.get_env(:xav, :log_level) once at application start and applies it. Users who want quiet decoding globally just add:

    # config/runtime.exs
    config :xav, log_level: :error
  • No behaviour change by default. If :log_level is unset, Xav.Application.start/2 leaves FFmpeg's default untouched (AV_LOG_INFO), so existing users see identical output.

Questions

  • Should the wrapper live on Xav instead of Xav.Reader?
  • Should the default log level come from an env var (e.g. XAV_LOG_LEVEL) as well as the application env, to match what FFmpeg users might already expect? Easy to add — maybe_set_log_level/0 would check both in order.
  • Is use Application + a no-children supervisor acceptable as a minimal app callback - its only there to read the config and set log level.

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