1783 Commits
Author SHA1 Message Date
Jake Fineman 215351c1c3 avdevice/decklink: fix build on macOS by defining IID_IUnknown
Commits 0cd75dbfa0 and 27e94281d1 added QueryInterface()
implementations that compare the requested interface against
IID_IUnknown. The Linux SDK defines it in LinuxCOM.h and the Windows
SDK gets it from the platform COM headers, but the macOS SDK uses
CoreFoundation's COM types from <CoreFoundation/CFPlugInCOM.h>, which
only provide IUnknownUUID as a CFUUIDRef. Since then, building with
--enable-decklink on macOS fails:

  libavdevice/decklink_dec.cpp:138:43: error: use of undeclared
  identifier 'IID_IUnknown'
  libavdevice/decklink_dec.cpp:603:43: error: use of undeclared
  identifier 'IID_IUnknown'
  libavdevice/decklink_enc.cpp:120:39: error: use of undeclared
  identifier 'IID_IUnknown'
  libavdevice/decklink_enc.cpp:181:39: error: use of undeclared
  identifier 'IID_IUnknown'

On macOS, REFIID is CFUUIDBytes, so derive IID_IUnknown from
IUnknownUUID with CFUUIDGetUUIDBytes(), the same definition used by
the macOS samples shipped with the DeckLink SDK. This avoids
duplicating the GUID bytes, and CFUUIDGetConstantUUIDWithBytes()
returns a constant that must not be released. The definition is
limited to __APPLE__, so Linux and Windows builds are unchanged.

Tested with DeckLink SDK 16.0 and Apple clang 21 on macOS arm64.

Signed-off-by: Jake Fineman <jake@wave.online>
2026-10-27 18:06:45 +00:00
whatisyourname0 46f23be8b1 fix(avdevice/alsa): timestamp the complete capture packet after short reads
ALSA capture can assemble a packet from multiple successful reads, possibly
across EAGAIN returns. The timestamp calculation still uses the frame count
from the final read, so it subtracts too little audio time. The same count
also supplies the wrong interval to the next time-filter update.

Use the completed packet's frame count for both calculations. A 7680-frame
packet assembled from two 3840-frame reads at 48 kHz otherwise receives a
first PTS 80 ms too late. Single-read packets retain the same calculation.

Reproduced with real ALSA short returns under ARM64 QEMU: a capture PCM
was primed by half a period, then read in nonblocking mode or interrupted
by SIGALRM while waiting for the remainder. No read return values were
changed in those tests. The fix also passes deterministic sample-order,
PTS, EAGAIN and XRUN recovery checks at 44.1, 48, 96 and 192 kHz.

Signed-off-by: Joonho Lee <mynameisjune111@gmail.com>
2026-10-25 13:19:37 +00:00
James Almer 5f0a7701c1 Bump minor after branching release/9.1
Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-24 17:05:20 -03:00
James Almer aecf409c18 Bump minor version for release/9.1
Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-24 17:05:20 -03:00
Michael Niedermayer abb54ce406 Bump minor after branching release/9.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-23 06:44:03 +02:00
Michael Niedermayer 66143d6aaa Bump minor version for release/9.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-23 06:44:03 +02:00
Michael Niedermayer 8f9ef6aa37 avdevice/v4l2: copy compressed frames out of the mmap buffers
A packet referencing a driver buffer has no AV_INPUT_BUFFER_PADDING_SIZE

Fixes: 7ZY4JenXTFy4
Fixes: out of array read
Out of array read Replicated through UnModified FFmpeg with v4l2loopback and an LD_PRELOAD guard page behind the mmap buffers
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24659
2026-10-20 20:41:50 +00:00
iSold Leo d65fd5581d avdevice/avfoundation: keep format and frame rate range paired
Formats with the same dimensions may expose different frame rates. The
selection loop previously updated selected_format for every size match but
kept selected_range from an earlier format. This could apply a range to a
format that does not support it and make device configuration fail.

Only update selected_format together with its matching range. Track a
size-only match separately so the muxed-device fallback remains unchanged.

Reported-by: MW-de <mw-de@noreply.code.ffmpeg.org>
Suggested-by: MW-de <mw-de@noreply.code.ffmpeg.org>
Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/22694
Signed-off-by: iSold Leo <s@qwqlog.com>
2026-08-30 02:50:39 +00:00
Martin Storsjö 0bffa4a84d avfoundation: Fix compilation for iOS
This fixes building for iOS after commit
c2802e520a.

On iOS, the fallback define kIOMasterPortDefault is never available.
The newer define kIOMainPortDefault is available since iOS 15.

However, if building with older iOS SDKs (iOS 15 SDK or older) then
IOKit is entirely missing. This caused compilation to succeed if
building with such older versions of the iOS SDK.

If building with a newer iOS SDK/Xcode but targeting an older version
of iOS, then IOKit is available, but compilation would fail as
kIOMasterPortDefault wasn't available.

Thus, this fixes compilation for iOS with iOS 16 SDKs and newer,
which was previously broken.
2026-08-28 00:07:13 +03:00
Martin Storsjö 3a99206902 avfoundation: Consolidate the HAVE_IOKIT ifdefs
This makes it easier to tweak the condition for when these codepaths
are enabled.
2026-08-28 00:07:13 +03:00
Gabriel Balaich a81b23a85a avdevice/avfoundation: fix build with deployment targets below macOS 12
c2802e520a selected kIOMainPortDefault whenever the SDK is new enough
(__MAC_OS_X_VERSION_MAX_ALLOWED), but that symbol is only available
since macOS 12, so building with a newer SDK against an older
deployment target failed with -Wunguarded-availability-new.

Check the deployment target (__MAC_OS_X_VERSION_MIN_REQUIRED) instead
and keep using the equivalent kIOMasterPortDefault when targeting
older releases.

See: https://lists.ffmpeg.org/archives/list/ffmpeg-devel@ffmpeg.org/thread/S7PGVSGNLIZ2WRYV6VOBAD3RWYUNWA3H/
Reported-by: Helmut K. C. Tessarek <tessarek@evermeet.cx>
Signed-off-by: Gabriel Balaich <ffmpeg@ninbura.com>
2026-08-07 13:55:36 +00:00
ninbura c2802e520a avdevice/avfoundation: add device selection by USB serial and unique ID
A capture device could previously be selected only by index or by name.
Both are unreliable when multiple audio/video devices share a name or
across reboots. AVFoundation reorders the device indices, and the USB
video uniqueID embeds the macOS locationID, which can be reassigned on
reboot or replug and can then resolve to a different physical device.

Add -video_device_id and -audio_device_id, which take a prefixed
identifier: uid:<unique ID> or serial:<USB serial number>.

The USB serial number is the only identifier that stays pegged to a
given physical unit. For video it is resolved to the device's current
locationID via IOKit. For audio it is matched against the uniqueID,
which already embeds it. The unique ID covers devices that have no
serial, such as virtual camera/audio devices.

-list_devices additionally prints each device's uniqueID and USB serial
so the values can be discovered. IOKit is detected in configure and used
only when available.

Signed-off-by: Gabriel Balaich <ffmpeg@ninbura.com>
2026-08-02 12:10:11 -05:00
Mirkó Visontai 1588bce21b avdevice/android_camera: fix OOB read in metadata parsing
ACAMERA_SCALER_AVAILABLE_STREAM_CONFIGURATIONS metadata is an
int32[n*4] array (one 4-tuple per stream config: format, width,
height, input/output flag). ACameraMetadata_const_entry.count is the
total number of int32_t elements, not the number of tuples. The loop
bound must be count/4 to avoid iterating past the end of the array.

Similarly, ACAMERA_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES is an
int32[n*2] array (min/max pairs). The loop bound must be count/2.

Without this fix, both loops over-iterate and read heap memory
beyond the metadata array bounds.

Signed-off-by: Mirko Visontai <mirkov@google.com>
2026-07-15 03:47:53 +00:00
zhanghongyuan ac91f1c0f7 avdevice/pulse_audio_dec: validate sample spec before use
ff_codec_id_to_pulse_format() returns PA_SAMPLE_INVALID for
unsupported codecs (e.g. AAC, FLAC, Opus). Without validation,
the invalid format propagates to pa_frame_size() and other PA
calls, causing assertion failures or division-by-zero.

Add pa_sample_spec_valid() check, matching the existing guard
in pulse_audio_enc.c.

Signed-off-by: zhanghongyuan <zhanghongyuan@uniontech.com>
2026-07-14 21:25:25 +00:00
Romain Beauxis 1f24840239 avdevice/alsa: auto-detect channel layout when capturing audio 2026-07-11 08:45:54 -05:00
Jun Zhao ddf8f40301 avdevice/avfoundation: wait for frame consumption to avoid dropping A/V frames
The capture callback dropped the previous frame instead of waiting for it
to be consumed, so frames were lost when avf_read_packet() fell behind;
39fbd06314 (return EAGAIN instead of waiting) made it easy to hit.

Add back a condition variable: the capture callback blocks until
avf_read_packet() takes the current frame, and the reader waits on it when
no frame is ready. An is_stopping flag set in destroy_context() wakes both
sides so teardown cannot deadlock. observed_quit is now set under the lock
and broadcast as well, so a blocked reader wakes and returns EOF when a
transport-control device stops delivering frames.

Based on a patch by Zhongxin Zhuang <zx.zhuang@hotmail.com>; here
unlock_frames() only broadcasts and unlocks, so a read no longer releases
the other stream's still-unconsumed frame.

Verified by capturing camera+mic for 8s and comparing delivered packet
counts before/after this change:

  ffmpeg -f avfoundation -pixel_format nv12 -framerate 30 -i "0:0" -t 8 \
         -vf "scale=2560:1440,hqdn3d" -c:v libx264 -preset medium \
         -c:a aac out.mp4
  ffprobe -count_packets -show_entries stream=nb_read_packets out.mp4

  slow consumer (ideal: video ~240, audio ~375)
                     video   audio
    before (EAGAIN)   174     163   (audio ~57% dropped)
    after  (condvar)  234     376   (no drops)

  fast consumer (-preset ultrafast, no filter)
    before            240     328
    after             238     376

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-07-03 23:53:25 +00:00
Michael Niedermayer d66e84695b Bump minor after release/9.0 branch on master
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 02:47:51 +02:00
Michael Niedermayer 47e9d68e20 Bump minor for release/9.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 02:43:34 +02:00
Andreas Rheinhardt 762b94e672 libs: Bump major version of all libraries
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Michael Niedermayer 54849fe663 avcodec/avformat: Unavpriv avpriv_packet_list_*()
The avpriv_packet_list_put/get/free() functions and the PacketList type
were implemented in libavcodec and exported via the avpriv_ mechanism
solely so that libavformat (and decklink in libavdevice) could use them;
libavcodec itself has no users of them. Exporting them across the library
boundary has the usual drawbacks for shared builds (export/import overhead
and having to keep them around for ABI stability even once unneeded).

Move the implementation and the PacketList/PacketListEntry types to
libavformat and rename the functions to ff_packet_list_*(). libavformat is
the primary user and compiles the new packet_list.c directly; decklink,
the only libavdevice user, gets a private copy for shared builds via the
SHLIBOBJS scheme already used for reverse.o and ccfifo.o (static builds
resolve the symbols from libavformat).

AVPACKET_IS_EMPTY() and ff_side_data_set_prft() remain in
libavcodec/packet_internal.h as they are libavcodec-internal.
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt d333beb8b5 avdevice: Remove deprecated FF_API_ALSA_CHANNELS
Deprecated since 2025-02-01.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Hunter Kvalevog 54749da98a avdevice/gdigrab: make overlay window layered
WS_EX_LAYERED allows input events to pass through to windows beneath.

WS_EX_NOACTIVATE prevents the window from stealing focus when created.
2026-06-10 12:56:20 +00:00
Hunter Kvalevog dc1128e475 avdevice/gdigrab: process window in a separate thread
Move window creation and event processing to a dedicated thread.

GetMessage only processes events from the calling thread's message
queue. Because gdigrab_read_header and gdigrab_read_packet don't run on
the same thread, the message queue was not being drained.

Fixes: #11539
2026-06-10 12:56:20 +00:00
Zhao Zhili 603234f945 avdevice/v4l2: fix mmap_free() skipping first buffer
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-28 13:45:20 +00:00
Romain Beauxis 82d7e375f1 libavdevice/alsa.c: fix NULL pointer dereference 2026-04-19 15:00:08 +00:00
Alexandru Ardelean e43aab67ed avdevice/v4l2: rename 'buff_data' -> 'buf_desc'
Since we've added a 'buf_data' struct, rename this to avoid any confusion
about this one.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
2026-04-10 16:02:28 +00:00
Alexandru Ardelean 1011e4d647 avdevice/v4l2: wrap buf_start and buf_len into a struct
This reduces the number of malloc() & free() calls, and structures the
data for the buffers a bit neatly.
In case more per-buffer data needs to be added, having a separate struct
is useful.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
2026-04-10 16:02:28 +00:00
Alexandru Ardelean 24adcf3a72 avdevice/v4l2: fix potential memleak when allocating device buffers
In the loop which allocates the buffers for a V4L2 device, if failure
occurs for a certain buffer (e.g. 3rd of 4 buffers), then the previously
allocated buffers (and the buffer array) would not be free'd in
the mmap_init(). This would cause a leak.

This change handles the error cases of that loop to free all allocated
resources, so that when mmap_init() fails nothing is leaked.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
2026-04-10 16:02:28 +00:00
David Hampton db53fe1ac2 avdevice/alsa.c: Conditionally compile out ESTRPIPE
NetBSD doesn't have this error code, so put in a test to prevent
compiling related code on NetBSD systems.
2026-04-08 20:44:16 +00:00
Michael Niedermayer c1263a3dd9 Bump versions for master after release/8.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-08 02:31:23 +01:00
Michael Niedermayer 67c886222f Bump versions for release/8.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-08 02:29:20 +01:00
Kacper Michajłow f7b7972f78 avdevice/gdigrab: suppress int to pointer cast warning
Fixes: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-03 23:45:44 +00:00
Thomas Gritzan 27e94281d1 libavdevice/decklink: add support for DeckLink SDK 14.3
This patch adds support for DeckLink SDK 14.3 and newer by using
the legacy interfaces in the header <DeckLinkAPI_v14_2_1.h>.

The missing QueryInterface implementations are also provided.
2025-12-01 21:37:12 +00:00
Thomas Gritzan 0cd75dbfa0 libavdevice/decklink: Implement QueryInterface to support newer driver
Playback to a decklink device with a newer version of the
DeckLink SDK (14.3) stalls because the driver code calls
IDeckLinkVideoFrame::QueryInterface, which is not
implemented by ffmpeg.
This patch implements decklink_frame::QueryInterface,
so that playback works with both older (12.x) and
newer (>= 14.3) drivers.

Note: The patch still does not allow the code to compile
with DeckLink SDK 14.3 or newer, as the API has changed.
2025-11-27 20:12:03 +00:00
James Almer b478037423 avdevice/lavfi: stop setting deprecated buffersink options
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-13 21:02:10 -03:00
Michael Niedermayer 638b521c7b Bump versions for master after release/8.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-09 18:03:05 +02:00
Michael Niedermayer 7eaa0f799a Bump versions for release/8.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-09 17:30:39 +02:00
Timo Rothenpieler 262d41c804 all: fix typos found by codespell 2025-08-03 13:48:47 +02:00
wangbin 7b13d17b6d avdevice/android_camera: Set image linesize aligment to 1
Can't read alignment from packet, codecpar or decoded frame linesizes, so don't
set it. My test device redmi k60 produces images in 4624x3472, not 32 aligned

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-07-18 10:37:53 +08:00
Clément Péron 90424a4475 various: fix typos
usefull -> useful
seperately -> separately
reciever -> receiver

Signed-off-by: Clément Péron <peron.clem@gmail.com>
2025-06-15 21:00:38 +05:30
Leo Izen 5fea5e3e11 configure: rename POSIX ioctl check
Commit 00b64fca55 introduced configure
detection for HAVE_POSIX_IOCTL but unfortunately this conflicts with
v4l-utils version 1.30, which itself checks for #ifdef HAVE_POSIX_IOCTL
in a public header and erroneously determines it to be true because we
define this to be 0.

Since this is only used for avdevice/v4l2, we rename this to something
else, namely ioctl_posix, simply to prevent the name conflict with the
file /usr/include/libv4l2.h at least until they can upstream a fix on
their end.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-06-08 19:42:56 -04:00
Martin Storsjö 69bab4e74f avfoundation: Fix compilation for OSes other than macOS and iOS
E.g. tvOS doesn't have devicesWithMediaType.

In principle, we could probably disable building the whole
input device on such OSes, but that would either require
testing explicitly for the OS type in configure (which we don't
do anywhere so far), or test for individual objective C methods.

This approach allows the code to compile, but no input devices
will be found at runtime.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-04 17:12:33 +03:00
James Almer b338d1b35b libs: bump major version for all libraries
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:44:34 -03:00
James Almer ebd6d07ab9 avutil: remove deprecated FF_API_FRAME_PKT
Deprecated since 2023-03-20.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:08 -03:00
James Almer c153238275 avformat: remove deprecated FF_API_ALLOW_FLUSH
Deprecated since 2023-10-02.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:07 -03:00
James Almer 8a7ce397bc avdevice/version_major: postpone some deprecations until the next bump
They are too recent.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:07 -03:00
James Almer 17b31065f0 avdevice: remove deprecated FF_API_SDL2_DEVICE
Deprecated since 2024-02-28.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:07 -03:00
James Almer 9283c5251f avdevice: remove deprecated FF_API_OPENGL_DEVICE
Deprecated since 2024-02-28.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:07 -03:00
James Almer a5064a72ff avdevice: remove deprecated FF_API_BKTR_DEVICE
Deprecated since 2024-02-02.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-28 14:33:07 -03:00
Andreas Rheinhardt e5d62e20c8 avdevice/sdl2: Suppress macro redefinition warning
SDL2's headers #define HAVE_PTHREAD_SETNAME_NP (to one here);
we also have a config define which leads the compiler to
warn about this when the values are distinct (as they are here).
Suppress this warning by including config.h before SDL.h.
The latter will then redefine our define which doesn't matter
and which does not lead to warnings because compilers don't warn
about system headers by default (depending upon -Wsystem-headers).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-21 04:30:09 +01:00