mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
27.87k stars 2.87k forks source link

How to open logs? #13181

Closed Naylor55 closed 8 months ago

ahaoboy commented 8 months ago

Try --log-file? https://[mpv.io](https://mpv.io/manual/master/#options-log-file)/manual/master/#options-log-file

 ./mpv ./t.mp4  --log-file=./log.txt
Naylor55 commented 8 months ago

@ahaoboy thanks ! I have almost completely solved my problem using the prompts you provided。 Because I am using avaloniaui and Libmpv , so My code is as follows :


[ObservableObject]
public abstract partial class BaseMpvContextViewModel : MpvContext
{

......

    public void LoadFile(string fileName, string mode = "replace")
    {
        Command("loadfile", fileName, mode);
        SetOptionString("keepaspect", "no");
        SetOptionString("hwdec", "auto-copy");
        SetOptionString("video-sync", "display-resample");
        SetOptionString("interpolation", "yes");
        SetOptionString("tscale", "oversample");
        //设置log输出文件
        //SetOptionString("log-file", "D:\\temp\\mpv.log");
        SetOptionString("log-file", "/tmp/mpv/mpv.log");
        SetOptionString("msg-level", "all=error");

        //Command("keepaspect", "yes");
        //this.Command("no-keepaspect");
    }

    ......
}

when I add SetOptionString("log-file", "/tmp/mpv/mpv.log"); and SetOptionString("msg-level", "all=error"); , mpv-log can push to /tmp/mpv/mpv.log ; but it print all type log (error ,debug, others )

part of mpv.log


[   3.566][v][cplayer] mpv 0.29.1 Copyright © 2000-2018 mpv/MPlayer/mplayer2 projects
[   3.566][v][cplayer]  built on Sat Dec 22 13:29:28 UTC 2018
[   3.566][v][demux] Trying demuxers for level=request.
[   3.566][v][cplayer] ffmpeg library versions:
[   3.566][v][cplayer]    libavutil       56.22.100
[   3.566][v][cplayer]    libavcodec      58.35.100
[   3.566][v][cplayer]    libavformat     58.20.100
[   3.566][v][cplayer]    libswscale      5.3.100
[   3.566][v][cplayer]    libavfilter     7.40.101
[   3.566][v][cplayer]    libswresample   3.3.100
[   3.566][v][cplayer] ffmpeg version: n4.1
[   3.566][v][cplayer] 
[   3.566][v][cplayer] Configuration: ./waf configure --enable-libmpv-shared --prefix=/usr --disable-vapoursynth --enable-lgpl --disable-drm --disable-drmprime --disable-lcms2 --disable-caca --disable-wayland --disable-gl-wayland --disable-libarchive --disable-zlib --disable-tv --disable-debug-build --disable-manpage-build --disable-libsmbclient --disable-wayland --disable-sdl --disable-sndio --enable-plain-gl --disable-cplugins
[   3.566][v][cplayer] List of enabled features: 52deb asm atomics build-date cplayer fchmod ffmpeg gl glibc-thread-name glob glob-posix gnuc iconv jpeg lgpl libass libass-osd libav-any libavcodec libavdevice libdl libm libmpv-shared librt linux-fstatfs lua optimize plain-gl posix posix-or-mingw posix-spawn posix-spawn-native pthreads pulse vt.h
[   3.566][v][cplayer] Set property: log-file="/tmp/mpv/mpv.log" -> 1
[   3.566][d][global] user path: '/tmp/mpv/mpv.log' -> '/tmp/mpv/mpv.log'
[   3.566][v][cplayer] Set property: msg-level="all=error" -> 1

To add, I would like to only print the error log

Akemi commented 8 months ago

read the documentation of the option you used. it's not possible with that option

The log level is at least -v -v, but can be raised via --msg-level (the option cannot lower it below the forced minimum log level).

you probably need to redirect the stdout/stderr with the proper --msg-level set, you might need to activate the --terminal.