PyAV
PyAV copied to clipboard
Logging can't be disabled
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: [email protected]: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:
- [x ] Checked the PyAV documentation
- [x ] Searched on Google
- [x ] Searched on Stack Overflow
- [x ] Looked through old GitHub issues
- [x ] Asked on PyAV Gitter
- [x ] ... and waited 72 hours for a response.
Hey! I faced same issue, anyone know how to fix it?
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.
Let's keep this issue alive, the logging framework is due for an overhaul.
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?
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
I'd still love to see this fixed, though I'm not sure I'll have time to do it myself.
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.
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.
same issue. mark
I implemented a "dirty" workaround in PR https://github.com/PyAV-Org/PyAV/pull/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 =)
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()
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'})
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
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)
@WyattBlue should I close this then?