Skip to content

Commit

Permalink
Merge pull request #6311 from bdach/video-decoding-ignore-editlist
Browse files Browse the repository at this point in the history
Ignore editlist when decoding mp4/mov videos
  • Loading branch information
peppy authored Jun 15, 2024
2 parents ec2c559 + 30cc44d commit 9979a9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions osu.Framework/Graphics/Video/FFmpegFuncs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public unsafe class FFmpegFuncs
{
#region Delegates

public delegate int AvDictSetDelegate(AVDictionary** pm, [MarshalAs(UnmanagedType.LPUTF8Str)] string key, [MarshalAs(UnmanagedType.LPUTF8Str)] string value, int flags);

public delegate void AvDictFreeDelegate(AVDictionary** m);

public delegate AVFrame* AvFrameAllocDelegate();

public delegate void AvFrameFreeDelegate(AVFrame** frame);
Expand Down Expand Up @@ -89,6 +93,8 @@ public unsafe class FFmpegFuncs

#endregion

public AvDictSetDelegate av_dict_set;
public AvDictFreeDelegate av_dict_free;
public AvFrameAllocDelegate av_frame_alloc;
public AvFrameFreeDelegate av_frame_free;
public AvFrameUnrefDelegate av_frame_unref;
Expand Down
9 changes: 8 additions & 1 deletion osu.Framework/Graphics/Video/VideoDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,12 @@ private void prepareDecoding()
formatContext->pb = ioContext;
formatContext->flags |= FFmpegFuncs.AVFMT_FLAG_GENPTS; // required for most HW decoders as they only read `pts`

int openInputResult = ffmpeg.avformat_open_input(&fcPtr, "pipe:", null, null);
AVDictionary* options = null;
// see https://github.com/ppy/osu/issues/13696 for reasoning
ffmpeg.av_dict_set(&options, "ignore_editlist", "1", 0);
int openInputResult = ffmpeg.avformat_open_input(&fcPtr, "pipe:", null, &options);
ffmpeg.av_dict_free(&options);

inputOpened = openInputResult >= 0;
if (!inputOpened)
throw new InvalidOperationException($"Error opening file or stream: {getErrorMessage(openInputResult)}");
Expand Down Expand Up @@ -842,6 +847,8 @@ protected virtual FFmpegFuncs CreateFuncs()

return new FFmpegFuncs
{
av_dict_set = FFmpeg.AutoGen.ffmpeg.av_dict_set,
av_dict_free = FFmpeg.AutoGen.ffmpeg.av_dict_free,
av_frame_alloc = FFmpeg.AutoGen.ffmpeg.av_frame_alloc,
av_frame_free = FFmpeg.AutoGen.ffmpeg.av_frame_free,
av_frame_unref = FFmpeg.AutoGen.ffmpeg.av_frame_unref,
Expand Down

0 comments on commit 9979a9c

Please sign in to comment.