1 | initial version |
hello yes it seems so expect recompile with -disable-logging there is a python solution to silent it but i need to wait 2 day to post an answer in my question so i will post it tomorrow if it can interrested someone
2 | No.2 Revision |
hello yes it seems so expect recompile with -disable-logging
there -disable-logging
There is a python solution to silent it but i need it: the idea is to wait 2 day to post an answer redirect the sterr (where ffmpeg library push the log) "elsewhere" only when this function is executed:
I use the way explain by this very good blog article
`import ctypes
import io
import os
import sys
import tempfile
from contextlib import contextmanager
import cv2
libc = ctypes.CDLL(None)
c_stderr = ctypes.c_void_p.in_dll(libc, 'stderr')
def screenshot(url):
vidcap = cv2.VideoCapture(url)
# do stuff in my question so i will post it tomorrow if it vidcap
vidcap.release()
@contextmanager
def stderr_redirector(stream):
original_stderr_fd = sys.stderr.fileno()
def _redirect_stderr(to_fd):
libc.fflush(c_stderr)
sys.stderr.close()
os.dup2(to_fd, original_stderr_fd)
sys.stderr = io.TextIOWrapper(os.fdopen(original_stderr_fd, 'wb'))
saved_stderr_fd = os.dup(original_stderr_fd)
try:
tfile = tempfile.TemporaryFile(mode='w+b')
_redirect_stderr(tfile.fileno())
yield
_redirect_stderr(saved_stderr_fd)
tfile.flush()
tfile.seek(0, io.SEEK_SET)
stream.write(tfile.read().decode())
finally:
tfile.close()
os.close(saved_stderr_fd)
url = "udp://224.X.X.X:1234"
f = io.StringIO()
with stderr_redirector(f):
screenshot(url)
# you can interrested someone get the ffmpeg log with f.getvalue() for analyze or just close it
f.close()`
3 | No.3 Revision |
hello yes it seems so expect recompile with -disable-logging
There is a python solution to silent it: the idea is to redirect the sterr (where ffmpeg library push the log) "elsewhere" only when this function is executed:
I use the way explain by this very good blog article
`import ctypes
import io
import os
import sys
import tempfile
from contextlib import contextmanager
import cv2
libc = ctypes.CDLL(None)
c_stderr = ctypes.c_void_p.in_dll(libc, 'stderr')
def screenshot(url):
vidcap = cv2.VideoCapture(url)
# do stuff in vidcap
vidcap.release()
@contextmanager
def stderr_redirector(stream):
original_stderr_fd = sys.stderr.fileno()
def _redirect_stderr(to_fd):
libc.fflush(c_stderr)
sys.stderr.close()
os.dup2(to_fd, original_stderr_fd)
sys.stderr = io.TextIOWrapper(os.fdopen(original_stderr_fd, 'wb'))
saved_stderr_fd = os.dup(original_stderr_fd)
try:
tfile = tempfile.TemporaryFile(mode='w+b')
_redirect_stderr(tfile.fileno())
yield
_redirect_stderr(saved_stderr_fd)
tfile.flush()
tfile.seek(0, io.SEEK_SET)
stream.write(tfile.read().decode())
finally:
tfile.close()
os.close(saved_stderr_fd)
url = "udp://224.X.X.X:1234"
f = io.StringIO()
with stderr_redirector(f):
screenshot(url)
# you can get the ffmpeg log with f.getvalue() for analyze or just close it
f.close()`
4 | No.4 Revision |
hello yes it seems so expect that the only way is recompile ffmpeg with -disable-logging
There is a python solution to silent it: the idea is to redirect the sterr (where ffmpeg library push the log) "elsewhere" only when this function is executed:
I use the way explain by this very good blog article
`import ctypes
import io
import os
import sys
import tempfile
from contextlib import contextmanager
import cv2
libc = ctypes.CDLL(None)
c_stderr = ctypes.c_void_p.in_dll(libc, 'stderr')
def screenshot(url):
vidcap = cv2.VideoCapture(url)
# do stuff in vidcap
vidcap.release()
@contextmanager
def stderr_redirector(stream):
original_stderr_fd = sys.stderr.fileno()
def _redirect_stderr(to_fd):
libc.fflush(c_stderr)
sys.stderr.close()
os.dup2(to_fd, original_stderr_fd)
sys.stderr = io.TextIOWrapper(os.fdopen(original_stderr_fd, 'wb'))
saved_stderr_fd = os.dup(original_stderr_fd)
try:
tfile = tempfile.TemporaryFile(mode='w+b')
_redirect_stderr(tfile.fileno())
yield
_redirect_stderr(saved_stderr_fd)
tfile.flush()
tfile.seek(0, io.SEEK_SET)
stream.write(tfile.read().decode())
finally:
tfile.close()
os.close(saved_stderr_fd)
url = "udp://224.X.X.X:1234"
f = io.StringIO()
with stderr_redirector(f):
screenshot(url)
# you can get the ffmpeg log with f.getvalue() for analyze or just close it
f.close()`