Skip to content

Commit ddd5246

Browse files
committed
Fix handling of RAWIMAGE under ffmpeg 4
1 parent e03cd87 commit ddd5246

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/FFmpegWriter.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,9 @@ void FFmpegWriter::flush_encoders() {
842842
#if (LIBAVFORMAT_VERSION_MAJOR < 58)
843843
if (info.has_video && video_codec && AV_GET_CODEC_TYPE(video_st) == AVMEDIA_TYPE_VIDEO && (oc->oformat->flags & AVFMT_RAWPICTURE) && AV_FIND_DECODER_CODEC_ID(video_st) == AV_CODEC_ID_RAWVIDEO)
844844
return;
845+
#else
846+
if (info.has_video && video_codec && AV_GET_CODEC_TYPE(video_st) == AVMEDIA_TYPE_VIDEO && AV_FIND_DECODER_CODEC_ID(video_st) == AV_CODEC_ID_RAWVIDEO)
847+
return;
845848
#endif
846849

847850
int error_code = 0;
@@ -1991,10 +1994,14 @@ void FFmpegWriter::process_video_packet(std::shared_ptr<Frame> frame) {
19911994
bool FFmpegWriter::write_video_packet(std::shared_ptr<Frame> frame, AVFrame *frame_final) {
19921995
#if (LIBAVFORMAT_VERSION_MAJOR >= 58)
19931996
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet", "frame->number", frame->number, "oc->oformat->flags", oc->oformat->flags);
1997+
1998+
if (video_st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
1999+
video_st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
19942000
#else
19952001
ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet", "frame->number", frame->number, "oc->oformat->flags & AVFMT_RAWPICTURE", oc->oformat->flags & AVFMT_RAWPICTURE);
19962002

19972003
if (oc->oformat->flags & AVFMT_RAWPICTURE) {
2004+
#endif
19982005
// Raw video case.
19992006
AVPacket pkt;
20002007
av_init_packet(&pkt);
@@ -2019,7 +2026,6 @@ bool FFmpegWriter::write_video_packet(std::shared_ptr<Frame> frame, AVFrame *fra
20192026
AV_FREE_PACKET(&pkt);
20202027

20212028
} else
2022-
#endif
20232029
{
20242030

20252031
AVPacket pkt;

0 commit comments

Comments
 (0)