summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-04-29 02:49:49 +0200
committerJan Ekström <jeebjp@gmail.com>2018-05-03 01:08:44 +0300
commit60dade104033f04fdd64f400d3f6707cf16d0ed7 (patch)
tree51657e382173b5a88309a087c704112db9d4380b /common
parente51cf79181b150d031f88683368f39c1b665aad1 (diff)
downloadmpv-60dade104033f04fdd64f400d3f6707cf16d0ed7.tar.bz2
mpv-60dade104033f04fdd64f400d3f6707cf16d0ed7.tar.xz
encode: restore 2-pass mode
While I'm not sure whether it really works, at least it writes the pass1 log correctly now. How 2-pass stat output is supposed to interact with the new decode API is rather fishy. ffmpeg.c does the same, and before this change, the log was not written on EOF (when at least libvpx actually outputs its stats).
Diffstat (limited to 'common')
-rw-r--r--common/encode_lavc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/common/encode_lavc.c b/common/encode_lavc.c
index 6f8378ac7f..5d34af609b 100644
--- a/common/encode_lavc.c
+++ b/common/encode_lavc.c
@@ -820,6 +820,7 @@ static void encoder_2pass_prepare(struct encoder_context *p)
stream_type_name(p->type));
if (p->encoder->flags & AV_CODEC_FLAG_PASS2) {
+ MP_INFO(p, "Reading 2-pass log: %s\n", filename);
struct stream *s = stream_open(filename, p->global);
if (s) {
struct bstr content = stream_read_complete(s, p, 1000000000);
@@ -838,6 +839,7 @@ static void encoder_2pass_prepare(struct encoder_context *p)
}
if (p->encoder->flags & AV_CODEC_FLAG_PASS1) {
+ MP_INFO(p, "Writing to 2-pass log: %s\n", filename);
p->twopass_bytebuffer = open_output_stream(filename, p->global);
if (!p->twopass_bytebuffer) {
MP_WARN(p, "could not open '%s', "
@@ -927,9 +929,9 @@ bool encoder_encode(struct encoder_context *p, AVFrame *frame)
av_init_packet(&packet);
status = avcodec_receive_packet(p->encoder, &packet);
- if (status == AVERROR(EAGAIN) || status == AVERROR_EOF)
+ if (status == AVERROR(EAGAIN))
break;
- if (status < 0)
+ if (status < 0 && status != AVERROR_EOF)
goto fail;
if (p->twopass_bytebuffer && p->encoder->stats_out) {
@@ -937,6 +939,9 @@ bool encoder_encode(struct encoder_context *p, AVFrame *frame)
strlen(p->encoder->stats_out));
}
+ if (status == AVERROR_EOF)
+ break;
+
encode_lavc_add_packet(p->mux_stream, &packet);
av_packet_unref(&packet);
}