Index | Thread | Search

From:
Jan Stary <hans@stare.cz>
Subject:
Re: UPDATE: FFmpeg 4.4.5
To:
Brad Smith <brad@comstyle.com>
Cc:
ports@openbsd.org
Date:
Mon, 29 Jul 2024 12:51:26 +0200

Download raw body.

Thread
On Jul 29 12:14:59, hans@stare.cz wrote:
> On Jul 29 03:57:36, brad@comstyle.com wrote:
> > Here is an update to FFmpeg 4.4.5.
> 
> Thanks. It works fine here on current/amd64.
> 
> How can I tell that it is using the new VAAPI?
> I think it does, as playing e.g. a H264 file
> makes ffplay eat about 10% on this otherwise idle machine,
> while mplayer on the same file also eats about 10% of CPU
> _and_ the Xorg process eats abut 30%,
> as opposed to near zero with ffplay.
> But how can I really tell?

vainfo says my i965 is supported:

> Trying display: x11
> Trying display: drm
> vainfo: VA-API version: 1.22 (libva 2.22.0)
> vainfo: Driver version: Intel i965 driver for Intel(R) Sandybridge Desktop - 2.4.1
> vainfo: Supported profile and entrypoints
>       VAProfileMPEG2Simple            :	VAEntrypointVLD
>       VAProfileMPEG2Main              :	VAEntrypointVLD
>       VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
>       VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
>       VAProfileH264Main               :	VAEntrypointVLD
>       VAProfileH264Main               :	VAEntrypointEncSlice
>       VAProfileH264High               :	VAEntrypointVLD
>       VAProfileH264High               :	VAEntrypointEncSlice
>       VAProfileH264StereoHigh         :	VAEntrypointVLD
>       VAProfileVC1Simple              :	VAEntrypointVLD
>       VAProfileVC1Main                :	VAEntrypointVLD
>       VAProfileVC1Advanced            :	VAEntrypointVLD
>       VAProfileNone                   :	VAEntrypointVideoProc

ffprobe says the file is H264 constrained baseline:

Input #0, matroska,webm, from '/media/Brabec/kytice.mkv':
  Metadata:
    encoder         : libebml v0.8.0 + libmatroska v0.9.0
    creation_time   : 2020-07-30T07:45:54.000000Z
  Duration: 01:23:43.21, start: 0.000000, bitrate: 3785 kb/s
  Stream #0:0: Video: h264 (Constrained Baseline), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 1k tbn, 48 tbc (default)
  Stream #0:1(cze): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)

Yet the updated mplayer, using ffmpeg 4.4.5, seems to be
using libavcodec (i.e. software decoding) when playing it:


hans@box:~$ mplayer  /media/Brabec/kytice.mkv
MPlayer SVN-r38416 (C) 2000-2023 MPlayer Team

Playing /media/Brabec/kytice.mkv.
libavformat version 58.76.100 (external)
libavformat file format detected.
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (ac3), -aid 0, -alang cze
VIDEO:	[H264]	1920x1080  0bpp	 23.999 fps    0.0 kbps ( 0.0 kbyte/s)
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 58.134.100 (external)
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
Clip info:
 encoder: libebml v0.8.0 + libmatroska v0.9.0
 creation_time: 2020-07-30T07:45:54.000000Z
Load subtitles in /media/Brabec/
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
[ac3 @ 0xe5cebcab9d0]Channel layout '5.1(side)' with 6 channels does not match specified number of channels 2: ignoring specified channel layout
AUDIO: 48000 Hz, 2 ch, floatle, 640.0 kbit/20.83% (ratio: 80000->384000)
Selected audio codec: [ffac3] afm: ffmpeg (FFmpeg AC-3)
==========================================================================
AO: [sndio] 48000Hz 2ch s32le (4 bytes per sample)
Starting playback...
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [xv] 1920x1080 => 1920x1080 Planar YV12  [fs]
[ASPECT] Warning: No suitable new res found!
[ASPECT] Warning: No suitable new res found!

Is mplayer using the new ffmpeg 4.4.5,
or does it carry its own copy that does not use the VAAPI?

	Jan


> > Index: graphics/ffmpeg/Makefile
> > ===================================================================
> > RCS file: /cvs/ports/graphics/ffmpeg/Makefile,v
> > retrieving revision 1.240
> > diff -u -p -u -p -r1.240 Makefile
> > --- graphics/ffmpeg/Makefile	28 Jul 2024 06:38:23 -0000	1.240
> > +++ graphics/ffmpeg/Makefile	29 Jul 2024 04:19:06 -0000
> > @@ -1,9 +1,8 @@
> >  COMMENT=	audio/video converter and streamer
> >  
> > -V=		4.4.4
> > +V=		4.4.5
> >  DISTNAME=	ffmpeg-${V}
> >  EPOCH=		1
> > -REVISION=	6
> >  CATEGORIES=	graphics multimedia
> >  SITES=		https://ffmpeg.org/releases/
> >  EXTRACT_SUFX=	.tar.xz
> > @@ -68,16 +67,19 @@ LIB_DEPENDS=	archivers/bzip2 \
> >  # inter-library dependencies for the current configuration
> >  LIBavcodec_EXTRALIBS=-L${LOCALBASE}/lib -L${X11BASE}/lib -laom -ldav1d -lgsm -liconv -llzma
> >  LIBavcodec_EXTRALIBS+=-lmp3lame -lopus -lspeex -ltheoradec -ltheoraenc -lvorbis
> > -LIBavcodec_EXTRALIBS+=-lvorbisenc -lvpx -lx264 -lx265 -lxvidcore -lm -lz -pthread
> > -LIBavcodec_EXTRALIBS+=-lva -lva-drm
> > +LIBavcodec_EXTRALIBS+=-lvorbisenc -lvpx -lx264 -lx265 -lxvidcore -lm -lz -lva
> > +LIBavcodec_EXTRALIBS+=-lva-drm -pthread
> >  
> >  LIBavdevice_EXTRALIBS=-L${LOCALBASE}/lib -L${X11BASE}/lib -lX11 -lXext -lXv
> >  LIBavdevice_EXTRALIBS+=-lxcb-shape -lxcb-shm -lxcb-xfixes -lxcb -lsndio -lv4l2 -lm
> >  
> >  LIBavfilter_EXTRALIBS=-L${LOCALBASE}/lib -L${X11BASE}/lib -lass -lfontconfig
> > -LIBavfilter_EXTRALIBS+=-lfreetype -lfribidi -lvidstab -lm -lz -lzimg -pthread -lva
> > +LIBavfilter_EXTRALIBS+=-lfreetype -lfribidi -lvidstab -lm -lz -lzimg -lva -pthread
> > +
> >  LIBavformat_EXTRALIBS=-L${LOCALBASE}/lib -lbz2 -lxml2 -lssl -lcrypto -lm -lz
> > +
> >  LIBavutil_EXTRALIBS=-L${X11BASE}/lib -lva -lva-drm -lva-x11 -lm -pthread
> > +
> >  LIBpostproc_EXTRALIBS=-lm
> >  LIBswresample_EXTRALIBS=-lm
> >  LIBswscale_EXTRALIBS=-lm
> > @@ -102,7 +104,6 @@ CONFIGURE_ARGS+=--enable-shared \
> >  		--disable-stripping \
> >  		--disable-indev=jack \
> >  		--disable-outdev=sdl2 \
> > -		--enable-vaapi \
> >  		--enable-fontconfig \
> >  		--enable-frei0r \
> >  		--enable-gpl \
> > Index: graphics/ffmpeg/distinfo
> > ===================================================================
> > RCS file: /cvs/ports/graphics/ffmpeg/distinfo,v
> > retrieving revision 1.66
> > diff -u -p -u -p -r1.66 distinfo
> > --- graphics/ffmpeg/distinfo	30 Apr 2023 05:25:28 -0000	1.66
> > +++ graphics/ffmpeg/distinfo	29 Jul 2024 04:19:06 -0000
> > @@ -1,2 +1,2 @@
> > -SHA256 (ffmpeg-4.4.4.tar.xz) = 6As4DVlcgJBg9m+WpdhJUR70p2omt26s9XeLlMNXAwk=
> > -SIZE (ffmpeg-4.4.4.tar.xz) = 9565584
> > +SHA256 (ffmpeg-4.4.5.tar.xz) = +VFODTUVruWicSg99xY24dH/cnSxWFO82E4US+QWqwc=
> > +SIZE (ffmpeg-4.4.5.tar.xz) = 9575596
> > Index: graphics/ffmpeg/patches/patch-configure
> > ===================================================================
> > RCS file: /cvs/ports/graphics/ffmpeg/patches/patch-configure,v
> > retrieving revision 1.72
> > diff -u -p -u -p -r1.72 patch-configure
> > --- graphics/ffmpeg/patches/patch-configure	4 Dec 2022 20:12:36 -0000	1.72
> > +++ graphics/ffmpeg/patches/patch-configure	29 Jul 2024 04:19:06 -0000
> > @@ -1,4 +1,3 @@
> > -- configure: use pkg-config for sndio
> >  - configure: add initial RISC-V support
> >  - Fix broken libatomic test
> >  
> > @@ -43,7 +42,7 @@ Index: configure
> >       s390)
> >           check_64bit s390 s390x
> >           enabled shared && enable_weak pic
> > -@@ -5378,7 +5386,6 @@ case $target_os in
> > +@@ -5379,7 +5387,6 @@ case $target_os in
> >           enable section_data_rel_ro
> >           striptype=""
> >           SHFLAGS='-shared'
> > @@ -51,7 +50,7 @@ Index: configure
> >           SLIB_INSTALL_LINKS=
> >           oss_indev_extralibs="-lossaudio"
> >           oss_outdev_extralibs="-lossaudio"
> > -@@ -5734,7 +5741,7 @@ set_default libdir
> > +@@ -5736,7 +5743,7 @@ set_default libdir
> >   set_default $PATHS_LIST
> >   set_default nm
> >   
> > @@ -60,7 +59,7 @@ Index: configure
> >   
> >   enable_weak_pic() {
> >       disabled pic && return
> > -@@ -6189,7 +6196,7 @@ check_headers asm/types.h
> > +@@ -6191,7 +6198,7 @@ check_headers asm/types.h
> >   #
> >   # some configurations also require linking to libatomic, so try
> >   # both with -latomic and without
> > @@ -69,13 +68,3 @@ Index: configure
> >       check_builtin stdatomic stdatomic.h                                                 \
> >           "atomic_int foo, bar = ATOMIC_VAR_INIT(-1); atomic_store(&foo, 0); foo += bar"  \
> >           $LATOMIC && eval stdatomic_extralibs="\$LATOMIC" && break
> > -@@ -6657,7 +6664,8 @@ enabled alsa && { check_pkg_config alsa alsa "alsa/aso
> > - enabled libjack &&
> > -     require_pkg_config libjack jack jack/jack.h jack_port_get_latency_range
> > - 
> > --enabled sndio && check_lib sndio sndio.h sio_open -lsndio
> > -+enabled sndio && { check_pkg_config sndio sndio "sndio.h" sio_open ||
> > -+                   check_lib sndio sndio.h sio_open -lsndio; }
> > - 
> > - if enabled libcdio; then
> > -     check_pkg_config libcdio libcdio_paranoia "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open ||
> > Index: graphics/ffmpeg/patches/patch-libavcodec_libsvtav1_c
> > ===================================================================
> > RCS file: /cvs/ports/graphics/ffmpeg/patches/patch-libavcodec_libsvtav1_c,v
> > retrieving revision 1.3
> > diff -u -p -u -p -r1.3 patch-libavcodec_libsvtav1_c
> > --- graphics/ffmpeg/patches/patch-libavcodec_libsvtav1_c	5 Dec 2022 10:03:55 -0000	1.3
> > +++ graphics/ffmpeg/patches/patch-libavcodec_libsvtav1_c	29 Jul 2024 04:19:06 -0000
> > @@ -13,7 +13,6 @@
> >  - avcodec/libsvtav1: update avctx bit rate according to RC mode
> >  - avcodec/libsvtav1: signal CPB properties through side data
> >  - avcodec/libsvtav1: properly initialize the flush EbBufferHeaderType struct
> > -- avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
> >  - avcodec/libsvtav1: replace vbv_bufsize with maximum_buffer_size_ms
> >  - avcodec/libsvtav1: only set max_buf_sz if both bitrate and rc_buf_sz is set
> >  - avcodec/libsvtav1: don't force a default value for deprecated options
> > @@ -45,27 +44,7 @@ Index: libavcodec/libsvtav1.c
> >   } SvtContext;
> >   
> >   static const struct {
> > -@@ -120,16 +123,12 @@ static int svt_print_error(void *log_ctx, EbErrorType 
> > - 
> > - static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
> > - {
> > --    const int    pack_mode_10bit =
> > --        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
> > --    const size_t luma_size_8bit  =
> > --        config->source_width * config->source_height * (1 << pack_mode_10bit);
> > --    const size_t luma_size_10bit =
> > --        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
> > -+    const size_t luma_size = config->source_width * config->source_height *
> > -+        (config->encoder_bit_depth > 8 ? 2 : 1);
> > - 
> > -     EbSvtIOFormat *in_data;
> > - 
> > --    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
> > -+    svt_enc->raw_size = luma_size * 3 / 2;
> > - 
> > -     // allocate buffer for in and out
> > -     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
> > -@@ -151,11 +150,132 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
> > +@@ -147,11 +150,132 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
> >   {
> >       SvtContext *svt_enc = avctx->priv_data;
> >       const AVPixFmtDescriptor *desc;
> > @@ -199,7 +178,7 @@ Index: libavcodec/libsvtav1.c
> >       param->encoder_bit_depth = desc->comp[0].depth;
> >   
> >       if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 1)
> > -@@ -169,12 +289,6 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
> > +@@ -165,12 +289,6 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
> >           return AVERROR(EINVAL);
> >       }
> >   
> > @@ -212,7 +191,7 @@ Index: libavcodec/libsvtav1.c
> >       if ((param->encoder_color_format == EB_YUV422 || param->encoder_bit_depth > 10)
> >            && param->profile != FF_PROFILE_AV1_PROFESSIONAL ) {
> >           av_log(avctx, AV_LOG_WARNING, "Forcing Professional profile\n");
> > -@@ -184,40 +298,21 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
> > +@@ -180,40 +298,21 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
> >           param->profile = FF_PROFILE_AV1_HIGH;
> >       }
> >   
> > @@ -264,7 +243,7 @@ Index: libavcodec/libsvtav1.c
> >       return 0;
> >   }
> >   
> > -@@ -330,11 +425,8 @@ static int eb_send_frame(AVCodecContext *avctx, const 
> > +@@ -326,11 +425,8 @@ static int eb_send_frame(AVCodecContext *avctx, const 
> >           if (svt_enc->eos_flag == EOS_SENT)
> >               return 0;
> >   
> > @@ -278,7 +257,7 @@ Index: libavcodec/libsvtav1.c
> >           headerPtrLast.flags         = EB_BUFFERFLAG_EOS;
> >   
> >           svt_av1_enc_send_picture(svt_enc->svt_handle, &headerPtrLast);
> > -@@ -350,6 +442,16 @@ static int eb_send_frame(AVCodecContext *avctx, const 
> > +@@ -346,6 +442,16 @@ static int eb_send_frame(AVCodecContext *avctx, const 
> >       headerPtr->p_app_private = NULL;
> >       headerPtr->pts           = frame->pts;
> >   
> > @@ -295,7 +274,7 @@ Index: libavcodec/libsvtav1.c
> >       svt_av1_enc_send_picture(svt_enc->svt_handle, headerPtr);
> >   
> >       return 0;
> > -@@ -472,21 +574,22 @@ static av_cold int eb_enc_close(AVCodecContext *avctx)
> > +@@ -468,21 +574,22 @@ static av_cold int eb_enc_close(AVCodecContext *avctx)
> >   #define OFFSET(x) offsetof(SvtContext, x)
> >   #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
> >   static const AVOption options[] = {
> > @@ -327,7 +306,7 @@ Index: libavcodec/libsvtav1.c
> >   
> >       FF_AV1_PROFILE_OPTS
> >   
> > -@@ -518,21 +621,20 @@ static const AVOption options[] = {
> > +@@ -514,21 +621,20 @@ static const AVOption options[] = {
> >           { LEVEL("7.3", 73) },
> >   #undef LEVEL
> >   
> > @@ -360,7 +339,7 @@ Index: libavcodec/libsvtav1.c
> >       {NULL},
> >   };
> >   
> > -@@ -544,9 +646,10 @@ static const AVClass class = {
> > +@@ -540,9 +646,10 @@ static const AVClass class = {
> >   };
> >   
> >   static const AVCodecDefault eb_enc_defaults[] = {
> > @@ -373,7 +352,7 @@ Index: libavcodec/libsvtav1.c
> >       { "qmax",      "63"    },
> >       { NULL },
> >   };
> > -@@ -561,12 +664,11 @@ AVCodec ff_libsvtav1_encoder = {
> > +@@ -557,12 +664,11 @@ AVCodec ff_libsvtav1_encoder = {
> >       .receive_packet = eb_receive_packet,
> >       .close          = eb_enc_close,
> >       .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS,
> > Index: graphics/ffmpeg/patches/patch-libavdevice_v4l2_c
> > ===================================================================
> > RCS file: graphics/ffmpeg/patches/patch-libavdevice_v4l2_c
> > diff -N graphics/ffmpeg/patches/patch-libavdevice_v4l2_c
> > --- graphics/ffmpeg/patches/patch-libavdevice_v4l2_c	23 Jul 2024 10:18:14 -0000	1.3
> > +++ /dev/null	1 Jan 1970 00:00:00 -0000
> > @@ -1,20 +0,0 @@
> > -lavd/v4l2: Use proper field type for second parameter of ioctl() with BSD's
> > -9e674b31606c805dd31b4bb754364a72a5877238
> > -
> > -Index: libavdevice/v4l2.c
> > ---- libavdevice/v4l2.c.orig
> > -+++ libavdevice/v4l2.c
> > -@@ -107,10 +107,10 @@ struct video_data {
> > -     int (*open_f)(const char *file, int oflag, ...);
> > -     int (*close_f)(int fd);
> > -     int (*dup_f)(int fd);
> > --#ifdef __GLIBC__
> > --    int (*ioctl_f)(int fd, unsigned long int request, ...);
> > --#else
> > -+#if defined(__sun) || defined(__BIONIC__) || defined(__musl__) /* POSIX-like */
> > -     int (*ioctl_f)(int fd, int request, ...);
> > -+#else
> > -+    int (*ioctl_f)(int fd, unsigned long int request, ...);
> > - #endif
> > -     ssize_t (*read_f)(int fd, void *buffer, size_t n);
> > -     void *(*mmap_f)(void *start, size_t length, int prot, int flags, int fd, int64_t offset);
> > Index: graphics/ffmpeg/patches/patch-libavformat_utils_c
> > ===================================================================
> > RCS file: graphics/ffmpeg/patches/patch-libavformat_utils_c
> > diff -N graphics/ffmpeg/patches/patch-libavformat_utils_c
> > --- graphics/ffmpeg/patches/patch-libavformat_utils_c	19 Dec 2023 09:00:06 -0000	1.7
> > +++ /dev/null	1 Jan 1970 00:00:00 -0000
> > @@ -1,24 +0,0 @@
> > -llvm 16 optimizations lead to a segfault when seeking in opus files because
> > -checks that could leave pos_max uninitialized are optimized away, leading
> > -to out-of-bounds reads from the guard pages.
> > -
> > -av_uninit() is complete batshittery:
> > -
> > -https://marc.info/?l=openbsd-ports&m=170284868209618&w=2
> > -
> > -Turns out the same commit has landed upstream:
> > -
> > -https://github.com/FFmpeg/FFmpeg/commit/ab792634197e364ca1bb194f9abe36836e42f12d
> > -
> > -Index: libavformat/utils.c
> > ---- libavformat/utils.c.orig
> > -+++ libavformat/utils.c
> > -@@ -2146,7 +2146,7 @@ int ff_seek_frame_binary(AVFormatContext *s, int strea
> > -                          int64_t target_ts, int flags)
> > - {
> > -     const AVInputFormat *avif = s->iformat;
> > --    int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit;
> > -+    int64_t pos_min = 0, pos_max = 0, pos, pos_limit;
> > -     int64_t ts_min, ts_max, ts;
> > -     int index;
> > -     int64_t ret;
> > Index: x11/mplayer/Makefile
> > ===================================================================
> > RCS file: /cvs/ports/x11/mplayer/Makefile,v
> > retrieving revision 1.329
> > diff -u -p -u -p -r1.329 Makefile
> > --- x11/mplayer/Makefile	27 Sep 2023 20:37:18 -0000	1.329
> > +++ x11/mplayer/Makefile	29 Jul 2024 04:19:06 -0000
> > @@ -1,9 +1,9 @@
> >  COMMENT=	movie player supporting many formats
> >  
> >  V=		20230409
> > -FFMPEG_V=	4.4.4
> > +FFMPEG_V=	4.4.5
> >  DISTNAME=	mplayer-${V}
> > -REVISION=	1
> > +REVISION=	2
> >  CATEGORIES=	x11 multimedia
> >  SITES=		https://comstyle.com/source/
> >  EXTRACT_SUFX=	.tar.xz
> > 
> > 
> 
>