Lines 1-5
Link Here
|
1 |
--- src/ui/gtk/ffmpeg.cc.orig 2010-03-07 20:50:23.000000000 +0100 |
1 |
--- src/ui/gtk/ffmpeg.cc.orig 2010-03-07 19:50:23 UTC |
2 |
+++ src/ui/gtk/ffmpeg.cc 2015-07-03 22:59:12.842256554 +0200 |
2 |
+++ src/ui/gtk/ffmpeg.cc |
3 |
@@ -48,7 +48,7 @@ FfmpegVideoEncoder::init(const char *fil |
3 |
@@ -48,7 +48,7 @@ FfmpegVideoEncoder::init(const char *fil |
4 |
|
4 |
|
5 |
av_register_all(); |
5 |
av_register_all(); |
Lines 27-33
Link Here
|
27 |
_stream->codec->codec_tag = MKTAG('D', 'X', '5', '0'); |
27 |
_stream->codec->codec_tag = MKTAG('D', 'X', '5', '0'); |
28 |
|
28 |
|
29 |
_stream->codec->bit_rate = 79000 + 1000 * pow(1.4, quality * 20.0); |
29 |
_stream->codec->bit_rate = 79000 + 1000 * pow(1.4, quality * 20.0); |
30 |
@@ -81,14 +82,8 @@ FfmpegVideoEncoder::init(const char *fil |
30 |
@@ -75,20 +76,14 @@ FfmpegVideoEncoder::init(const char *fil |
|
|
31 |
_stream->codec->time_base.den = 50; |
32 |
_stream->codec->time_base.num = fps_den; |
33 |
_stream->codec->gop_size = 100 / fps_den; |
34 |
- _stream->codec->pix_fmt = PIX_FMT_YUV420P; |
35 |
+ _stream->codec->pix_fmt = AV_PIX_FMT_YUV420P; |
36 |
|
37 |
// some formats want stream headers to be separate |
31 |
if (_context->oformat->flags & AVFMT_GLOBALHEADER) |
38 |
if (_context->oformat->flags & AVFMT_GLOBALHEADER) |
32 |
_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; |
39 |
_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; |
33 |
|
40 |
|
Lines 43-48
Link Here
|
43 |
{ |
50 |
{ |
44 |
close(); |
51 |
close(); |
45 |
return false; |
52 |
return false; |
|
|
53 |
@@ -102,7 +97,7 @@ FfmpegVideoEncoder::init(const char *fil |
54 |
return false; |
55 |
} |
56 |
|
57 |
- _frame = avcodec_alloc_frame(); |
58 |
+ _frame = av_frame_alloc(); |
59 |
if (_frame == NULL) |
60 |
{ |
61 |
close(); |
46 |
@@ -119,14 +114,14 @@ FfmpegVideoEncoder::init(const char *fil |
62 |
@@ -119,14 +114,14 @@ FfmpegVideoEncoder::init(const char *fil |
47 |
|
63 |
|
48 |
avpicture_fill((AVPicture *) _frame, buf, _stream->codec->pix_fmt, width, height); |
64 |
avpicture_fill((AVPicture *) _frame, buf, _stream->codec->pix_fmt, width, height); |
Lines 60-75
Link Here
|
60 |
return true; |
76 |
return true; |
61 |
} |
77 |
} |
62 |
|
78 |
|
63 |
@@ -171,7 +166,7 @@ FfmpegVideoEncoder::encode(byte_t *image |
79 |
@@ -161,20 +156,21 @@ FfmpegVideoEncoder::encode(byte_t *image |
|
|
80 |
} |
81 |
} |
82 |
|
83 |
- int out_size = avcodec_encode_video(_stream->codec, _buf, _bufsize, _frame); |
84 |
- if (out_size == 0) |
85 |
- return true; |
86 |
- |
87 |
AVPacket pkt; |
88 |
av_init_packet(&pkt); |
89 |
+ pkt.data = _buf; |
90 |
+ pkt.size = _bufsize; |
91 |
+ |
92 |
+ int got_packet = 0; |
93 |
+ int ret = avcodec_encode_video2(_stream->codec, &pkt, _frame, &got_packet); |
94 |
+ if (ret < 0 || !got_packet || pkt.size <= 0) |
95 |
+ return true; |
96 |
|
64 |
if (_stream->codec->coded_frame->pts != AV_NOPTS_VALUE) |
97 |
if (_stream->codec->coded_frame->pts != AV_NOPTS_VALUE) |
65 |
pkt.pts = av_rescale_q(_stream->codec->coded_frame->pts, _stream->codec->time_base, _stream->time_base); |
98 |
pkt.pts = av_rescale_q(_stream->codec->coded_frame->pts, _stream->codec->time_base, _stream->time_base); |
66 |
if (_stream->codec->coded_frame->key_frame) |
99 |
if (_stream->codec->coded_frame->key_frame) |
67 |
- pkt.flags |= PKT_FLAG_KEY; |
100 |
- pkt.flags |= PKT_FLAG_KEY; |
68 |
+ pkt.flags |= AV_PKT_FLAG_KEY; |
101 |
+ pkt.flags |= AV_PKT_FLAG_KEY; |
69 |
pkt.stream_index = _stream->index; |
102 |
pkt.stream_index = _stream->index; |
70 |
pkt.data = _buf; |
103 |
- pkt.data = _buf; |
71 |
pkt.size = out_size; |
104 |
- pkt.size = out_size; |
72 |
@@ -197,7 +192,7 @@ FfmpegVideoEncoder::close(void) |
105 |
|
|
|
106 |
return av_interleaved_write_frame(_context, &pkt) == 0; |
107 |
} |
108 |
@@ -197,7 +193,7 @@ FfmpegVideoEncoder::close(void) |
73 |
av_freep(&_context->streams[i]->codec); |
109 |
av_freep(&_context->streams[i]->codec); |
74 |
av_freep(&_context->streams[i]); |
110 |
av_freep(&_context->streams[i]); |
75 |
} |
111 |
} |
Lines 78-84
Link Here
|
78 |
|
114 |
|
79 |
av_free(_context); |
115 |
av_free(_context); |
80 |
|
116 |
|
81 |
@@ -207,4 +202,4 @@ FfmpegVideoEncoder::close(void) |
117 |
@@ -207,4 +203,4 @@ FfmpegVideoEncoder::close(void) |
82 |
_buf = NULL; |
118 |
_buf = NULL; |
83 |
} |
119 |
} |
84 |
|
120 |
|