Skip to content

Commit ff63396

Browse files
Update to ffmpeg5.0 (#625)
Co-authored-by: quangtt-starify <[email protected]>
1 parent 6cae62e commit ff63396

File tree

6 files changed

+14
-17
lines changed

6 files changed

+14
-17
lines changed

Unosquare.FFME.Windows.Sample/Unosquare.FFME.Windows.Sample.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
</ItemGroup>
7373

7474
<ItemGroup>
75-
<PackageReference Include="FFmpeg.AutoGen" Version="4.4.0" />
76-
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.3">
75+
<PackageReference Include="FFmpeg.AutoGen" Version="5.0.0" />
76+
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
7777
<PrivateAssets>all</PrivateAssets>
7878
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
7979
</PackageReference>

Unosquare.FFME.Windows/Unosquare.FFME.Windows.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
</ItemGroup>
7979

8080
<ItemGroup>
81-
<PackageReference Include="FFmpeg.AutoGen" Version="4.4.0" />
82-
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.3">
81+
<PackageReference Include="FFmpeg.AutoGen" Version="5.0.0" />
82+
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
8383
<PrivateAssets>all</PrivateAssets>
8484
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
8585
</PackageReference>

Unosquare.FFME/Common/MediaInfo.cs

+3-8
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,7 @@ private static List<StreamInfo> ExtractStreams(AVFormatContext* inputContext)
114114
var s = inputContext->streams[i];
115115

116116
var codecContext = ffmpeg.avcodec_alloc_context3(null);
117-
118-
#pragma warning disable CS0618 // Type or member is obsolete
119-
120-
// ffmpeg.avcodec_parameters_to_context(codecContext, s->codecpar);
121-
ffmpeg.avcodec_copy_context(codecContext, s->codec);
122-
#pragma warning restore CS0618 // Type or member is obsolete
117+
ffmpeg.avcodec_parameters_to_context(codecContext, s->codecpar);
123118

124119
var bitsPerSample = codecContext->codec_type == AVMediaType.AVMEDIA_TYPE_AUDIO ?
125120
ffmpeg.av_get_bits_per_sample(codecContext->codec_id) : 0;
@@ -150,7 +145,7 @@ private static List<StreamInfo> ExtractStreams(AVFormatContext* inputContext)
150145
bitsPerSample * codecContext->channels * codecContext->sample_rate :
151146
codecContext->bit_rate,
152147
MaxBitRate = codecContext->rc_max_rate,
153-
InfoFrameCount = s->codec_info_nb_frames,
148+
InfoFrameCount = (int)s->nb_frames,
154149
TimeBase = s->time_base,
155150
SampleFormat = codecContext->sample_fmt,
156151
SampleRate = codecContext->sample_rate,
@@ -258,7 +253,7 @@ private static List<ChapterInfo> ExtractChapters(AVFormatContext* ic)
258253
StartTime = c->start.ToTimeSpan(c->time_base),
259254
EndTime = c->end.ToTimeSpan(c->time_base),
260255
Index = i,
261-
ChapterId = c->id,
256+
ChapterId = (int)c->id,
262257
Metadata = FFDictionary.ToDictionary(c->metadata)
263258
};
264259

Unosquare.FFME/Container/MediaComponent.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ protected MediaComponent(MediaContainer container, int streamIndex)
8383
#pragma warning disable CS0618 // Type or member is obsolete
8484

8585
// Set default codec context options from probed stream
86-
// var setCodecParamsResult = ffmpeg.avcodec_parameters_to_context(CodecContext, Stream->codecpar);
87-
var setCodecParamsResult = ffmpeg.avcodec_copy_context(CodecContext, Stream->codec);
86+
var setCodecParamsResult = ffmpeg.avcodec_parameters_to_context(CodecContext, Stream->codecpar);
87+
8888
#pragma warning restore CS0618 // Type or member is obsolete
8989

9090
if (setCodecParamsResult < 0)

Unosquare.FFME/Container/MediaContainer.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -807,12 +807,14 @@ private void StreamInitializeInputContext()
807807
// Flags
808808
InputContext->flags |= opts.FlagDiscardCorrupt ? ffmpeg.AVFMT_FLAG_DISCARD_CORRUPT : InputContext->flags;
809809
InputContext->flags |= opts.FlagEnableFastSeek ? ffmpeg.AVFMT_FLAG_FAST_SEEK : InputContext->flags;
810-
InputContext->flags |= opts.FlagEnableLatmPayload ? ffmpeg.AVFMT_FLAG_MP4A_LATM : InputContext->flags;
810+
811+
// InputContext->flags |= opts.FlagEnableLatmPayload ? ffmpeg.AVFMT_FLAG_MP4A_LATM : InputContext->flags;
811812
InputContext->flags |= opts.FlagEnableNoFillIn ? ffmpeg.AVFMT_FLAG_NOFILLIN : InputContext->flags;
812813
InputContext->flags |= opts.FlagGeneratePts ? ffmpeg.AVFMT_FLAG_GENPTS : InputContext->flags;
813814
InputContext->flags |= opts.FlagIgnoreDts ? ffmpeg.AVFMT_FLAG_IGNDTS : InputContext->flags;
814815
InputContext->flags |= opts.FlagIgnoreIndex ? ffmpeg.AVFMT_FLAG_IGNIDX : InputContext->flags;
815-
InputContext->flags |= opts.FlagKeepSideData ? ffmpeg.AVFMT_FLAG_KEEP_SIDE_DATA : InputContext->flags;
816+
817+
// InputContext->flags |= opts.FlagKeepSideData ? ffmpeg.AVFMT_FLAG_KEEP_SIDE_DATA : InputContext->flags;
816818
InputContext->flags |= opts.FlagNoBuffer ? ffmpeg.AVFMT_FLAG_NOBUFFER : InputContext->flags;
817819
InputContext->flags |= opts.FlagSortDts ? ffmpeg.AVFMT_FLAG_SORT_DTS : InputContext->flags;
818820
InputContext->flags |= opts.FlagStopAtShortest ? ffmpeg.AVFMT_FLAG_SHORTEST : InputContext->flags;

Unosquare.FFME/Container/VideoFrame.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ internal VideoFrame(AVFrame* frame, VideoComponent component)
7575
continue;
7676

7777
// Parse 3 bytes at a time
78-
for (var p = 0; p < sideData->size; p += 3)
78+
for (var p = 0; p < (int)sideData->size; p += 3)
7979
{
8080
var packet = new ClosedCaptionPacket(TimeSpan.FromTicks(StartTime.Ticks + p), sideData->data, p);
8181
if (packet.PacketType == CaptionsPacketType.NullPad || packet.PacketType == CaptionsPacketType.Unrecognized)

0 commit comments

Comments
 (0)