Closed mxnt10 closed 3 months ago
Hi, thanks for the contribution!
Did you set define for DEFINES+="QT_AVPLAYER_MULTIMEDIA"
? do you use qmake?
Estou usando cmake 3.27.1
EDIT: O erro foi meu, esqueci de definir as definições do cmake. O código funcionou.
FindQtAVPlayer.cmake no subdiretório cmake
# Find QtAVPlayer
set(PWD ${CMAKE_SOURCE_DIR}/utils/QtAVPlayer)
message(STATUS "QtAVPlayer dir: " ${PWD})
option(QT_AVPLAYER_MULTIMEDIA "Enable AVPlayer multimedia support" ON)
option(QT_AVPLAYER_VA_X11 "Enable VA X11 support" ON)
option(QT_AVPLAYER_VA_DRM "Enable VA DRM support" ON)
option(QT_AVPLAYER_VDPAU "Enable VDPAU support" ON)
set(QT_AVPLAYER_LIBS
avcodec
avformat
swscale
avutil
swresample
avfilter
avdevice
)
set(QT_AVPLAYER_PRIVATE_HEADERS
${PWD}/qavcodec_p.h
${PWD}/qavcodec_p_p.h
${PWD}/qavframecodec_p.h
${PWD}/qavaudiocodec_p.h
${PWD}/qavvideocodec_p.h
${PWD}/qavsubtitlecodec_p.h
${PWD}/qavhwdevice_p.h
${PWD}/qavdemuxer_p.h
${PWD}/qavpacket_p.h
${PWD}/qavstreamframe_p.h
${PWD}/qavframe_p.h
${PWD}/qavpacketqueue_p.h
${PWD}/qavvideobuffer_p.h
${PWD}/qavvideobuffer_cpu_p.h
${PWD}/qavvideobuffer_gpu_p.h
${PWD}/qavfilter_p.h
${PWD}/qavfilter_p_p.h
${PWD}/qavvideofilter_p.h
${PWD}/qavaudiofilter_p.h
${PWD}/qavfiltergraph_p.h
${PWD}/qavinoutfilter_p.h
${PWD}/qavinoutfilter_p_p.h
${PWD}/qavvideoinputfilter_p.h
${PWD}/qavaudioinputfilter_p.h
${PWD}/qavvideooutputfilter_p.h
${PWD}/qavaudiooutputfilter_p.h
${PWD}/qavfilters_p.h
)
set(QT_AVPLAYER_PUBLIC_HEADERS
${PWD}/qaviodevice.h
${PWD}/qavaudioformat.h
${PWD}/qavstreamframe.h
${PWD}/qavframe.h
${PWD}/qavvideoframe.h
${PWD}/qavaudioframe.h
${PWD}/qavsubtitleframe.h
${PWD}/qtavplayerglobal.h
${PWD}/qavstream.h
${PWD}/qavplayer.h
)
set(QT_AVPLAYER_SOURCES
${PWD}/qavplayer.cpp
${PWD}/qavcodec.cpp
${PWD}/qavframecodec.cpp
${PWD}/qavaudiocodec.cpp
${PWD}/qavvideocodec.cpp
${PWD}/qavsubtitlecodec.cpp
${PWD}/qavdemuxer.cpp
${PWD}/qavpacket.cpp
${PWD}/qavframe.cpp
${PWD}/qavstreamframe.cpp
${PWD}/qavvideoframe.cpp
${PWD}/qavaudioframe.cpp
${PWD}/qavsubtitleframe.cpp
${PWD}/qavvideobuffer_cpu.cpp
${PWD}/qavvideobuffer_gpu.cpp
${PWD}/qavfilter.cpp
${PWD}/qavvideofilter.cpp
${PWD}/qavaudiofilter.cpp
${PWD}/qavfiltergraph.cpp
${PWD}/qavinoutfilter.cpp
${PWD}/qavvideoinputfilter.cpp
${PWD}/qavaudioinputfilter.cpp
${PWD}/qavvideooutputfilter.cpp
${PWD}/qavaudiooutputfilter.cpp
${PWD}/qaviodevice.cpp
${PWD}/qavstream.cpp
${PWD}/qavfilters.cpp
)
if(QT_AVPLAYER_MULTIMEDIA)
message(STATUS "QT_AVPLAYER_MULTIMEDIA is defined")
add_definitions(-DQT_AVPLAYER_MULTIMEDIA)
set(QT_AVPLAYER_PUBLIC_HEADERS
${QT_AVPLAYER_PUBLIC_HEADERS}
${PWD}/qavaudiooutput.h
${PWD}/qavaudiooutputdevice.h
)
set(QT_AVPLAYER_SOURCES
${QT_AVPLAYER_SOURCES}
${PWD}/qavaudiooutput.cpp
${PWD}/qavaudiooutputdevice.cpp
)
endif()
if(QT_AVPLAYER_VA_X11)
message(STATUS "QT_AVPLAYER_VA_X11 is defined")
add_definitions(-DQT_AVPLAYER_VA_X11)
set(QT_AVPLAYER_LIBS
${QT_AVPLAYER_LIBS}
OpenGL::GL
X11
va-x11
va
)
set(QT_AVPLAYER_PRIVATE_HEADERS
${QT_AVPLAYER_PRIVATE_HEADERS}
${PWD}/qavhwdevice_vaapi_x11_glx_p.h
)
set(QT_AVPLAYER_SOURCES
${QT_AVPLAYER_SOURCES}
${PWD}/qavhwdevice_vaapi_x11_glx.cpp
)
endif()
if(QT_AVPLAYER_VA_DRM)
message(STATUS "QT_AVPLAYER_VA_DRM is defined")
add_definitions(-DQT_AVPLAYER_VA_DRM)
set(QT_AVPLAYER_LIBS
${QT_AVPLAYER_LIBS}
OpenGL::GL
EGL
va-drm
va
)
set(QT_AVPLAYER_PRIVATE_HEADERS
${QT_AVPLAYER_PRIVATE_HEADERS}
${PWD}/qavhwdevice_vaapi_drm_egl_p.h
)
set(QT_AVPLAYER_SOURCES
${QT_AVPLAYER_SOURCES}
${PWD}/qavhwdevice_vaapi_drm_egl.cpp
)
endif()
if(QT_AVPLAYER_VDPAU)
message(STATUS "QT_AVPLAYER_VDPAU is defined")
add_definitions(-DQT_AVPLAYER_VDPAU)
set(QT_AVPLAYER_PRIVATE_HEADERS
${QT_AVPLAYER_PRIVATE_HEADERS}
${PWD}/qavhwdevice_vdpau_p.h
)
set(QT_AVPLAYER_SOURCES
${QT_AVPLAYER_SOURCES}
${PWD}/qavhwdevice_vdpau.cpp
)
endif()
Adições no CMakeLists.txt
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
find_package(Qt6 COMPONENTS # exemplo qt6
Concurrent
Multimedia
MultimediaWidgets
REQUIRED
)
include_directories(
utils # pode ser necessário
utils/QtAVPlayer # local do qtavplayer no teu projeto
${Qt${QT_VERSION_MAJOR}Multimedia_PRIVATE_INCLUDE_DIRS}
)
include(FindQtAVPlayer) # da pasta do cmake
add_executable(${PRG_NAME}
${SRC_FILES} # coisas do teu projeto como exemplo
${QT_AVPLAYER_PRIVATE_HEADERS}
${QT_AVPLAYER_PUBLIC_HEADERS}
${QT_AVPLAYER_SOURCES}
)
target_link_libraries(${PRG_NAME}
Qt::Concurrent
Qt::Multimedia
Qt::MultimediaWidgets
${QT_AVPLAYER_LIBS}
)
o cmake acima é 100%. Inclui na wiki.
o "player" nesse exemplo é dinamico e "video" é um qgraphicsvideoitem dinâmico também. Versão do qt 6.5.2
Esse código retorna o seguinte erro:
Se eu tento corrigir dá falha de segmentação. Eu tento:
QVideoFrame videoFrame = (const QVideoFrame &) frame;
E então, um simples qDebug no videoFrame já retorna isso:
Process finished with exit code 139 (interrupted by signal 11:SIGSEGV)
EDIT: Resolvi. só vou postar o cmake aqui pra ninguém passar por isso também.