Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
ui/prores_aw_handler: Workaround for FFmpeg bug with ProRes in Matroska
Browse files Browse the repository at this point in the history
In current FFmpeg, whenever Matroska with ProRes is demuxed it creates an atom that is just 8 bytes short of the true size necessary.

We can work around this by padding the actual packet by 8 0x00 bytes, which should result in older FFmpeg versions working fine.

An FFmpeg patch is available: http://ffmpeg.org/pipermail/ffmpeg-devel/2019-September/250724.html
  • Loading branch information
Xaymar committed Sep 29, 2019
1 parent cbd39a8 commit fe71944
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions source/ui/prores_aw_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,17 @@ void obsffmpeg::ui::prores_aw_handler::log_options(obs_data_t* settings, const A
PLOG_INFO("[%s] Profile: %s", codec->name, ptr->name);
}
}

void obsffmpeg::ui::prores_aw_handler::process_avpacket(AVPacket& packet, const AVCodec* codec, AVCodecContext* context)
{
//FFmpeg Bug:
// When ProRes content is stored in Matroska, FFmpeg strips the size
// from the atom. Later when the ProRes content is demuxed from Matroska,
// FFmpeg creates an atom with the incorrect size, as the ATOM size
// should be content + atom, but FFmpeg set it to only be content. This
// difference leads to decoders to be off by 8 bytes.
//Fix (until FFmpeg stops being broken):
// Pad the packet with 8 bytes of 0x00.

av_grow_packet(&packet, 8);
}
2 changes: 2 additions & 0 deletions source/ui/prores_aw_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ namespace obsffmpeg {

virtual void log_options(obs_data_t* settings, const AVCodec* codec,
AVCodecContext* context) override;

virtual void process_avpacket(AVPacket& packet, const AVCodec* codec, AVCodecContext* context) override;
};
} // namespace ui
} // namespace obsffmpeg

0 comments on commit fe71944

Please sign in to comment.