04.8.2024, 11:44
Další užitečné možnosti logování
Někdy se hodí, zvláště pokud se věnujete optimalizaci zpracování real time streamů, mít přehled o tom, co se na jednotlivých úrovních zpracování streamu děje. Streamlink pro to poskytuje další možnosti, které získáte použitím dalších parametrů příkazového řádku:
--ffmpeg-verbose-path <file>
Protokoluje streamy tak, jak je vidí a zpracuje ffmpeg. Výstup může vypadat nějak takto:
--loglevel <level>
--logfile <file>
Kde loglevel určuje úroveň protokolování definovanou v <level>, což je jeden z parametrů none, critical, error, warning, info, debug, traceall a logfile pak v parametru <file> definuje jméno souboru, do kterého se log ukládá. Je třeba vzít na vědomí, že v případě adaptivních porotkolů se do souboru <logfile> zapisují data - tzn. informce o jednotlivých chunks - postupně v průběhu přehrávání streamu. Takovýto log pak může vypadat nějak takto:
Já mám obvykle se scriptu streamer.sh, připraveny dvě verze volání streamlink, z nichž jedna obsahuje pouze základní porotokolování, zatímco druhá to úplné. Umožní mi to mít základní přehled o chování stremů kdykoliv (i zpětně) - to když použiju tu první verzi - a v případě, že dojde k nějakému problému, tak si uvolním tu verzi druhou, kde vidím úplně všechno. Tady je třeba si uvědomit, že verze s úplným protokolováním o něco prodlouží čas volby/přepnutí kanálů, ale také to, že může na disk/kartu zapisovat soustavně nějaká data, což může být u některých konfigurací nežádoucí.
Někdy se hodí, zvláště pokud se věnujete optimalizaci zpracování real time streamů, mít přehled o tom, co se na jednotlivých úrovních zpracování streamu děje. Streamlink pro to poskytuje další možnosti, které získáte použitím dalších parametrů příkazového řádku:
--ffmpeg-verbose-path <file>
Protokoluje streamy tak, jak je vidí a zpracuje ffmpeg. Výstup může vypadat nějak takto:
Kód:
ffmpeg version 5.1.5-0+rpt1+deb12u1 Copyright (c) 2000-2024 the FFmpeg developers
built with gcc 12 (Debian 12.2.0-14)
configuration: --prefix=/usr --extra-version=0+rpt1+deb12u1 --toolchain=hardened --incdir=/usr/include/aarch64-linux-gnu --enable-gpl --disable-stripping --disable-mmal --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sand --enable-sdl2 --disable-sndio --enable-libjxl --enable-neon --enable-v4l2-request --enable-libudev --enable-epoxy --libdir=/usr/lib/aarch64-linux-gnu --arch=arm64 --enable-pocketsphinx --enable-librsvg --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
[h264 @ 0x555591d97d90] Increasing reorder buffer to 2
[h264 @ 0x555591d97d90] Increasing reorder buffer to 3
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/streamlinkpipe-1929747-1-1193':
Metadata:
major_brand : iso6
minor_version : 0
compatible_brands: iso6dash
Duration: 478545:15:55.22, start: 1722762953.358333, bitrate: N/A
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 600 tbn (default)
Metadata:
handler_name : USP Video Handler
vendor_id : [0][0][0][0]
encoder : h264
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/streamlinkpipe-1929747-2-6040':
Metadata:
major_brand : iso6
minor_version : 0
compatible_brands: iso6dash
Duration: 478545:15:55.24, start: 1722762953.321292, bitrate: N/A
Stream #1:0[0x1](mul): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp (default)
Metadata:
handler_name : USP Sound Handler
vendor_id : [0][0][0][0]
Output #0, mpegts, to 'pipe:1':
Metadata:
major_brand : iso6
minor_version : 0
compatible_brands: iso6dash
encoder : Lavf59.27.100
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 50 fps, 50 tbr, 90k tbn (default)
Metadata:
handler_name : USP Video Handler
vendor_id : [0][0][0][0]
encoder : h264
Stream #0:1(mul): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp (default)
Metadata:
handler_name : USP Sound Handler
vendor_id : [0][0][0][0]
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x555591d973d0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x555591da6eb0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)--loglevel <level>
--logfile <file>
Kde loglevel určuje úroveň protokolování definovanou v <level>, což je jeden z parametrů none, critical, error, warning, info, debug, traceall a logfile pak v parametru <file> definuje jméno souboru, do kterého se log ukládá. Je třeba vzít na vědomí, že v případě adaptivních porotkolů se do souboru <logfile> zapisují data - tzn. informce o jednotlivých chunks - postupně v průběhu přehrávání streamu. Takovýto log pak může vypadat nějak takto:
Kód:
[11:08:35.129900][cli][debug] OS: Linux-6.6.31+rpt-rpi-2712-aarch64-with-glibc2.36
[11:08:35.130107][cli][debug] Python: 3.11.2
[11:08:35.130188][cli][debug] Streamlink: 5.2.1
[11:08:35.130828][cli][debug] Dependencies:
[11:08:35.136586][cli][debug] PySocks: 1.7.1
[11:08:35.137055][cli][debug] certifi: 2022.9.24
[11:08:35.137534][cli][debug] isodate: 0.6.1
[11:08:35.137923][cli][debug] lxml: 4.9.2
[11:08:35.138526][cli][debug] pycountry: 22.3.5
[11:08:35.138876][cli][debug] pycryptodomex: 3.11.0
[11:08:35.139285][cli][debug] requests: 2.28.1
[11:08:35.140559][cli][debug] urllib3: 1.26.12
[11:08:35.141002][cli][debug] websocket-client: 1.2.3
[11:08:35.141502][cli][debug] importlib-metadata: 4.12.0
[11:08:35.141752][cli][debug] Arguments:
[11:08:35.141794][cli][debug] url=dash://https://...
[11:08:35.141829][cli][debug] stream=['best']
[11:08:35.141871][cli][debug] --loglevel=all
[11:08:35.141901][cli][debug] --logfile=/home/kodi/TVServer/playlist/o2tv/streamer.str
[11:08:35.141931][cli][debug] --locale=cs_CZ
[11:08:35.141975][cli][debug] --stdout=True
[11:08:35.142022][cli][debug] --ffmpeg-ffmpeg=ffmpeg
[11:08:35.142049][cli][debug] --ffmpeg-verbose-path=/home/kodi/TVServer/playlist/o2tv/streamer.ffm
[11:08:35.142074][cli][debug] --ffmpeg-fout=mpegts
[11:08:35.142324][cli][info] Found matching plugin dash for URL dash://https://...
[11:08:35.142412][plugins.dash][debug] URL=https://...
[11:08:35.449667][utils.l10n][debug] Language code: cs_CZ
[11:08:35.449898][stream.dash][debug] Available languages for DASH audio streams: mul, en (using: mul)
[11:08:35.450648][cli][info] Available streams: 180p (worst), 360p, 540p, 720p, 1080p (best)
[11:08:35.450735][cli][info] Opening stream: 1080p (dash)
[11:08:35.450956][stream.dash][debug] Opening DASH reader for: video=5852800 (video/mp4)
[11:08:35.451792][stream.dash][debug] Opening DASH reader for: audio_145100_mul=144000 (audio/mp4)
[11:08:35.452153][stream.dash_manifest][debug] Generating segment timeline for dynamic playlist (id=3))
[11:08:35.452514][stream.dash][debug] Reloading manifest (video=5852800:video/mp4)
[11:08:35.453683][stream.dash_manifest][debug] Generating segment timeline for dynamic playlist (id=1))
[11:08:35.454203][stream.dash][debug] Reloading manifest (audio_145100_mul=144000:audio/mp4)
[11:08:35.455089][stream.ffmpegmux][trace] Querying FFmpeg version: ['/usr/bin/ffmpeg', '-version']
[11:08:35.466611][stream.dash][debug] Download of segment: 3113-video=5852800.dash complete
[11:08:35.572330][stream.dash][debug] Download of segment: 3113-audio_145100_mul=144000.dash complete
[11:08:35.577946][stream.ffmpegmux][debug] ffmpeg version 5.1.5-0+rpt1+deb12u1 Copyright (c) 2000-2024 the FFmpeg developers
[11:08:35.578198][stream.ffmpegmux][debug] built with gcc 12 (Debian 12.2.0-14)
[11:08:35.578342][stream.ffmpegmux][debug] configuration: --prefix=/usr --extra-version=0+rpt1+deb12u1 --toolchain=hardened --incdir=/usr/include/aarch64-linux-gnu --enable-gpl --disable-stripping --disable-mmal --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sand --enable-sdl2 --disable-sndio --enable-libjxl --enable-neon --enable-v4l2-request --enable-libudev --enable-epoxy --libdir=/usr/lib/aarch64-linux-gnu --arch=arm64 --enable-pocketsphinx --enable-librsvg --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
[11:08:35.578449][stream.ffmpegmux][debug] libavutil 57. 28.100 / 57. 28.100
[11:08:35.578537][stream.ffmpegmux][debug] libavcodec 59. 37.100 / 59. 37.100
[11:08:35.578624][stream.ffmpegmux][debug] libavformat 59. 27.100 / 59. 27.100
[11:08:35.578706][stream.ffmpegmux][debug] libavdevice 59. 7.100 / 59. 7.100
[11:08:35.578787][stream.ffmpegmux][debug] libavfilter 8. 44.100 / 8. 44.100
[11:08:35.578864][stream.ffmpegmux][debug] libswscale 6. 7.100 / 6. 7.100
[11:08:35.578941][stream.ffmpegmux][debug] libswresample 4. 7.100 / 4. 7.100
[11:08:35.579020][stream.ffmpegmux][debug] libpostproc 56. 6.100 / 56. 6.100
[11:08:35.579137][utils.named_pipe][info] Creating pipe streamlinkpipe-1928849-1-2347
[11:08:35.579807][utils.named_pipe][info] Creating pipe streamlinkpipe-1928849-2-1357
[11:08:35.580035][stream.ffmpegmux][debug] ffmpeg command: /usr/bin/ffmpeg -nostats -y -i /tmp/streamlinkpipe-1928849-1-2347 -i /tmp/streamlinkpipe-1928849-2-1357 -c:v copy -c:a copy -copyts -f mpegts pipe:1
[11:08:35.580378][stream.ffmpegmux][debug] Starting copy to pipe: /tmp/streamlinkpipe-1928849-1-2347
[11:08:35.580572][stream.ffmpegmux][debug] Starting copy to pipe: /tmp/streamlinkpipe-1928849-2-1357
[11:08:35.580944][cli][debug] Pre-buffering 8192 bytes
[11:08:35.599393][stream.dash][debug] Download of segment: 3113-audio_145100_mul=144000-82692600101822.dash complete
[11:08:35.611586][stream.dash][debug] Download of segment: 3113-audio_145100_mul=144000-82692600193982.dash complete
[11:08:35.827421][stream.dash][debug] Download of segment: 3113-video=5852800-1033657501259.dash complete
[11:08:36.069747][cli][debug] Writing stream to output
[11:08:36.156213][stream.dash][debug] Download of segment: 3113-video=5852800-1033657502411.dash complete
[11:08:37.451550][stream.dash_manifest][debug] Generating segment timeline for dynamic playlist (id=3))
[11:08:37.452481][stream.dash][debug] Reloading manifest (video=5852800:video/mp4)
[11:08:37.453546][stream.dash_manifest][debug] Generating segment timeline for dynamic playlist (id=1))
[11:08:37.454314][stream.dash][debug] Reloading manifest (audio_145100_mul=144000:audio/mp4)
[11:08:39.451719][stream.dash_manifest][debug] Generating segment timeline for dynamic playlist (id=3))
[11:08:39.453102][stream.dash][debug] Reloading manifest (video=5852800:video/mp4)
[11:08:39.454175][stream.dash_manifest][debug] Generating segment timeline for dynamic playlist (id=1))
[11:08:39.459728][stream.dash][debug] Reloading manifest (audio_145100_mul=144000:audio/mp4)
[11:08:39.513866][stream.dash][debug] Download of segment: 3113-audio_145100_mul=144000-82692600286142.dash complete
[11:08:39.532900][stream.dash][debug] Download of segment: 3113-audio_145100_mul=144000-82692600378302.dash complete
[11:08:39.803711][stream.dash][debug] Download of segment: 3113-video=5852800-1033657503563.dash complete
[11:08:40.240029][stream.dash][debug] Download of segment: 3113-video=5852800-1033657504715.dash complete
[11:08:41.451884][stream.dash_manifest][debug] Generating segment timeline for dynamic playlist (id=3))
[11:08:41.453285][stream.dash][debug] Reloading manifest (video=5852800:video/mp4)
[11:08:41.455577][stream.dash_manifest][debug] Generating segment timeline for dynamic playlist (id=1))
[11:08:41.457137][stream.dash][debug] Reloading manifest (audio_145100_mul=144000:audio/mp4)
[11:08:41.482584][stream.dash][debug] Download of segment: 3113-audio_145100_mul=144000-82692600470462.dash complete
[11:08:41.789007][stream.dash][debug] Download of segment: 3113-video=5852800-1033657505867.dash complete
[11:08:43.452037][stream.dash_manifest][debug] Generating segment timeline for dynamic playlist (id=3))
...Já mám obvykle se scriptu streamer.sh, připraveny dvě verze volání streamlink, z nichž jedna obsahuje pouze základní porotokolování, zatímco druhá to úplné. Umožní mi to mít základní přehled o chování stremů kdykoliv (i zpětně) - to když použiju tu první verzi - a v případě, že dojde k nějakému problému, tak si uvolním tu verzi druhou, kde vidím úplně všechno. Tady je třeba si uvědomit, že verze s úplným protokolováním o něco prodlouží čas volby/přepnutí kanálů, ale také to, že může na disk/kartu zapisovat soustavně nějaká data, což může být u některých konfigurací nežádoucí.
