Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FFmpeg.AutoGen" Version="7.0.0" />
<PackageReference Include="FFmpeg.AutoGen" Version="8.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion Unosquare.FFME.Windows/Unosquare.FFME.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FFmpeg.AutoGen" Version="7.0.0" />
<PackageReference Include="FFmpeg.AutoGen" Version="8.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
6 changes: 4 additions & 2 deletions Unosquare.FFME/Container/MediaContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ private void StreamInitialize()
}
}

ffmpeg.av_format_inject_global_side_data(InputContext);
// ffmpeg.av_format_inject_global_side_data(InputContext);

Comment on lines +722 to 723
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The av_format_inject_global_side_data call has been commented out instead of being properly removed or documented. If this function is removed in FFmpeg 8 and no longer needed, the comment should explain why it's safe to remove. If it's been replaced by an alternative approach, that should be documented here.

Suggested change
// ffmpeg.av_format_inject_global_side_data(InputContext);

Copilot uses AI. Check for mistakes.
// This is useful for file formats with no headers such as MPEG. This function also computes
// the real frame-rate in case of MPEG-2 repeat frame mode.
Expand Down Expand Up @@ -822,7 +822,7 @@ private void StreamInitializeInputContext()
// InputContext->flags |= opts.FlagKeepSideData ? ffmpeg.AVFMT_FLAG_KEEP_SIDE_DATA : InputContext->flags;
InputContext->flags |= opts.FlagNoBuffer ? ffmpeg.AVFMT_FLAG_NOBUFFER : InputContext->flags;
InputContext->flags |= opts.FlagSortDts ? ffmpeg.AVFMT_FLAG_SORT_DTS : InputContext->flags;
InputContext->flags |= opts.FlagStopAtShortest ? ffmpeg.AVFMT_FLAG_SHORTEST : InputContext->flags;
////InputContext->flags |= opts.FlagStopAtShortest ? ffmpeg.AVFMT_FLAG_SHORTEST : InputContext->flags;
Comment thread
zgabi marked this conversation as resolved.
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AVFMT_FLAG_SHORTEST flag usage has been commented out with four slashes instead of being properly removed or documented. Since the FlagStopAtShortest option still exists in DemuxerGlobalOptions, users may set this option expecting it to work, but it will now be silently ignored. Either document why this flag is no longer supported in FFmpeg 8, remove the option from DemuxerGlobalOptions, or provide an alternative implementation.

Suggested change
////InputContext->flags |= opts.FlagStopAtShortest ? ffmpeg.AVFMT_FLAG_SHORTEST : InputContext->flags;
// NOTE: AVFMT_FLAG_SHORTEST is no longer supported in FFmpeg 8+.
// The DemuxerGlobalOptions.FlagStopAtShortest option is kept for backward compatibility
// but is currently a no-op and does not modify InputContext->flags.

Copilot uses AI. Check for mistakes.

InputContext->seek2any = opts.SeekToAny ? 1 : 0;

Expand Down Expand Up @@ -998,6 +998,8 @@ private MediaType StreamRead()
if (Data.TryHandleDataPacket(this, readPacket))
return MediaType.None;

readPacket.Pointer->opaque = (void*)readPacket.Pointer->size;
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The packet size is being stored in the opaque field as a workaround for the deprecated pkt_size field. However, there's no documentation explaining this workaround pattern or any validation that the opaque field isn't already being used for another purpose. Consider adding a comment explaining that this is a workaround for the removed pkt_size field in FFmpeg 8, and verify that opaque is not used elsewhere in a conflicting way.

Suggested change
readPacket.Pointer->opaque = (void*)readPacket.Pointer->size;
// FFmpeg 8 removed AVPacket.pkt_size. As a workaround, store the packet size
// in AVPacket.opaque for later retrieval, but only if opaque is not already
// being used for some other purpose.
if (readPacket.Pointer->opaque == null)
readPacket.Pointer->opaque = (void*)readPacket.Pointer->size;

Copilot uses AI. Check for mistakes.

var componentType = Components.SendPacket(readPacket);

// Discard the packet -- it was not accepted by any component
Expand Down
5 changes: 1 addition & 4 deletions Unosquare.FFME/Container/MediaFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ internal abstract unsafe class MediaFrame : IComparable<MediaFrame>, IDisposable
protected MediaFrame(AVFrame* pointer, MediaComponent component, MediaType mediaType)
: this((void*)pointer, component, mediaType)
{
#pragma warning disable CS0618 // Type or member is obsolete
var packetSize = pointer->pkt_size;
#pragma warning restore CS0618 // Type or member is obsolete
CompressedSize = packetSize > 0 ? packetSize : 0;
CompressedSize = (int)pointer->opaque;
PresentationTime = pointer->pts;
DecodingTime = pointer->pkt_dts;
}
Expand Down
10 changes: 4 additions & 6 deletions Unosquare.FFME/Container/VideoComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ internal VideoComponent(MediaContainer container, int streamIndex)
FrameHeight = CodecContext->height;

// Retrieve Matrix Rotation
#pragma warning disable CS0618 // Type or member is obsolete
var displayMatrixRef = ffmpeg.av_stream_get_side_data(Stream, AVPacketSideDataType.AV_PKT_DATA_DISPLAYMATRIX, null);
#pragma warning restore CS0618 // Type or member is obsolete
DisplayRotation = ComputeRotation(displayMatrixRef);
var displayMatrixRef = ffmpeg.av_packet_side_data_get(Stream->codecpar->coded_side_data, Stream->codecpar->nb_coded_side_data, AVPacketSideDataType.AV_PKT_DATA_DISPLAYMATRIX);
DisplayRotation = displayMatrixRef == null ? 0 : ComputeRotation(displayMatrixRef->data);

var aspectRatio = ffmpeg.av_d2q((double)FrameWidth / FrameHeight, int.MaxValue);
DisplayAspectWidth = aspectRatio.num;
Expand All @@ -89,7 +87,7 @@ internal VideoComponent(MediaContainer container, int streamIndex)
/// Point / nearest-neighbor is the default and it is the cheapest. This is by design as
/// we don't change the dimensions of the image. We only do color conversion.
/// </summary>
public static int ScalerFlags { get; internal set; } = ffmpeg.SWS_POINT;
public static SwsFlags ScalerFlags { get; internal set; } = SwsFlags.SWS_POINT;

/// <summary>
/// Gets the base frame rate as reported by the stream component.
Expand Down Expand Up @@ -223,7 +221,7 @@ public override bool MaterializeFrame(MediaFrame input, ref MediaBlock output, M
source.Pointer->width,
source.Pointer->height,
Constants.VideoPixelFormat,
ScalerFlags,
(int)ScalerFlags,
null,
null,
null);
Expand Down
Loading