Control: tags -1 patch
Control: forwarded -1 https://github.com/OpenShot/libopenshot/issues/87

Hi,

On 24/01/18 23:26, jcowg...@debian.org wrote:
> Source: libopenshot
> Version: 0.1.9+dfsg1-3
> Severity: important
> User: debian-multime...@lists.debian.org
> Usertags: ffmpeg-3.5-transition
> 
> Hi,
> 
> Your package FTBFS with the upcoming version 3.5 of FFmpeg.

The attached patch fixes this. Unlike other packages I've looked at, the
changes aren't quite as trivial because it involves the removal of the
AVFMT_RAWPICTURE API. I think what I've done is correct, but I'm not
100% sure.

Thanks,
James
Description: Fix FTBFS with FFmpeg 4.0
 This involves removing code using the AVFMT_RAWPICTURE API which has been
 removed in FFmpeg 4.0
Author: James Cowgill <jcowg...@debian.org>
Bug: https://github.com/OpenShot/libopenshot/issues/87
Bug-Debian: https://bugs.debian.org/888364
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/src/FFmpegWriter.cpp
+++ b/src/FFmpegWriter.cpp
@@ -543,8 +543,6 @@ void FFmpegWriter::flush_encoders()
 {
     if (info.has_audio && audio_codec && audio_st->codec->codec_type == AVMEDIA_TYPE_AUDIO && audio_codec->frame_size <= 1)
         return;
-    if (info.has_video && video_st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (oc->oformat->flags & AVFMT_RAWPICTURE) && video_codec->codec->id == AV_CODEC_ID_RAWVIDEO)
-        return;
 
     int error_code = 0;
     int stop_encoding = 1;
@@ -858,7 +856,7 @@ AVStream* FFmpegWriter::add_audio_stream
 
 	// some formats want stream headers to be separate
 	if (oc->oformat->flags & AVFMT_GLOBALHEADER)
-		c->flags |= CODEC_FLAG_GLOBAL_HEADER;
+		c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
 
 	ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_audio_stream", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->channels", c->channels, "c->sample_fmt", c->sample_fmt, "c->channel_layout", c->channel_layout, "c->sample_rate", c->sample_rate);
 
@@ -931,7 +929,7 @@ AVStream* FFmpegWriter::add_video_stream
 		c->mb_decision = 2;
 	// some formats want stream headers to be separate
 	if (oc->oformat->flags & AVFMT_GLOBALHEADER)
-		c->flags |= CODEC_FLAG_GLOBAL_HEADER;
+		c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
 
 	// Find all supported pixel formats for this codec
     const PixelFormat* supported_pixel_formats = codec->pix_fmts;
@@ -947,18 +945,10 @@ AVStream* FFmpegWriter::add_video_stream
         if(fmt->video_codec == AV_CODEC_ID_RAWVIDEO) {
             // Raw video should use RGB24
         	c->pix_fmt = PIX_FMT_RGB24;
-
-        if (strcmp(fmt->name, "gif") != 0)
-			// If not GIF format, skip the encoding process
-			// Set raw picture flag (so we don't encode this video)
-			oc->oformat->flags |= AVFMT_RAWPICTURE;
-        } else {
-        	// Set the default codec
-        	c->pix_fmt = PIX_FMT_YUV420P;
         }
     }
 
-	ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (string)fmt->name + " : " + (string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags, "AVFMT_RAWPICTURE", AVFMT_RAWPICTURE, "", -1);
+	ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::add_video_stream (" + (string)fmt->name + " : " + (string)av_get_pix_fmt_name(c->pix_fmt) + ")", "c->codec_id", c->codec_id, "c->bit_rate", c->bit_rate, "c->pix_fmt", c->pix_fmt, "oc->oformat->flags", oc->oformat->flags, "", -1, "", -1);
 
 	return st;
 }
@@ -1018,7 +1008,7 @@ void FFmpegWriter::open_audio(AVFormatCo
 	audio_encoder_buffer_size = AUDIO_PACKET_ENCODING_SIZE;
 	audio_encoder_buffer = new uint8_t[audio_encoder_buffer_size];
 
-	ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::open_audio", "audio_codec->thread_count", audio_codec->thread_count, "audio_input_frame_size", audio_input_frame_size, "buffer_size", AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE, "", -1, "", -1, "", -1);
+	ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::open_audio", "audio_codec->thread_count", audio_codec->thread_count, "audio_input_frame_size", audio_input_frame_size, "buffer_size", AVCODEC_MAX_AUDIO_FRAME_SIZE + AV_INPUT_BUFFER_PADDING_SIZE, "", -1, "", -1, "", -1);
 
 }
 
@@ -1473,34 +1463,7 @@ void FFmpegWriter::process_video_packet(
 // write video frame
 bool FFmpegWriter::write_video_packet(std::shared_ptr<Frame> frame, AVFrame* frame_final)
 {
-	ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet", "frame->number", frame->number, "oc->oformat->flags & AVFMT_RAWPICTURE", oc->oformat->flags & AVFMT_RAWPICTURE, "", -1, "", -1, "", -1, "", -1);
-
-	if (oc->oformat->flags & AVFMT_RAWPICTURE) {
-		// Raw video case.
-		AVPacket pkt;
-		av_init_packet(&pkt);
-
-		pkt.flags |= AV_PKT_FLAG_KEY;
-		pkt.stream_index= video_st->index;
-		pkt.data= (uint8_t*)frame_final->data;
-		pkt.size= sizeof(AVPicture);
-
-		// Increment PTS (in frames and scaled to the codec's timebase)
-		write_video_count += av_rescale_q(1, (AVRational){info.fps.den, info.fps.num}, video_codec->time_base);
-		pkt.pts = write_video_count;
-
-		/* write the compressed frame in the media file */
-		int error_code = av_interleaved_write_frame(oc, &pkt);
-		if (error_code < 0)
-		{
-			ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet ERROR [" + (string)av_err2str(error_code) + "]", "error_code", error_code, "", -1, "", -1, "", -1, "", -1, "", -1);
-			return false;
-		}
-
-		// Deallocate packet
-		AV_FREE_PACKET(&pkt);
-
-	} else {
+	ZmqLogger::Instance()->AppendDebugMethod("FFmpegWriter::write_video_packet", "frame->number", frame->number, "", -1, "", -1, "", -1, "", -1, "", -1);
 
 		AVPacket pkt;
 		av_init_packet(&pkt);
@@ -1577,7 +1540,6 @@ bool FFmpegWriter::write_video_packet(st
 
 		// Deallocate packet
 		AV_FREE_PACKET(&pkt);
-	}
 
 	// Success
 	return true;
--- a/src/FFmpegReader.cpp
+++ b/src/FFmpegReader.cpp
@@ -903,7 +903,7 @@ void FFmpegReader::ProcessAudioPacket(in
 	int data_size = 0;
 
 	// re-initialize buffer size (it gets changed in the avcodec_decode_audio2 method call)
-	int buf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE;
+	int buf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE + AV_INPUT_BUFFER_PADDING_SIZE;
 	int used = avcodec_decode_audio4(aCodecCtx, audio_frame, &frame_finished, packet);
 
 	if (frame_finished) {
@@ -976,7 +976,7 @@ void FFmpegReader::ProcessAudioPacket(in
 
 
 	// Allocate audio buffer
-	int16_t *audio_buf = new int16_t[AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
+	int16_t *audio_buf = new int16_t[AVCODEC_MAX_AUDIO_FRAME_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
 
 	ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::ProcessAudioPacket (ReSample)", "packet_samples", packet_samples, "info.channels", info.channels, "info.sample_rate", info.sample_rate, "aCodecCtx->sample_fmt", aCodecCtx->sample_fmt, "AV_SAMPLE_FMT_S16", AV_SAMPLE_FMT_S16, "", -1);
 

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to