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

Logging can't be disabled #711

Closed
pohmelie opened this issue Oct 11, 2020 · 15 comments · Fixed by #1383
Closed

Logging can't be disabled #711

pohmelie opened this issue Oct 11, 2020 · 15 comments · Fixed by #1383
Labels

Comments

@pohmelie
Copy link

Overview

I want to shut up any logging from av and underlying ffmpeg. I tried all of this:

logging.basicConfig()
av.logging.set_level(av.logging.PANIC)
logging.getLogger('libav').setLevel(logging.ERROR)

Btw, docs said there is av.logging.QUIET, but it missed.

Expected behavior

No logs.

Actual behavior

I encode video frame by frame. I see tons of almost equal output like this:

[jpeg2000 @ 0x7f8408000940] End mismatch 3
[jpeg2000 @ 0x7f8408000940] End mismatch 4
[jpeg2000 @ 0x7f8408000940] End mismatch 4
[jpeg2000 @ 0x7f8408000940] End mismatch 3
[jpeg2000 @ 0x7f8408000940] End mismatch 3
[jpeg2000 @ 0x7f8408000940] End mismatch 3

Versions

  • OS: ubuntu 20.04
  • PyAV runtime:
PyAV v8.0.2
git origin: git@github.com:PyAV-Org/PyAV
git commit: v8.0.2
library configuration: --disable-doc --disable-static --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-shared --enable-version3 --enable-zlib --prefix=/tmp/vendor
library license: GPL version 3 or later
libavcodec     58. 54.100
libavdevice    58.  8.100
libavfilter     7. 57.100
libavformat    58. 29.100
libavutil      56. 31.100
libswresample   3.  5.100
libswscale      5.  5.100
  • PyAV build:
    pip installed
  • FFmpeg:
ffmpeg version N-90315-gf706cdd Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
configuration: --prefix=/opt/tnt --pkg-config-flags=--static --extra-cflags='-fPIC -I/opt/tnt/include' --extra-ldflags='-Wl,-rpath,/opt/tnt/lib/x86_64-linux-gnu -L/opt/tnt/lib/x86_64-linux-gnu' --extra-libs='-lpthread -lm' --libdir=/opt/tnt/lib/x86_64-linux-gnu --bindir=/opt/tnt/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libspeex --enable-nonfree --enable-pic --enable-shared
libavutil      56.  9.100 / 56.  9.100
libavcodec     58. 14.100 / 58. 14.100
libavformat    58. 10.100 / 58. 10.100
libavdevice    58.  2.100 / 58.  2.100
libavfilter     7. 13.100 /  7. 13.100
libswscale      5.  0.102 /  5.  0.102
libswresample   3.  0.101 /  3.  0.101
libpostproc    55.  0.100 / 55.  0.100

Research

I have done the following:

@pohmelie pohmelie added the bug label Oct 11, 2020
@ashat1701
Copy link

Hey! I faced same issue, anyone know how to fix it?

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 27, 2022
@jlaine
Copy link
Member

jlaine commented Mar 27, 2022

Let's keep this issue alive, the logging framework is due for an overhaul.

@jlaine jlaine removed the stale label Mar 27, 2022
@d4l3k
Copy link

d4l3k commented Apr 11, 2022

Are the logging levels flipped?

I've been getting some ffmpeg logs that I wanted to silence to avoid spamming the console but I'm seeing some weird behavior.

av.logging.set_level(logging.INFO/DEBUG) silences the ffmpeg warnings but WARNING-CRITICAL show them. It seems like it should be the opposite. If you set log level CRITICAL it should only show CRITICAL and above logs. But it seems to be only X and below priority. So setting logging.INFO only shows INFO and DEBUG but not error/critical?

@nilsh
Copy link

nilsh commented Jul 30, 2022

Update on this for my tests:

  • av.logging.set_level(logging.INFO) will suppress most (but not all) warnings
  • av.logging.set_level(logging.ERROR) will NOT suppress many warnings
  • av.logging.set_level(av.logging.PANIC) works as expected and suppresses all warnings I get so far

@jlaine
Copy link
Member

jlaine commented Oct 17, 2022

I'd still love to see this fixed, though I'm not sure I'll have time to do it myself.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Feb 15, 2023
@InkosiZhong
Copy link

I'm trying to use PyAV to mux a lot of video, so I want to disable the log as below:

x265 [info]: HEVC encoder version 3.5+1-f0c1022b6
x265 [info]: build info [Linux][GCC 10.2.1][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 16 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 4 / wpp(17 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 3
x265 [info]: Keyframe min / max / scenecut / bias  : 25 / 250 / 40 / 5.00 
x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 3 / off / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : ABR-1024 kbps / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 early-skip rskip mode=1 signhide tmvp
x265 [info]: tools: b-intra strong-intra-smoothing lslices=6 deblock sao

encoded 0 frames

I have tried the methods in https://pyav.org/docs/develop/api/utils.html, but the log still exists. And I find this line in the doc:

This will leave (or restore) the FFmpeg logging system, which prints to the terminal. This may also result in raised errors having less detailed messages.

I think this log may be produced by ffmpeg. How can I disable it? Thank you very much.

@github-actions github-actions bot removed the stale label Mar 1, 2023
@hanl754
Copy link

hanl754 commented Jun 6, 2023

same issue. mark

@eerimoq
Copy link

eerimoq commented Jun 18, 2023

I implemented a "dirty" workaround in PR #1133. It's obviously a proper solution, so if someone can figure out how to implement a proper fix, feel free to ignore my PR =)

@eerimoq
Copy link

eerimoq commented Jun 19, 2023

Another workaround is to close stderr, given that your application does not write other information to it.

import os
import av
os.close(2)
av.logging.restore_default_callback()

@zthorson
Copy link

zthorson commented Sep 8, 2023

A slightly cleaner workaround is to pass arguments to ffmpeg itself to disable logging. This got rid of the chatty h265 encoder messages for me while leaving stderr untouched.

For example:

av_codec = av.CodecContext.create('hevc', 'r')
mp4 = av.open('./test.mp4', mode='w')
cur_mp4_stream = stream.mp4.add_stream('hevc', rate=30, options={'x265-params': 'log_level=none'})

@gonzaloplaza
Copy link

If you're still looking for a workaround, updating the log level to a higher one worked for us

More info here: https://pyav.org/docs/stable/api/utils.html

logging.getLogger("libav").setLevel(logging.FATAL)

Also they suggest to set this env variable to off, but it didn't work in our case:

export PYAV_LOGGING=off

@WyattBlue WyattBlue linked a pull request Nov 11, 2023 that will close this issue
@github-actions github-actions bot added the stale label Feb 2, 2024
@WyattBlue WyattBlue removed the stale label Feb 2, 2024
@PyAV-Org PyAV-Org deleted a comment from github-actions bot Feb 2, 2024
@WyattBlue WyattBlue removed a link to a pull request Apr 24, 2024
@WyattBlue WyattBlue linked a pull request Apr 24, 2024 that will close this issue
@WyattBlue
Copy link
Member

WyattBlue commented Apr 24, 2024

You can disable logs now in master. In fact, it's the default behaviour now.

import av

# turn off logs
av.logging.set_level(None)

# turn on logs
av.logging.set_level(av.logging.VERBOSE)

@pohmelie
Copy link
Author

@WyattBlue should I close this then?

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

Successfully merging a pull request may close this issue.