
Recherche avancée
Médias (91)
-
Chuck D with Fine Arts Militia - No Meaning No
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Paul Westerberg - Looking Up in Heaven
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Le Tigre - Fake French
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Thievery Corporation - DC 3000
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Dan the Automator - Relaxation Spa Treatment
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Gilberto Gil - Oslodum
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (52)
-
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...) -
MediaSPIP version 0.1 Beta
16 avril 2011, parMediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)
Sur d’autres sites (7602)
-
Show error when build win32 version Ffmpeg in windows10,How solve it ? [duplicate]
25 septembre 2020, par lslboyI build a win32 version FFmpeg for get the .dll and .lib file in windows10 follow the https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT document, I executed the command


../../../configure \
--toolchain=msvc \
--disable-programs \
--disable-d3d11va \
--disable-dxva2 \
--arch=x86 \
--enable-shared \
--enable-cross-compile \
--target-os=win32 \
--extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WIN32_WINNT=0x0A00" \
--extra-ldflags="-APPCONTAINER WindowsApp.lib" \
--prefix=../../../Build/Windows10/x86



everything works well, after that, I execute the command :


make



it shows error :


\Users\LEE\Downloads\ffmpeg-snapshot\ffmpeg\Output\Windows10\x86\config.h: warning C4828: The file contains a character starting at offset 0x2da, which is invalid in the current source character set (code page 65001) .
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(59): error C2143: syntax error: missing ")" (before "*")
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(59): error C2143: syntax error: missing "{" (before "*")
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(60): warning C4228: Non-standard extension used: Ignore the qualifier after the comma in the declarator list
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(60): error C2143: syntax error: missing ";" (before "*")
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(61): error C2371: “IMFActivate”: redefinition; different base types
C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um\mfobjects.h(184): note: see the statement of "IMFActivate"
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(61): error C2143: syntax error: missing ";" (before "*")
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(61): warning C4142: "UINT32": benign redefinition of types
C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared\basetsd.h(81): note: see the statement of "UINT32"
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(61): error C2370: “UINT32”: redefinition; different storage class
C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared\basetsd.h(81): note: see the statement of "UINT32"
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(61): error C2059: syntax error: ")"
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(166): error C2143: syntax error: missing ")" (before "*")
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(166): error C2081: "MFT_REGISTER_TYPE_INFO": The name in the formal parameter table is illegal
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(166): error C2143: syntax error: missing "{" (before "*")
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(167): error C2143: syntax error: missing ";" (before "*")
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(168): error C2059: syntax error: "type"
c:\users\lee\downloads\ffmpeg-snapshot\ffmpeg\libavcodec\mf_utils.h(168): error C2059: syntax error: ")"
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(54): error C2143: syntax error: missing ")" (before "*")
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(54): error C2143: syntax error: missing "{" (before "*")
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(55): warning C4228: Non-standard extension used: Ignore the qualifier after the comma in the declarator list
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(55): error C2143: syntax error: missing ";" (before "*")
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(56): error C2371: “IMFActivate”: redefinition; different base types
C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um\mfobjects.h(184): note: see the statement of "IMFActivate"
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(56): error C2143: syntax error: missing ";" (before "*")
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(56): warning C4142: "UINT32": benign redefinition of types
C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared\basetsd.h(81): note: see the statement of "UINT32"
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(56): error C2370: “UINT32”: redefinition; different storage class
C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared\basetsd.h(81): note: see the statement of "UINT32"
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(56): error C2059: syntax error: ")"
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(57): error C2054: "(" should be entered after "pnumMFTActivate"
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(584): error C2143: syntax error: missing ")" (before "*")
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(584): error C2081: "MFT_REGISTER_TYPE_INFO": The name in the formal parameter table is illegal
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(584): error C2143: syntax error: missing "{" (before "*")
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(585): error C2143: syntax error: missing ";" (before "*")
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(586): error C2059: syntax error: "type"
C:/Users/LEE/Downloads/ffmpeg-snapshot/ffmpegbavcodec/mf_utils.c(587): error C2059: syntax error: ")"
make: *** [/c/Users/LEE/Downloads/ffmpeg-snapshot/ffmpeg/ffbuild/common.mak:67: libavcodec/mf_utils.o] Error 2



I don't know why, could you help me,thanks !


-
Why does ffmpeg show a corrupted video when receiving stream in MPEG TS format ?
20 décembre 2019, par CarloI’m trying to stream a CCTV footage using RTP/MPEGTS. I can properly view it in vlc using the following command(I’m using windows 10) :
vlc --demux ts rtp://239.194.115.71:5000
The problem arises when I tried to receive and play it in ffmpeg using the following command :
ffplay -f mpegts rtp://239.194.115.71:5000
I’m getting a semi decent video for the first 5 seconds :
After 5 seconds the video gets droopy and corrupted
(note that the top part of the video seems to be unaffected)Compete logs can be found here : https://pastebin.com/7CvbFsQK
This is some of the logs from ffmpeg :
[udp @ 00000296e31a4480] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 00000296e319f400] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[mpegts @ 00000296e31a4880] Unable to seek back to the start
[mpegts @ 00000296e31a4880] Unable to seek back to the startf=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[h264 @ 00000296e31c9e80] SPS unavailable in decode_picture_timing
[h264 @ 00000296e31c9e80] non-existing PPS 0 referenced
[h264 @ 00000296e31c9e80] SPS unavailable in decode_picture_timing
[h264 @ 00000296e31c9e80] non-existing PPS 0 referenced
[h264 @ 00000296e31c9e80] decode_slice_header error
[h264 @ 00000296e31c9e80] no frame!
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[h264 @ 00000296e31c9e80] SPS unavailable in decode_picture_timing
[h264 @ 00000296e31c9e80] non-existing PPS 0 referenced
[h264 @ 00000296e31c9e80] SPS unavailable in decode_picture_timing
[h264 @ 00000296e31c9e80] non-existing PPS 0 referenced
[h264 @ 00000296e31c9e80] decode_slice_header error
[h264 @ 00000296e31c9e80] no frame!
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[h264 @ 00000296e31c9e80] SPS unavailable in decode_picture_timing
[h264 @ 00000296e31c9e80] non-existing PPS 0 referenced
[h264 @ 00000296e31c9e80] SPS unavailable in decode_picture_timing
[h264 @ 00000296e31c9e80] non-existing PPS 0 referenced
[h264 @ 00000296e31c9e80] decode_slice_header error
[h264 @ 00000296e31c9e80] no frame!
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[h264 @ 00000296e31c9e80] SPS unavailable in decode_picture_timing
[h264 @ 00000296e31c9e80] non-existing PPS 0 referenced
[h264 @ 00000296e31c9e80] SPS unavailable in decode_picture_timing
[h264 @ 00000296e31c9e80] non-existing PPS 0 referenced
[h264 @ 00000296e31c9e80] decode_slice_header error
[h264 @ 00000296e31c9e80] no frame!
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[h264 @ 00000296e31c9e80] left block unavailable for requested intra4x4 mode -1
[h264 @ 00000296e31c9e80] error while decoding MB 0 6, bytestream 150225
[h264 @ 00000296e31c9e80] concealing 7489 DC, 7489 AC, 7489 MV errors in I frame
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[h264 @ 00000296e31c9e80] concealing 7487 DC, 7487 AC, 7487 MV errors in P frame
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[h264 @ 00000296e31c9e80] cabac decode of qscale diff failed at 64 24
[h264 @ 00000296e31c9e80] error while decoding MB 64 24, bytestream 15698
[h264 @ 00000296e31c9e80] concealing 5265 DC, 5265 AC, 5265 MV errors in P frame
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192 0B f=0/0
[mpegts @ 00000296e31a4880] changing packet size to 204
[mpegts @ 00000296e31a4880] changing packet size to 192
[mpegts @ 00000296e31a4880] changing packet size to 204
Input #0, mpegts, from 'rtp://239.194.115.71:5000':q= 0B f=0/0
Duration: N/A, start: 67510.427322, bitrate: N/A
Program 1
Stream #0:0[0x1011]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
[h264 @ 00000296e8195180] left block unavailable for requested intra4x4 mode -1
[h264 @ 00000296e8195180] error while decoding MB 0 6, bytestream 150225
[h264 @ 00000296e8195180] concealing 7489 DC, 7489 AC, 7489 MV errors in I frame
[h264 @ 00000296e3235200] concealing 7487 DC, 7487 AC, 7487 MV errors in P frame
[h264 @ 00000296e3235200] cabac decode of qscale diff failed at 64 24
[h264 @ 00000296e3235200] error while decoding MB 64 24, bytestream 15698
[h264 @ 00000296e3235200] concealing 5265 DC, 5265 AC, 5265 MV errors in P frame
[h264 @ 00000296e819b400] concealing 7425 DC, 7425 AC, 7425 MV errors in P frame
[h264 @ 00000296e8195180] cabac decode of qscale diff failed at 27 49
[h264 @ 00000296e8195180] error while decoding MB 27 49, bytestream 5976
[h264 @ 00000296e8195180] concealing 2302 DC, 2302 AC, 2302 MV errors in P frame
[h264 @ 00000296e8195180] concealing 4980 DC, 4980 AC, 4980 MV errors in I frame
[h264 @ 00000296e819b400] concealing 1322 DC, 1322 AC, 1322 MV errors in P frame
[h264 @ 00000296e3235200] concealing 619 DC, 619 AC, 619 MV errors in P frame
[h264 @ 00000296e82ce6c0] concealing 6875 DC, 6875 AC, 6875 MV errors in P frame
[h264 @ 00000296e819b400] concealing 6462 DC, 6462 AC, 6462 MV errors in P frame
[h264 @ 00000296e819bb80] concealing 4570 DC, 4570 AC, 4570 MV errors in P frame
[h264 @ 00000296e8195180] concealing 4196 DC, 4196 AC, 4196 MV errors in P frame
[h264 @ 00000296e819bb80] cabac decode of qscale diff failed at 1 15
[h264 @ 00000296e819bb80] error while decoding MB 1 15, bytestream 20111
[h264 @ 00000296e819bb80] concealing 6408 DC, 6408 AC, 6408 MV errors in P frame
[h264 @ 00000296e8195180] left block unavailable for requested intra mode
[h264 @ 00000296e8195180] error while decoding MB 0 46, bytestream 59771
[h264 @ 00000296e8195180] concealing 2689 DC, 2689 AC, 2689 MV errors in I frame
[h264 @ 00000296e819bb80] concealing 3478 DC, 3478 AC, 3478 MV errors in P frame
[h264 @ 00000296e819bb80] concealing 6970 DC, 6970 AC, 6970 MV errors in P frame
[h264 @ 00000296e8195180] concealing 6875 DC, 6875 AC, 6875 MV errors in P frame
[h264 @ 00000296e8195180] left block unavailable for requested intra4x4 mode -1
[h264 @ 00000296e8195180] error while decoding MB 0 31, bytestream 92665
[h264 @ 00000296e8195180] concealing 4489 DC, 4489 AC, 4489 MV errors in I frame
[h264 @ 00000296e3235200] concealing 2421 DC, 2421 AC, 2421 MV errors in P frame
[h264 @ 00000296e819b400] concealing 7268 DC, 7268 AC, 7268 MV errors in P frame
[h264 @ 00000296e3235200] concealing 6889 DC, 6889 AC, 6889 MV errors in P frame
[h264 @ 00000296e82ce6c0] concealing 4213 DC, 4213 AC, 4213 MV errors in P frame
[h264 @ 00000296e819bb80] concealing 6255 DC, 6255 AC, 6255 MV errors in P frame
[h264 @ 00000296e8195180] left block unavailable for requested intra4x4 mode -1
[h264 @ 00000296e8195180] error while decoding MB 0 2, bytestream 169691
[h264 @ 00000296e8195180] concealing 7969 DC, 7969 AC, 7969 MV errors in I frame
[h264 @ 00000296e3235200] concealing 1707 DC, 1707 AC, 1707 MV errors in P frame
[h264 @ 00000296e82ce6c0] left block unavailable for requested intra mode
[h264 @ 00000296e82ce6c0] error while decoding MB 0 20, bytestream 16584
[h264 @ 00000296e82ce6c0] concealing 5809 DC, 5809 AC, 5809 MV errors in P frame
[h264 @ 00000296e3235200] cabac decode of qscale diff failed at 17 15
[h264 @ 00000296e3235200] error while decoding MB 17 15, bytestream 18775
[h264 @ 00000296e3235200] concealing 6392 DC, 6392 AC, 6392 MV errors in P frameWireshark packet dump :
https://drive.google.com/open?id=1zppjXVgEcL8Ws-xP3e1J7NJF1UGdPzMA
What could be problem with ffmpeg playing the stream, could it be the codec used ?
-
Failed to decode h264 key frame with DXVA2.0 because returned buffer is to small
16 mai 2023, par grill2010I hava a strange problem on Windows with DXVA2 h264 decoding. I recently figured out a ffmpeg decoding limitation for DXVA2 and D3D11VA on Windows and how to solve it, this solution completly fixes the problem with D3D11VA but DXVA2 still has some problems with certain keyframes. Upon further investigation it turned out that the decoding of these certain keyframes fail because the buffer returned from the IDirectXVideoDecoder_GetBuffer function was too small. FFmpeg is printing out these logs when the decoding fails :


Error: [h264 @ 0000028b2e5796c0] Buffer for type 5 was too small. size: 58752, dxva_size: 55296
Error: [h264 @ 0000028b2e5796c0] Failed to add bitstream or slice control buffer
Error: [h264 @ 0000028b2e5796c0] hardware accelerator failed to decode picture



Why is this returned buffer too low ? What kind of factors inside ffmpeg do have an effect on this buffer size or is this a limitation of DXVA2 in general ? All other decoders like Cuvid, D3D11VA or the software decoder are not affected by this problem and can decode all keyframes.


I have an example javacv project on github that can reproduce the problem. I also provide the source code of the main class here. The keyframe example data with prepended SPS and PPS in hex form can be downloaded here.


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import org.bytedeco.ffmpeg.avcodec.AVCodec;
import org.bytedeco.ffmpeg.avcodec.AVCodecContext;
import org.bytedeco.ffmpeg.avcodec.AVCodecHWConfig;
import org.bytedeco.ffmpeg.avcodec.AVPacket;
import org.bytedeco.ffmpeg.avutil.AVBufferRef;
import org.bytedeco.ffmpeg.avutil.AVDictionary;
import org.bytedeco.ffmpeg.avutil.AVFrame;
import org.bytedeco.ffmpeg.avutil.LogCallback;
import org.bytedeco.javacpp.BytePointer;
import org.bytedeco.javacpp.IntPointer;
import org.bytedeco.javacpp.Pointer;
import org.tinylog.Logger;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.function.Consumer;

import static org.bytedeco.ffmpeg.avcodec.AVCodecContext.FF_THREAD_SLICE;
import static org.bytedeco.ffmpeg.global.avcodec.*;
import static org.bytedeco.ffmpeg.global.avutil.*;

public class App extends Application {

 /**** decoder variables ****/

 private AVHWContextInfo hardwareContext;

 private AVCodec decoder;
 private AVCodecContext m_VideoDecoderCtx;

 private AVCodecContext.Get_format_AVCodecContext_IntPointer formatCallback;

 private final int streamResolutionX = 1920;
 private final int streamResolutionY = 1080;

 // AV_HWDEVICE_TYPE_CUDA // example works with cuda
 // AV_HWDEVICE_TYPE_DXVA2 // producing Invalid data found on keyframe
 // AV_HWDEVICE_TYPE_D3D11VA // producing Invalid data found on keyframe
 private static final int HW_DEVICE_TYPE = AV_HWDEVICE_TYPE_DXVA2;

 private static final boolean USE_HW_ACCEL = true;

 private static final boolean USE_AV_EF_EXPLODE = true;

 public static void main(final String[] args) {
 //System.setProperty("prism.order", "d3d,sw");
 System.setProperty("prism.vsync", "false");
 Application.launch(App.class);
 }

 @Override
 public void start(final Stage primaryStage) {
 final Pane dummyPane = new Pane();
 dummyPane.setStyle("-fx-background-color: black");
 final Scene scene = new Scene(dummyPane, this.streamResolutionX, this.streamResolutionY);
 primaryStage.setScene(scene);
 primaryStage.show();
 primaryStage.setMinWidth(480);
 primaryStage.setMinHeight(360);

 this.initializeFFmpeg(result -> {
 if (!result) {
 Logger.error("FFmpeg could not be initialized correctly, terminating program");
 System.exit(1);
 return;
 }
 scene.setRoot(new StackPane());
 this.performTestFramesFeeding();
 });
 }

 private void initializeFFmpeg(final Consumer<boolean> finishHandler) {
 FFmpegLogCallback.setLevel(AV_LOG_DEBUG); // Increase log level until the first frame is decoded
 FFmpegLogCallback.set();
 Pointer pointer = new Pointer((Pointer) null);
 AVCodec c;
 while ((c = av_codec_iterate(pointer)) != null) {
 if (av_codec_is_decoder(c) > 0)
 Logger.debug("{}:{} ", c.name().getString(), c.type());
 }

 this.decoder = avcodec_find_decoder(AV_CODEC_ID_H264); // usually decoder name is h264 and without hardware support it's yuv420p otherwise nv12
 if (this.decoder == null) {
 Logger.error("Unable to find decoder for format {}", "h264");
 finishHandler.accept(false);
 return;
 }
 Logger.info("Current decoder name: {}, {}", this.decoder.name().getString(), this.decoder.long_name().getString());

 if (true) {
 for (; ; ) {
 this.m_VideoDecoderCtx = avcodec_alloc_context3(this.decoder);
 if (this.m_VideoDecoderCtx == null) {
 Logger.error("Unable to find decoder for format AV_CODEC_ID_H264");
 if (this.hardwareContext != null) {
 this.hardwareContext.free();
 this.hardwareContext = null;
 }
 continue;
 }

 if (App.USE_HW_ACCEL) {
 this.hardwareContext = this.createHardwareContext();
 if (this.hardwareContext != null) {
 Logger.info("Set hwaccel support");
 this.m_VideoDecoderCtx.hw_device_ctx(this.hardwareContext.hwContext()); // comment to disable hwaccel
 }
 } else {
 Logger.info("Hwaccel manually disabled");
 }

 // Always request low delay decoding
 this.m_VideoDecoderCtx.flags(this.m_VideoDecoderCtx.flags() | AV_CODEC_FLAG_LOW_DELAY);

 // Allow display of corrupt frames and frames missing references
 this.m_VideoDecoderCtx.flags(this.m_VideoDecoderCtx.flags() | AV_CODEC_FLAG_OUTPUT_CORRUPT);
 this.m_VideoDecoderCtx.flags2(this.m_VideoDecoderCtx.flags2() | AV_CODEC_FLAG2_SHOW_ALL);

 if (App.USE_AV_EF_EXPLODE) {
 // Report decoding errors to allow us to request a key frame
 this.m_VideoDecoderCtx.err_recognition(this.m_VideoDecoderCtx.err_recognition() | AV_EF_EXPLODE);
 }

 // Enable slice multi-threading for software decoding
 if (this.m_VideoDecoderCtx.hw_device_ctx() == null) { // if not hw accelerated
 this.m_VideoDecoderCtx.thread_type(this.m_VideoDecoderCtx.thread_type() | FF_THREAD_SLICE);
 this.m_VideoDecoderCtx.thread_count(2/*AppUtil.getCpuCount()*/);
 } else {
 // No threading for HW decode
 this.m_VideoDecoderCtx.thread_count(1);
 }

 this.m_VideoDecoderCtx.width(this.streamResolutionX);
 this.m_VideoDecoderCtx.height(this.streamResolutionY);
 this.m_VideoDecoderCtx.pix_fmt(this.getDefaultPixelFormat());

 this.formatCallback = new AVCodecContext.Get_format_AVCodecContext_IntPointer() {
 @Override
 public int call(final AVCodecContext context, final IntPointer pixelFormats) {
 final boolean hwDecodingSupported = context.hw_device_ctx() != null && App.this.hardwareContext != null;
 final int preferredPixelFormat = hwDecodingSupported ?
 App.this.hardwareContext.hwConfig().pix_fmt() :
 context.pix_fmt();
 int i = 0;
 while (true) {
 final int currentSupportedFormat = pixelFormats.get(i++);
 System.out.println("Supported pixel formats " + currentSupportedFormat);
 if (currentSupportedFormat == AV_PIX_FMT_NONE) {
 break;
 }
 }

 i = 0;
 while (true) {
 final int currentSupportedFormat = pixelFormats.get(i++);
 if (currentSupportedFormat == preferredPixelFormat) {
 Logger.info("[FFmpeg]: pixel format in format callback is {}", currentSupportedFormat);
 return currentSupportedFormat;
 }
 if (currentSupportedFormat == AV_PIX_FMT_NONE) {
 break;
 }
 }

 i = 0;
 while (true) { // try again and search for yuv
 final int currentSupportedFormat = pixelFormats.get(i++);
 if (currentSupportedFormat == AV_PIX_FMT_YUV420P) {
 Logger.info("[FFmpeg]: Not found in first match so use {}", AV_PIX_FMT_YUV420P);
 return currentSupportedFormat;
 }
 if (currentSupportedFormat == AV_PIX_FMT_NONE) {
 break;
 }
 }

 i = 0;
 while (true) { // try again and search for nv12
 final int currentSupportedFormat = pixelFormats.get(i++);
 if (currentSupportedFormat == AV_PIX_FMT_NV12) {
 Logger.info("[FFmpeg]: Not found in second match so use {}", AV_PIX_FMT_NV12);
 return currentSupportedFormat;
 }
 if (currentSupportedFormat == AV_PIX_FMT_NONE) {
 break;
 }
 }

 Logger.info("[FFmpeg]: pixel format in format callback is using fallback {}", AV_PIX_FMT_NONE);
 return AV_PIX_FMT_NONE;
 }
 };
 this.m_VideoDecoderCtx.get_format(this.formatCallback);

 final AVDictionary options = new AVDictionary(null);
 final int result = avcodec_open2(this.m_VideoDecoderCtx, this.decoder, options);
 if (result < 0) {
 Logger.error("avcodec_open2 was not successful");
 finishHandler.accept(false);
 return;
 }
 av_dict_free(options);
 break;
 }
 }

 if (this.decoder == null || this.m_VideoDecoderCtx == null) {
 finishHandler.accept(false);
 return;
 }
 finishHandler.accept(true);
 }

 private AVHWContextInfo createHardwareContext() {
 AVHWContextInfo result = null;
 for (int i = 0; ; i++) {
 final AVCodecHWConfig config = avcodec_get_hw_config(this.decoder, i);
 if (config == null) {
 break;
 }

 if ((config.methods() & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX) < 0) {
 continue;
 }
 final int device_type = config.device_type();
 if (device_type != App.HW_DEVICE_TYPE) {
 continue;
 }
 final AVBufferRef hw_context = av_hwdevice_ctx_alloc(device_type);
 if (hw_context == null || av_hwdevice_ctx_create(hw_context, device_type, (String) null, null, 0) < 0) {
 Logger.error("HW accel not supported for type {}", device_type);
 av_free(config);
 av_free(hw_context);
 } else {
 Logger.info("HW accel created for type {}", device_type);
 result = new AVHWContextInfo(config, hw_context);
 }
 break;
 }

 return result;
 }

 @Override
 public void stop() {
 this.releaseNativeResources();
 }

 /*****************************/
 /*** test frame processing ***/
 /*****************************/
 
 private void performTestFramesFeeding() {
 final AVPacket pkt = av_packet_alloc();
 if (pkt == null) {
 return;
 }
 try (final BytePointer bp = new BytePointer(65_535 * 15)) {


 for (int i = 0; i < 1; i++) {
 final byte[] frameData = AVTestFrames.h264KeyTestFrame;

 bp.position(0);

 bp.put(frameData);
 bp.limit(frameData.length);

 pkt.data(bp);
 pkt.capacity(bp.capacity());
 pkt.size(frameData.length);
 pkt.position(0);
 pkt.limit(frameData.length);
 //pkt.flags(AV_PKT_FLAG_KEY);
 final AVFrame avFrame = av_frame_alloc();
 System.out.println("frameData.length " + frameData.length);

 final int err = avcodec_send_packet(this.m_VideoDecoderCtx, pkt); //fill_scaling_lists
 if (err < 0) {
 final BytePointer buffer = new BytePointer(512);
 av_strerror(err, buffer, buffer.capacity());
 final String string = buffer.getString();
 System.out.println("Error on decoding test frame " + err + " message " + string);
 av_frame_free(avFrame);
 return;
 }

 final int result = avcodec_receive_frame(this.m_VideoDecoderCtx, avFrame);
 final AVFrame decodedFrame;
 if (result == 0) {
 if (this.m_VideoDecoderCtx.hw_device_ctx() == null) {
 decodedFrame = avFrame;
 System.out.println("SUCESS with SW decoding");
 } else {
 final AVFrame hwAvFrame = av_frame_alloc();
 if (av_hwframe_transfer_data(hwAvFrame, avFrame, 0) < 0) {
 System.out.println("Failed to transfer frame from hardware");
 av_frame_unref(hwAvFrame);
 decodedFrame = avFrame;
 } else {
 av_frame_unref(avFrame);
 decodedFrame = hwAvFrame;
 System.out.println("SUCESS with HW decoding");
 }
 }

 av_frame_unref(decodedFrame);
 } else {
 final BytePointer buffer = new BytePointer(512);
 av_strerror(result, buffer, buffer.capacity());
 final String string = buffer.getString();
 System.out.println("error " + result + " message " + string);
 av_frame_free(avFrame);
 }
 }
 } finally {
 if (pkt.stream_index() != -1) {
 av_packet_unref(pkt);
 }
 pkt.releaseReference();
 }
 }

 final Object releaseLock = new Object();
 private volatile boolean released = false;

 private void releaseNativeResources() {
 if (this.released) {
 return;
 }
 this.released = true;
 synchronized (this.releaseLock) {
 // Close the video codec
 if (this.m_VideoDecoderCtx != null) {
 avcodec_free_context(this.m_VideoDecoderCtx);
 this.m_VideoDecoderCtx = null;
 }

 // close the format callback
 if (this.formatCallback != null) {
 this.formatCallback.close();
 this.formatCallback = null;
 }

 // close hw context
 if (this.hardwareContext != null) {
 this.hardwareContext.free();
 }
 }
 }

 private int getDefaultPixelFormat() {
 return AV_PIX_FMT_YUV420P; // Always return yuv420p here
 }


 /*********************/
 /*** inner classes ***/
 /*********************/

 public static final class HexUtil {

 private HexUtil() {
 }

 public static byte[] unhexlify(final String argbuf) {
 final int arglen = argbuf.length();
 if (arglen % 2 != 0) {
 throw new RuntimeException("Odd-length string");
 } else {
 final byte[] retbuf = new byte[arglen / 2];

 for (int i = 0; i < arglen; i += 2) {
 final int top = Character.digit(argbuf.charAt(i), 16);
 final int bot = Character.digit(argbuf.charAt(i + 1), 16);
 if (top == -1 || bot == -1) {
 throw new RuntimeException("Non-hexadecimal digit found");
 }

 retbuf[i / 2] = (byte) ((top << 4) + bot);
 }

 return retbuf;
 }
 }
 }

 public static final class AVHWContextInfo {
 private final AVCodecHWConfig hwConfig;
 private final AVBufferRef hwContext;

 private volatile boolean freed = false;

 public AVHWContextInfo(final AVCodecHWConfig hwConfig, final AVBufferRef hwContext) {
 this.hwConfig = hwConfig;
 this.hwContext = hwContext;
 }

 public AVCodecHWConfig hwConfig() {
 return this.hwConfig;
 }

 public AVBufferRef hwContext() {
 return this.hwContext;
 }

 public void free() {
 if (this.freed) {
 return;
 }
 this.freed = true;
 av_free(this.hwConfig);
 av_free(this.hwContext);
 }


 @Override
 public boolean equals(Object o) {
 if (this == o) return true;
 if (o == null || getClass() != o.getClass()) return false;
 AVHWContextInfo that = (AVHWContextInfo) o;
 return freed == that.freed && Objects.equals(hwConfig, that.hwConfig) && Objects.equals(hwContext, that.hwContext);
 }

 @Override
 public int hashCode() {
 return Objects.hash(hwConfig, hwContext, freed);
 }

 @Override
 public String toString() {
 return "AVHWContextInfo[" +
 "hwConfig=" + this.hwConfig + ", " +
 "hwContext=" + this.hwContext + ']';
 }
 }

 public static final class AVTestFrames {

 private AVTestFrames() {

 }

 static {
 InputStream inputStream = null;
 try {
 inputStream = AVTestFrames.class.getClassLoader().getResourceAsStream("h264_test_key_frame.txt");
 final byte[] h264TestFrameBuffer = inputStream == null ? new byte[0] : inputStream.readAllBytes();
 final String h264TestFrame = new String(h264TestFrameBuffer, StandardCharsets.UTF_8);
 AVTestFrames.h264KeyTestFrame = HexUtil.unhexlify(h264TestFrame);
 } catch (final IOException e) {
 Logger.error(e, "Could not parse test frame");
 } finally {
 if (inputStream != null) {
 try {
 inputStream.close();
 } catch (final IOException e) {
 Logger.error(e, "Could not close test frame input stream");
 }
 }
 }
 }

 public static byte[] h264KeyTestFrame;
 }

 public static class FFmpegLogCallback extends LogCallback {

 private static final org.bytedeco.javacpp.tools.Logger logger = org.bytedeco.javacpp.tools.Logger.create(FFmpegLogCallback.class);

 static final FFmpegLogCallback instance = new FFmpegLogCallback().retainReference();

 public static FFmpegLogCallback getInstance() {
 return instance;
 }

 /**
 * Calls {@code avutil.setLogCallback(getInstance())}.
 */
 public static void set() {
 setLogCallback(getInstance());
 }

 /**
 * Returns {@code av_log_get_level()}.
 **/
 public static int getLevel() {
 return av_log_get_level();
 }

 /**
 * Calls {@code av_log_set_level(level)}.
 **/
 public static void setLevel(int level) {
 av_log_set_level(level);
 }

 @Override
 public void call(int level, BytePointer msg) {
 switch (level) {
 case AV_LOG_PANIC, AV_LOG_FATAL, AV_LOG_ERROR -> logger.error(msg.getString());
 case AV_LOG_WARNING -> logger.warn(msg.getString());
 case AV_LOG_INFO -> logger.info(msg.getString());
 case AV_LOG_VERBOSE, AV_LOG_DEBUG, AV_LOG_TRACE -> logger.debug(msg.getString());
 default -> {
 assert false;
 }
 }
 }
 }
}
</boolean>