[Qemu-devel] [PATCH] Video and sound capture to a videofile through ffmpeg

Alex K posted 1 patch 6 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1493894491-26130-1-git-send-email-vip-ak47@yandex.ru
Test checkpatch passed
Test docker failed
Test s390x failed
configure                          |  20 +
default-configs/i386-softmmu.mak   |   1 +
default-configs/x86_64-softmmu.mak |   1 +
hmp-commands.hx                    |  34 ++
hmp.h                              |   2 +
hw/display/Makefile.objs           |   2 +
hw/display/capture.c               | 761 +++++++++++++++++++++++++++++++++++++
hw/display/capture.h               |  78 ++++
8 files changed, 899 insertions(+)
create mode 100644 hw/display/capture.c
create mode 100644 hw/display/capture.h
[Qemu-devel] [PATCH] Video and sound capture to a videofile through ffmpeg
Posted by Alex K 6 years, 11 months ago
Hello everyone,

I've made a patch that adds ability to record video of what's going on
inside qemu. It uses ffmpeg libraries. Basically, the patch adds
2 new commands to the console:
capture_start path framerate
capture_stop

path is required
framerate could be 24, 25, 30 or 60. Default is 60
video codec is always h264

The patch uses ffmpeg so you will need to install these packages:
ffmpeg libavformat-dev libavcodec-dev libavutil-dev libswscale-dev

This is my first time posting here, so please correct me if I'm doing
something wrong

Signed-off-by: Alex K <vip-ak47@yandex.ru>
---
 configure                          |  20 +
 default-configs/i386-softmmu.mak   |   1 +
 default-configs/x86_64-softmmu.mak |   1 +
 hmp-commands.hx                    |  34 ++
 hmp.h                              |   2 +
 hw/display/Makefile.objs           |   2 +
 hw/display/capture.c               | 761 +++++++++++++++++++++++++++++++++++++
 hw/display/capture.h               |  78 ++++
 8 files changed, 899 insertions(+)
 create mode 100644 hw/display/capture.c
 create mode 100644 hw/display/capture.h

diff --git a/configure b/configure
index 48a9370..a6ddbf0 100755
--- a/configure
+++ b/configure
@@ -281,6 +281,7 @@ opengl=""
 opengl_dmabuf="no"
 avx2_opt="no"
 zlib="yes"
+libav="yes"
 lzo=""
 snappy=""
 bzip2=""
@@ -1993,6 +1994,25 @@ if test "$seccomp" != "no" ; then
         seccomp="no"
     fi
 fi
+#########################################
+# libav check
+
+if test "$libav" != "no" ; then
+    cat > $TMPC << EOF
+#include <libavcodec/avcodec.h>
+#include <libavformat/avformat.h>
+
+int main(void){ av_register_all(); avcodec_register_all(); return 0; }
+EOF
+    if compile_prog "" "-lm -lpthread -lavformat -lavcodec -lavutil -lswscale -lswresample" ; then
+        :
+    else
+        error_exit "libav check failed" \
+            "Make sure to have the libav libs and headers installed."
+    fi
+fi
+LIBS="$LIBS -lm -lpthread -lavformat -lavcodec -lavutil -lswscale -lswresample"
+
 ##########################################
 # xen probe
 
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index d2ab2f6..35ce513 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -59,3 +59,4 @@ CONFIG_SMBIOS=y
 CONFIG_HYPERV_TESTDEV=$(CONFIG_KVM)
 CONFIG_PXB=y
 CONFIG_ACPI_VMGENID=y
+CONFIG_CAPTURE=y
diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
index 9bde2f1..b9a7175 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -59,3 +59,4 @@ CONFIG_SMBIOS=y
 CONFIG_HYPERV_TESTDEV=$(CONFIG_KVM)
 CONFIG_PXB=y
 CONFIG_ACPI_VMGENID=y
+CONFIG_CAPTURE=y
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 0aca984..9066aac 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1809,3 +1809,37 @@ ETEXI
 STEXI
 @end table
 ETEXI
+
+    {
+        .name       = "capture_start",
+        .args_type  = "filename:F,fps:i?",
+        .params     = "filename [framerate]",
+        .help       = "Start video capture",
+        .cmd        = hmp_capture_start,
+    },
+
+STEXI
+@item capture_start @var{filename} [@var{framerate}]
+@findex capture_start
+Start video capture.
+Capture video into @var{filename} with framerate @var{framerate}.
+
+Defaults:
+@itemize @minus
+@item framerate = 60
+@end itemize
+ETEXI
+
+    {
+        .name       = "capture_stop",
+        .args_type  = "",
+        .params     = "",
+        .help       = "Stop video capture",
+        .cmd        = hmp_capture_stop,
+    },
+
+STEXI
+@item capture_stop
+@findex capture_stop
+Stop video capture.
+ETEXI
diff --git a/hmp.h b/hmp.h
index 799fd37..36c7a4d 100644
--- a/hmp.h
+++ b/hmp.h
@@ -138,5 +138,7 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict);
 void hmp_info_dump(Monitor *mon, const QDict *qdict);
 void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict);
 void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict);
+void hmp_capture_start(Monitor *mon, const QDict *qdict);
+void hmp_capture_stop(Monitor *mon, const QDict *qdict);
 
 #endif
diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
index 551c050..a918896 100644
--- a/hw/display/Makefile.objs
+++ b/hw/display/Makefile.objs
@@ -20,6 +20,8 @@ common-obj-$(CONFIG_ZAURUS) += tc6393xb.o
 
 common-obj-$(CONFIG_MILKYMIST_TMU2) += milkymist-tmu2.o
 
+obj-$(CONFIG_CAPTURE) += capture.o
+
 obj-$(CONFIG_OMAP) += omap_dss.o
 obj-$(CONFIG_OMAP) += omap_lcdc.o
 obj-$(CONFIG_PXA2XX) += pxa2xx_lcd.o
diff --git a/hw/display/capture.c b/hw/display/capture.c
new file mode 100644
index 0000000..c89aaa0
--- /dev/null
+++ b/hw/display/capture.c
@@ -0,0 +1,761 @@
+#include "capture.h"
+
+static void sound_capture_notify(void *opaque, audcnotification_e cmd)
+{
+    (void) opaque;
+    (void) cmd;
+}
+
+static void sound_capture_destroy(void *opaque)
+{
+    (void) opaque;
+}
+
+static void write_empty_sound(void *opaque, struct CaptureThreadWorkerData *data)
+{
+    AVFormatContext *oc = data->oc;
+    OutputStream *ost = &data->audio_stream;
+
+    AVFrame *tmp = ost->tmp_frame;
+    ost->tmp_frame = ost->empty_frame;
+    double newlen = write_audio_frame(oc, ost);
+    ost->tmp_frame = tmp;
+
+    if (newlen >= 0.0) {
+        data->video_len = newlen;
+    }
+}
+
+static void sound_capture_capture(void *opaque, void *buf, int size)
+{
+    int bufsize = size;
+    SoundCapture *wav = opaque;
+    AVFrame *frame;
+    int sampleCount;
+    double len1, len2, delta;
+    int8_t *q;
+    int buffpos;
+
+    /*int32_t n = 0;
+    int i = 0;
+    for(i=0;i<size;i++) {
+        int8_t a = ((int8_t*)buf)[i];
+        n+=a;
+    }
+    wav->bytes += size;
+    if(n==0)
+        return;
+    printf("%d\n",n);*/
+    frame = wav->data->audio_stream.tmp_frame;
+    sampleCount = frame->nb_samples * 4;
+
+    len1 = wav->data->video_len;
+    len2 = wav->data->video_len2;
+    delta = len1 - len2;
+
+    while (delta < 0.0) {
+        write_empty_sound(opaque, wav->data);
+
+        len1 = wav->data->video_len;
+        len2 = wav->data->video_len2;
+        delta = len1 - len2;
+    }
+
+    q = (int8_t *)frame->data[0];
+
+    buffpos = 0;
+    while (bufsize > 0) {
+        int start = wav->bufferPos;
+        int freeSpace = sampleCount - start;
+
+        int willWrite = freeSpace;
+        if (willWrite > bufsize) {
+            willWrite = bufsize;
+        }
+
+        memcpy(q + start, buf + buffpos, willWrite);
+        bufsize -= willWrite;
+        buffpos += willWrite;
+
+        freeSpace = sampleCount - start - willWrite;
+
+        if (freeSpace == 0) {
+            double newlen = write_audio_frame(wav->data->oc, &wav->data->audio_stream);
+
+            if (newlen >= 0.0) {
+                wav->data->video_len = newlen;
+            }
+            wav->bufferPos = 0;
+        } else {
+            wav->bufferPos = start + willWrite;
+        }
+    }
+}
+
+static void sound_capture_capture_destroy(void *opaque)
+{
+    SoundCapture *wav = opaque;
+
+    AUD_del_capture (wav->cap, wav);
+}
+
+static int sound_capture_start_capture(struct CaptureThreadWorkerData *data)
+{
+    Monitor *mon = cur_mon;
+    SoundCapture *wav;
+    struct audsettings as;
+    struct audio_capture_ops ops;
+    CaptureVoiceOut *cap;
+
+    as.freq = 44100;
+    as.nchannels = 2;
+    as.fmt = AUD_FMT_S16;
+    as.endianness = 0;
+
+    ops.notify = sound_capture_notify;
+    ops.capture = sound_capture_capture;
+    ops.destroy = sound_capture_destroy;
+
+    wav = g_malloc0(sizeof(*wav));
+
+
+    cap = AUD_add_capture(&as, &ops, wav);
+    if (!cap) {
+        monitor_printf(mon, "Failed to add audio capture\n");
+        goto error_free;
+    }
+
+    wav->bufferPos = 0;
+    wav->data = data;
+    wav->cap = cap;
+    data->soundCapture = wav;
+    return 0;
+
+error_free:
+    g_free(wav);
+    return -1;
+}
+
+static int write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base,
+                        AVStream *st, AVPacket *pkt)
+{
+    /* rescale output packet timestamp values from codec to stream timebase */
+    av_packet_rescale_ts(pkt, *time_base, st->time_base);
+    pkt->stream_index = st->index;
+    /* Write the compressed frame to the media file. */
+    return av_interleaved_write_frame(fmt_ctx, pkt);
+}
+
+/* Add an output stream. */
+static void add_video_stream(OutputStream *ost, AVFormatContext *oc,
+                       AVCodec **codec,
+                       enum AVCodecID codec_id,
+                       int w, int h, int bit_rate, int framerate)
+{
+    AVCodecContext *c;
+    /* find the encoder */
+    *codec = avcodec_find_encoder(codec_id);
+    if (!(*codec)) {
+        fprintf(stderr, "Could not find encoder for '%s'\n",
+                avcodec_get_name(codec_id));
+        exit(1);
+    }
+    ost->st = avformat_new_stream(oc, *codec);
+    if (!ost->st) {
+        fprintf(stderr, "Could not allocate stream\n");
+        exit(1);
+    }
+    ost->st->id = oc->nb_streams - 1;
+    c = ost->st->codec;
+    if ((*codec)->type == AVMEDIA_TYPE_VIDEO) {
+        c->codec_id = codec_id;
+        c->bit_rate = bit_rate;
+        /* Resolution must be a multiple of two. */
+        c->width    = w;
+        c->height   = h;
+        /* timebase: This is the fundamental unit of time (in seconds) in terms
+         * of which frame timestamps are represented. For fixed-fps content,
+         * timebase should be 1/framerate and timestamp increments should be
+         * identical to 1. */
+        ost->st->time_base = (AVRational){ 1, framerate };
+        c->time_base = ost->st->time_base;
+        c->gop_size  = 12; /* emit one intra frame every 12 frames at most */
+        c->pix_fmt   = AV_PIX_FMT_YUV420P;
+        if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+            /* just for testing, we also add B frames */
+            c->max_b_frames = 2;
+        }
+        if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
+            /* Needed to avoid using macroblocks in which some coeffs overflow.
+             * This does not happen with normal video, it just happens here as
+             * the motion of the chroma plane does not match the luma plane. */
+            c->mb_decision = 2;
+        }
+    } else {
+        fprintf(stderr, "Wrong stream type\n");
+        exit(1);
+    }
+    /* Some formats want stream headers to be separate. */
+    if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
+        c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
+    }
+}
+
+static void add_audio_stream(OutputStream *ost, AVFormatContext *oc,
+                             AVCodec **codec,
+                             enum AVCodecID codec_id)
+{
+    AVCodecContext *c;
+    int i;
+    /* find the encoder */
+    *codec = avcodec_find_encoder(codec_id);
+    if (!(*codec)) {
+        fprintf(stderr, "Could not find encoder for '%s'\n",
+                avcodec_get_name(codec_id));
+        exit(1);
+    }
+    ost->st = avformat_new_stream(oc, *codec);
+    if (!ost->st) {
+        fprintf(stderr, "Could not allocate stream\n");
+        exit(1);
+    }
+    ost->st->id = oc->nb_streams - 1;
+    c = ost->st->codec;
+    if ((*codec)->type == AVMEDIA_TYPE_AUDIO) {
+        c->sample_fmt = AV_SAMPLE_FMT_FLTP;
+        c->bit_rate    = 128000;
+        c->sample_rate = 44100;
+        c->channels    = av_get_channel_layout_nb_channels(c->channel_layout);
+        c->channel_layout = AV_CH_LAYOUT_STEREO;
+        if ((*codec)->channel_layouts) {
+            c->channel_layout = (*codec)->channel_layouts[0];
+            for (i = 0; (*codec)->channel_layouts[i]; i++) {
+                if ((*codec)->channel_layouts[i] == AV_CH_LAYOUT_STEREO) {
+                    c->channel_layout = AV_CH_LAYOUT_STEREO;
+                }
+            }
+        }
+        c->channels   = av_get_channel_layout_nb_channels(c->channel_layout);
+        ost->st->time_base = (AVRational){ 1, c->sample_rate };
+    } else {
+        fprintf(stderr, "Wrong stream type\n");
+        exit(1);
+    }
+    /* Some formats want stream headers to be separate. */
+    if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
+        c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
+    }
+}
+/**************************************************************/
+/* audio output */
+static AVFrame *alloc_audio_frame(enum AVSampleFormat sample_fmt,
+                                  uint64_t channel_layout,
+                                  int sample_rate, int nb_samples)
+{
+    AVFrame *frame = av_frame_alloc();
+    int ret;
+    if (!frame) {
+        fprintf(stderr, "Error allocating an audio frame\n");
+        exit(1);
+    }
+    frame->format = sample_fmt;
+    frame->channel_layout = channel_layout;
+    frame->sample_rate = sample_rate;
+    frame->nb_samples = nb_samples;
+    if (nb_samples) {
+        ret = av_frame_get_buffer(frame, 0);
+        if (ret < 0) {
+            fprintf(stderr, "Error allocating an audio buffer\n");
+            exit(1);
+        }
+    }
+    return frame;
+}
+
+static void open_audio(AVFormatContext *oc, AVCodec *codec,
+                       OutputStream *ost, AVDictionary *opt_arg)
+{
+    AVCodecContext *c;
+    int nb_samples;
+    int ret;
+    AVDictionary *opt = NULL;
+    c = ost->st->codec;
+    /* open it */
+    av_dict_copy(&opt, opt_arg, 0);
+    ret = avcodec_open2(c, codec, &opt);
+    av_dict_free(&opt);
+    if (ret < 0) {
+        fprintf(stderr, "Could not open audio codec: %s\n", av_err2str(ret));
+        exit(1);
+    }
+    nb_samples = c->frame_size;
+    ost->frame     = alloc_audio_frame(c->sample_fmt, c->channel_layout,
+                                       c->sample_rate, nb_samples);
+
+    ost->tmp_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, c->channel_layout,
+                                       c->sample_rate, nb_samples);
+    ost->tmp_frame->pts = 0;
+
+    ost->empty_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, c->channel_layout,
+                                       c->sample_rate, nb_samples);
+    int sampleCount = nb_samples * 4;
+    int8_t *q = (int8_t *)ost->empty_frame->data[0];
+    memset(q, 0, sampleCount);
+
+    /* create resampler context */
+    ost->swr_ctx = swr_alloc();
+    if (!ost->swr_ctx) {
+        fprintf(stderr, "Could not allocate resampler context\n");
+        exit(1);
+    }
+    /* set options */
+    av_opt_set_int       (ost->swr_ctx, "in_channel_count",  c->channels,       0);
+    av_opt_set_int       (ost->swr_ctx, "in_sample_rate",    c->sample_rate,    0);
+    av_opt_set_sample_fmt(ost->swr_ctx, "in_sample_fmt",     AV_SAMPLE_FMT_S16, 0);
+    av_opt_set_int       (ost->swr_ctx, "out_channel_count", c->channels,       0);
+    av_opt_set_int       (ost->swr_ctx, "out_sample_rate",   c->sample_rate,    0);
+    av_opt_set_sample_fmt(ost->swr_ctx, "out_sample_fmt",    c->sample_fmt,     0);
+    /* initialize the resampling context */
+    if (swr_init(ost->swr_ctx) < 0) {
+        fprintf(stderr, "Failed to initialize the resampling context\n");
+        exit(1);
+    }
+}
+
+/*
+ * encode one audio frame and send it to the muxer
+ */
+static double write_audio_frame(AVFormatContext *oc, OutputStream *ost)
+{
+    AVCodecContext *c;
+    AVPacket pkt = { 0 };
+    AVFrame *frame;
+    int ret;
+    int got_packet;
+    int dst_nb_samples;
+    av_init_packet(&pkt);
+    c = ost->st->codec;
+    frame = ost->tmp_frame;
+    frame->pts = frame->pts + 1;
+    double videolen = -1.0;
+    if (frame) {
+        /* convert samples from native format to destination codec format,
+         * using the resampler */
+        /* compute destination number of samples */
+        dst_nb_samples = av_rescale_rnd(
+            swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples,
+            c->sample_rate, c->sample_rate, AV_ROUND_UP);
+        av_assert0(dst_nb_samples == frame->nb_samples);
+        /* when we pass a frame to the encoder, it may keep a reference to it
+         * internally;
+         * make sure we do not overwrite it here
+         */
+        ret = av_frame_make_writable(ost->frame);
+        if (ret < 0) {
+            exit(1);
+        }
+        /* convert to destination format */
+        ret = swr_convert(ost->swr_ctx,
+                          ost->frame->data, dst_nb_samples,
+                          (const uint8_t **)frame->data, frame->nb_samples);
+        if (ret < 0) {
+            fprintf(stderr, "Error while converting\n");
+            exit(1);
+        }
+        frame = ost->frame;
+        frame->pts = av_rescale_q(ost->samples_count,
+                                  (AVRational){1, c->sample_rate},
+                                  c->time_base);
+
+        videolen = (double)frame->pts / c->sample_rate;
+        ost->samples_count += dst_nb_samples;
+    }
+    ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet);
+    if (ret < 0) {
+        fprintf(stderr, "Error encoding audio frame: %s\n", av_err2str(ret));
+        exit(1);
+    }
+    if (got_packet) {
+        ret = write_frame(oc, &c->time_base, ost->st, &pkt);
+        if (ret < 0) {
+            fprintf(stderr, "Error while writing audio frame: %s\n",
+                    av_err2str(ret));
+            exit(1);
+        }
+    }
+    return videolen;
+}
+static void write_delayed_audio_frames(void)
+{
+    struct CaptureThreadWorkerData *data = capture_get_data();
+    AVFormatContext *oc = data->oc;
+    OutputStream *ost = &data->audio_stream;
+    AVCodecContext *c = ost->st->codec;
+
+    AVPacket pkt = { 0 };
+    pkt.data = NULL;
+    pkt.size = 0;
+    av_init_packet(&pkt);
+    int got_output = 1;
+    int ret;
+    while (got_output) {
+
+        ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);
+        if (ret < 0) {
+            fprintf(stderr, "Error encoding frame\n");
+            exit(1);
+        }
+
+        if (got_output) {
+            ret = write_frame(oc, &c->time_base, ost->st, &pkt);
+            av_free_packet(&pkt);
+        }
+    }
+}
+/**************************************************************/
+/* video output */
+static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height)
+{
+    AVFrame *picture;
+    int ret;
+    picture = av_frame_alloc();
+    if (!picture) {
+        return NULL;
+    }
+    picture->format = pix_fmt;
+    picture->width  = width;
+    picture->height = height;
+    /* allocate the buffers for the frame data */
+    ret = av_frame_get_buffer(picture, 32);
+    if (ret < 0) {
+        fprintf(stderr, "Could not allocate frame data.\n");
+        exit(1);
+    }
+    return picture;
+}
+
+static void open_video(AVFormatContext *oc, AVCodec *codec,
+                       OutputStream *ost, AVDictionary *opt_arg)
+{
+    int ret;
+    AVCodecContext *c = ost->st->codec;
+    AVDictionary *opt = NULL;
+    av_dict_copy(&opt, opt_arg, 0);
+    /* open the codec */
+    ret = avcodec_open2(c, codec, &opt);
+    av_dict_free(&opt);
+    if (ret < 0) {
+        fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));
+        exit(1);
+    }
+    /* allocate and init a re-usable frame */
+    ost->frame = alloc_picture(c->pix_fmt, c->width, c->height);
+    if (!ost->frame) {
+        fprintf(stderr, "Could not allocate video frame\n");
+        exit(1);
+    }
+}
+
+static AVFrame *get_filled_image(void)
+{
+    QemuConsole *con = qemu_console_lookup_by_index(0);
+    DisplaySurface *surface;
+    surface = qemu_console_surface(con);
+
+    if (con == NULL) {
+        fprintf(stderr, "There is no QemuConsole I can screendump from.\n");
+        return NULL;
+    }
+
+    int ourW = pixman_image_get_width(surface->image);
+    int ourH = pixman_image_get_height(surface->image);
+
+    AVFrame *pict = alloc_picture(AV_PIX_FMT_RGB32, ourW, ourH);
+    av_frame_make_writable(pict);
+
+    uint8_t* picdata = (uint8_t *)pixman_image_get_data(surface->image);
+
+    memcpy(pict->data[0], picdata, ourW * ourH * 4);
+    return pict;
+}
+
+static AVFrame *get_video_frame(OutputStream *ost, int64_t frame)
+{
+    AVCodecContext *c = ost->st->codec;
+
+    AVFrame *pict = get_filled_image();
+    if (pict == NULL) {
+        return NULL;
+    }
+
+    struct SwsContext *swsContext = sws_getContext(
+        pict->width, pict->height, pict->format,
+        ost->frame->width, ost->frame->height,
+        ost->frame->format, SWS_BICUBIC, NULL, NULL, NULL);
+    sws_scale(swsContext, (const uint8_t * const *)pict->data,
+              pict->linesize , 0, c->height, ost->frame->data,
+              ost->frame->linesize);
+
+    av_frame_free(&pict);
+    sws_freeContext(swsContext);
+
+    if (frame <= ost->frame->pts) {
+        ost->frame->pts = ost->frame->pts + 1;
+    } else {
+        ost->frame->pts = frame;
+    }
+
+    return ost->frame;
+}
+/*
+ * encode one video frame and send it to the muxer
+ */
+static void write_video_frame(AVFormatContext *oc,
+                              OutputStream *ost, int frameNumber)
+{
+    int ret;
+    AVCodecContext *c;
+    AVFrame *frame;
+    int got_packet = 0;
+    AVPacket pkt = { 0 };
+
+    frame = get_video_frame(ost, frameNumber);
+    if (frame == NULL) {
+        return;
+    }
+
+    c = ost->st->codec;
+    av_init_packet(&pkt);
+    /* encode the image */
+    ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
+    if (ret < 0) {
+        fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));
+        exit(1);
+    }
+    if (got_packet) {
+        ret = write_frame(oc, &c->time_base, ost->st, &pkt);
+    } else {
+        ret = 0;
+    }
+    if (ret < 0) {
+        fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret));
+        return;
+    }
+}
+
+static void write_delayed_video_frames(void)
+{
+    struct CaptureThreadWorkerData *data = capture_get_data();
+    AVFormatContext *oc = data->oc;
+    OutputStream *ost = &data->stream;
+    AVCodecContext *c = ost->st->codec;
+
+    AVPacket pkt = { 0 };
+    pkt.data = NULL;
+    pkt.size = 0;
+    av_init_packet(&pkt);
+    int got_output = 1;
+    int ret;
+    while (got_output) {
+        ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
+        if (ret < 0) {
+            fprintf(stderr, "Error encoding frame\n");
+            exit(1);
+        }
+
+        if (got_output) {
+            ret = write_frame(oc, &c->time_base, ost->st, &pkt);
+            av_free_packet(&pkt);
+        }
+    }
+}
+
+static void close_stream(AVFormatContext *oc, OutputStream *ost)
+{
+    avcodec_close(ost->st->codec);
+    av_frame_free(&ost->frame);
+    av_frame_free(&ost->tmp_frame);
+    sws_freeContext(ost->sws_ctx);
+    swr_free(&ost->swr_ctx);
+}
+
+static int ends_with(const char *str, const char *suffix)
+{
+    if (!str || !suffix) {
+        return 0;
+    }
+    size_t lenstr = strlen(str);
+    size_t lensuffix = strlen(suffix);
+    if (lensuffix >  lenstr) {
+        return 0;
+    }
+    return strncmp(str + lenstr - lensuffix, suffix, lensuffix) == 0;
+}
+
+static struct CaptureThreadWorkerData *capture_get_data(void)
+{
+    static struct CaptureThreadWorkerData data = {0};
+    return &data;
+}
+
+static void capture_timer(void *p)
+{
+    struct CaptureThreadWorkerData *data = (struct CaptureThreadWorkerData *)p;
+    if (!data->is_capturing) {
+        return;
+    }
+
+    int64_t n = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
+    int64_t intdelta = (n - data->time) / 100000;
+    double delta = (double)intdelta / 10000;
+    data->delta += delta;
+    data->time   = n;
+
+    while (data->delta > (1.0 / data->framerate)) {
+        data->delta -= 1.0 / data->framerate;
+
+        av_frame_make_writable(data->stream.frame);
+        write_video_frame(data->oc, &data->stream,
+            (int)(floor(data->video_len * (double)data->framerate + 0.5)));
+    }
+    data->video_len2 = data->video_len2 + delta;
+
+    int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
+    if (data->is_capturing) {
+        timer_mod_ns(data->timer, now + 10000000);
+    }
+}
+
+static void capture_powerdown_req(void)
+{
+    if (capture_stop()) {
+        printf("Capture stoped\n");
+    }
+}
+
+void hmp_capture_start(Monitor *mon, const QDict *qdict)
+{
+    const char *filename = qdict_get_str(qdict, "filename");
+    int framerate = qdict_get_try_int(qdict, "fps", 60);
+
+    struct CaptureThreadWorkerData *data = capture_get_data();
+    if (!data->is_loaded) {
+        av_register_all();
+        avcodec_register_all();
+        data->codec = avcodec_find_encoder(AV_CODEC_ID_H264);
+        if (!data->codec) {
+            fprintf(stderr, "codec not found\n");
+            return;
+        }
+        data->c = NULL;
+        data->is_loaded = 1;
+        atexit(capture_powerdown_req);
+    }
+
+    if (data->is_capturing == 0) {
+        if (!ends_with(filename, ".mp4")
+         && !ends_with(filename, ".mpg")
+         && !ends_with(filename, ".avi")) {
+            monitor_printf(mon, "Invalid file format, use .mp4 or .mpg\n");
+            return;
+        }
+        if (framerate != 60 && framerate != 30
+         && framerate != 24 && framerate != 25) {
+            monitor_printf(mon, "Invalid framerate, valid values are: 24, 25, 30, 60\n");
+            return;
+        }
+        monitor_printf(mon, "Capture started to file: %s\n", filename);
+
+        data->framerate = framerate;
+        data->frame = 0;
+
+        data->delta = 0.0;
+        data->time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
+
+        data->video_len = 0.0;
+        data->video_len2 = 0.0;
+
+        QemuConsole *con = qemu_console_lookup_by_index(0);
+        DisplaySurface *surface;
+        surface = qemu_console_surface(con);
+        int resW = pixman_image_get_width(surface->image);
+        int resH = pixman_image_get_height(surface->image);
+
+        OutputStream video_st = { 0 };
+        data->stream = video_st;
+        OutputStream audio_st = { 0 };
+        data->audio_stream = audio_st;
+
+        avformat_alloc_output_context2(&data->oc, NULL, "avi", filename);
+        AVOutputFormat *fmt;
+        fmt = data->oc->oformat;
+
+        add_video_stream(&data->stream, data->oc, &data->codec,
+                         fmt->video_codec, resW, resH, 4000000, framerate);
+        add_audio_stream(&data->audio_stream, data->oc, &data->audio_codec,
+                         fmt->audio_codec);
+
+        open_video(data->oc, data->codec, &data->stream, NULL);
+        open_audio(data->oc, data->audio_codec, &data->audio_stream, NULL);
+
+        int ret = avio_open(&data->oc->pb, filename, AVIO_FLAG_WRITE);
+        if (ret < 0) {
+            fprintf(stderr, "Could not open '%s': %s\n", filename,
+                    av_err2str(ret));
+            return;
+        }
+        ret = avformat_write_header(data->oc, NULL);
+        if (ret < 0) {
+            fprintf(stderr, "Error occurred when opening output file: %s\n",
+                    av_err2str(ret));
+            return;
+        }
+
+        data->is_capturing = 1;
+
+        if (data->timer) {
+            timer_free(data->timer);
+        }
+        data->timer = timer_new_ns(QEMU_CLOCK_REALTIME, capture_timer, data);
+        int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
+        timer_mod_ns(data->timer, now + 1000000000 / data->framerate);
+
+        sound_capture_start_capture(data);
+    } else {
+        monitor_printf(mon, "Already capturing\n");
+    }
+}
+
+static int capture_stop(void)
+{
+    struct CaptureThreadWorkerData *data = capture_get_data();
+    if (!data->is_loaded) {
+        return 0;
+    }
+
+    if (data->is_capturing) {
+        data->is_capturing = 0;
+
+        write_delayed_video_frames();
+        write_delayed_audio_frames();
+
+        av_write_trailer(data->oc);
+        close_stream(data->oc, &data->stream);
+        close_stream(data->oc, &data->audio_stream);
+        avio_closep(&data->oc->pb);
+        avformat_free_context(data->oc);
+
+        sound_capture_capture_destroy(data->soundCapture);
+        return 1;
+    }
+    return 0;
+}
+
+void hmp_capture_stop(Monitor *mon, const QDict *qdict)
+{
+    if (capture_stop()) {
+        monitor_printf(mon, "Capture stopped\n");
+    } else {
+        monitor_printf(mon, "Not capturing\n");
+    }
+}
diff --git a/hw/display/capture.h b/hw/display/capture.h
new file mode 100644
index 0000000..73c79f1
--- /dev/null
+++ b/hw/display/capture.h
@@ -0,0 +1,78 @@
+#ifndef CAPTURE_H
+#define CAPTURE_H
+
+#include "qemu/osdep.h"
+#include "monitor/monitor.h"
+#include "ui/console.h"
+#include "qemu/timer.h"
+#include "audio/audio.h"
+
+#include <libavcodec/avcodec.h>
+#include <libavformat/avformat.h>
+#include "libavutil/frame.h"
+#include "libavutil/imgutils.h"
+#include <libswscale/swscale.h>
+#include <libavutil/avassert.h>
+#include <libavutil/channel_layout.h>
+#include <libavutil/opt.h>
+#include <libavutil/mathematics.h>
+#include <libavutil/timestamp.h>
+#include <libswresample/swresample.h>
+
+void hmp_capture_start(Monitor *mon, const QDict *qdict);
+void hmp_capture_stop(Monitor *mon, const QDict *qdict);
+
+typedef struct OutputStream {
+    AVStream *st;
+    int samples_count;
+    AVFrame *frame;
+    AVFrame *tmp_frame;
+    AVFrame *empty_frame;
+    struct SwsContext *sws_ctx;
+    struct SwrContext *swr_ctx;
+} OutputStream;
+
+struct CaptureThreadWorkerData {
+    QEMUTimer *timer;
+    int frame;
+    int is_loaded;
+    int is_capturing;
+    int framerate;
+    double video_len;
+    double video_len2;
+    CaptureState *wavCapture;
+
+    AVCodec *codec;
+    AVCodecContext *c;
+
+    AVFrame *picture;
+    AVPacket pkt;
+
+    AVCodec *audio_codec;
+    OutputStream stream;
+    OutputStream audio_stream;
+    AVFormatContext *oc;
+
+    int64_t time;
+    double delta;
+
+    void *soundCapture;
+};
+
+typedef struct {
+    int bytes;
+    CaptureVoiceOut *cap;
+    struct CaptureThreadWorkerData *data;
+    int bufferPos;
+} SoundCapture;
+
+static int sound_capture_start_capture(struct CaptureThreadWorkerData *data);
+static int ends_with(const char *str, const char *suffix);
+static struct CaptureThreadWorkerData *capture_get_data(void);
+static void write_delayed_audio_frames(void);
+static void write_delayed_video_frames(void);
+static int capture_stop(void);
+static double write_audio_frame(AVFormatContext *oc, OutputStream *ost);
+static void write_empty_sound(void *opaque, struct CaptureThreadWorkerData* data);
+
+#endif
-- 
2.7.4


Re: [Qemu-devel] [PATCH] Video and sound capture to a videofile through ffmpeg
Posted by no-reply@patchew.org 6 years, 11 months ago
Hi,

This series failed build test on s390x host. Please find the details below.

Subject: [Qemu-devel] [PATCH] Video and sound capture to a videofile through ffmpeg
Message-id: 1493894491-26130-1-git-send-email-vip-ak47@yandex.ru
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
# Testing script will be invoked under the git checkout with
# HEAD pointing to a commit that has the patches applied on top of "base"
# branch
set -e
echo "=== ENV ==="
env
echo "=== PACKAGES ==="
rpm -qa
echo "=== TEST BEGIN ==="
CC=$HOME/bin/cc
INSTALL=$PWD/install
BUILD=$PWD/build
echo -n "Using CC: "
realpath $CC
mkdir -p $BUILD $INSTALL
SRC=$PWD
cd $BUILD
$SRC/configure --cc=$CC --prefix=$INSTALL
make -j4
# XXX: we need reliable clean up
# make check -j4 V=1
make install
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]      patchew/1493816238-33120-1-git-send-email-imammedo@redhat.com -> patchew/1493816238-33120-1-git-send-email-imammedo@redhat.com
 * [new tag]         patchew/1493894491-26130-1-git-send-email-vip-ak47@yandex.ru -> patchew/1493894491-26130-1-git-send-email-vip-ak47@yandex.ru
Switched to a new branch 'test'
827fcdc Video and sound capture to a videofile through ffmpeg

=== OUTPUT BEGIN ===
=== ENV ===
XDG_SESSION_ID=35327
SHELL=/bin/sh
USER=fam
PATCHEW=/home/fam/patchew/patchew-cli -s http://patchew.org --nodebug
PATH=/usr/bin:/bin
PWD=/var/tmp/patchew-tester-tmp-5k9gig5j/src
LANG=en_US.UTF-8
HOME=/home/fam
SHLVL=2
LOGNAME=fam
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1012/bus
XDG_RUNTIME_DIR=/run/user/1012
_=/usr/bin/env
=== PACKAGES ===
gpg-pubkey-873529b8-54e386ff
xz-libs-5.2.2-2.fc24.s390x
libxshmfence-1.2-3.fc24.s390x
giflib-4.1.6-15.fc24.s390x
trousers-lib-0.3.13-6.fc24.s390x
ncurses-base-6.0-6.20160709.fc25.noarch
gmp-6.1.1-1.fc25.s390x
libidn-1.33-1.fc25.s390x
slang-2.3.0-7.fc25.s390x
libsemanage-2.5-8.fc25.s390x
pkgconfig-0.29.1-1.fc25.s390x
alsa-lib-1.1.1-2.fc25.s390x
yum-metadata-parser-1.1.4-17.fc25.s390x
python3-slip-dbus-0.6.4-4.fc25.noarch
python2-cssselect-0.9.2-1.fc25.noarch
python-fedora-0.8.0-2.fc25.noarch
createrepo_c-libs-0.10.0-6.fc25.s390x
initscripts-9.69-1.fc25.s390x
wget-1.18-2.fc25.s390x
dhcp-client-4.3.5-1.fc25.s390x
parted-3.2-21.fc25.s390x
flex-2.6.0-3.fc25.s390x
colord-libs-1.3.4-1.fc25.s390x
python-osbs-client-0.33-3.fc25.noarch
perl-Pod-Simple-3.35-1.fc25.noarch
python2-simplejson-3.10.0-1.fc25.s390x
brltty-5.4-2.fc25.s390x
librados2-10.2.4-2.fc25.s390x
tcp_wrappers-7.6-83.fc25.s390x
libcephfs_jni1-10.2.4-2.fc25.s390x
nettle-devel-3.3-1.fc25.s390x
bzip2-devel-1.0.6-21.fc25.s390x
libuuid-2.28.2-2.fc25.s390x
mesa-libglapi-13.0.3-5.fc25.s390x
pcre-cpp-8.40-5.fc25.s390x
pango-1.40.4-1.fc25.s390x
python3-magic-5.29-3.fc25.noarch
python3-dnf-1.1.10-6.fc25.noarch
cryptsetup-libs-1.7.4-1.fc25.s390x
texlive-kpathsea-doc-svn41139-33.fc25.1.noarch
netpbm-10.77.00-3.fc25.s390x
openssh-7.4p1-4.fc25.s390x
kernel-headers-4.10.5-200.fc25.s390x
texlive-kpathsea-bin-svn40473-33.20160520.fc25.1.s390x
texlive-graphics-svn41015-33.fc25.1.noarch
texlive-dvipdfmx-def-svn40328-33.fc25.1.noarch
texlive-mfware-svn40768-33.fc25.1.noarch
texlive-texlive-scripts-svn41433-33.fc25.1.noarch
texlive-euro-svn22191.1.1-33.fc25.1.noarch
texlive-etex-svn37057.0-33.fc25.1.noarch
texlive-iftex-svn29654.0.2-33.fc25.1.noarch
texlive-palatino-svn31835.0-33.fc25.1.noarch
texlive-texlive-docindex-svn41430-33.fc25.1.noarch
texlive-xunicode-svn30466.0.981-33.fc25.1.noarch
texlive-koma-script-svn41508-33.fc25.1.noarch
texlive-pst-grad-svn15878.1.06-33.fc25.1.noarch
texlive-pst-blur-svn15878.2.0-33.fc25.1.noarch
texlive-jknapltx-svn19440.0-33.fc25.1.noarch
netpbm-progs-10.77.00-3.fc25.s390x
mesa-libgbm-devel-13.0.3-5.fc25.s390x
texinfo-6.1-4.fc25.s390x
openssl-devel-1.0.2k-1.fc25.s390x
python2-sssdconfig-1.15.2-1.fc25.noarch
libaio-0.3.110-6.fc24.s390x
libfontenc-1.1.3-3.fc24.s390x
lzo-2.08-8.fc24.s390x
isl-0.14-5.fc24.s390x
libXau-1.0.8-6.fc24.s390x
linux-atm-libs-2.5.1-14.fc24.s390x
libXext-1.3.3-4.fc24.s390x
libXxf86vm-1.1.4-3.fc24.s390x
bison-3.0.4-4.fc24.s390x
perl-srpm-macros-1-20.fc25.noarch
gawk-4.1.3-8.fc25.s390x
libwayland-client-1.12.0-1.fc25.s390x
perl-Exporter-5.72-366.fc25.noarch
perl-version-0.99.17-1.fc25.s390x
fftw-libs-double-3.3.5-3.fc25.s390x
libssh2-1.8.0-1.fc25.s390x
ModemManager-glib-1.6.4-1.fc25.s390x
newt-python3-0.52.19-2.fc25.s390x
python-munch-2.0.4-3.fc25.noarch
python-bugzilla-1.2.2-4.fc25.noarch
libedit-3.1-16.20160618cvs.fc25.s390x
python-pycurl-7.43.0-4.fc25.s390x
createrepo_c-0.10.0-6.fc25.s390x
device-mapper-multipath-libs-0.4.9-83.fc25.s390x
yum-3.4.3-510.fc25.noarch
dhcp-common-4.3.5-1.fc25.noarch
dracut-config-rescue-044-78.fc25.s390x
teamd-1.26-1.fc25.s390x
mozjs17-17.0.0-16.fc25.s390x
libselinux-2.5-13.fc25.s390x
libgo-devel-6.3.1-1.fc25.s390x
NetworkManager-libnm-1.4.4-3.fc25.s390x
python2-pyparsing-2.1.10-1.fc25.noarch
cairo-gobject-1.14.8-1.fc25.s390x
kernel-devel-4.9.3-200.fc25.s390x
ethtool-4.8-1.fc25.s390x
xorg-x11-proto-devel-7.7-20.fc25.noarch
brlapi-0.6.5-2.fc25.s390x
librados-devel-10.2.4-2.fc25.s390x
libXinerama-devel-1.1.3-6.fc24.s390x
quota-4.03-7.fc25.s390x
lua-posix-33.3.1-3.fc25.s390x
p11-kit-devel-0.23.2-2.fc24.s390x
usbredir-devel-0.7.1-2.fc24.s390x
libcurl-devel-7.51.0-4.fc25.s390x
python-libs-2.7.13-1.fc25.s390x
libX11-devel-1.6.4-4.fc25.s390x
python-devel-2.7.13-1.fc25.s390x
nss-util-3.29.3-1.0.fc25.s390x
libepoxy-1.4.1-1.fc25.s390x
freetype-devel-2.6.5-3.fc25.s390x
system-python-3.5.3-3.fc25.s390x
glusterfs-cli-3.10.0-1.fc25.s390x
python3-dnf-plugins-core-0.1.21-5.fc25.noarch
perl-macros-5.24.1-385.fc25.s390x
texlive-pdftex-doc-svn41149-33.fc25.1.noarch
mariadb-config-10.1.21-3.fc25.s390x
openssh-clients-7.4p1-4.fc25.s390x
iptables-1.6.0-3.fc25.s390x
texlive-texlive.infra-svn41280-33.fc25.1.noarch
texlive-graphics-cfg-svn40269-33.fc25.1.noarch
texlive-bibtex-svn40768-33.fc25.1.noarch
texlive-mfware-bin-svn40473-33.20160520.fc25.1.s390x
texlive-texlive-scripts-bin-svn29741.0-33.20160520.fc25.1.noarch
texlive-sauerj-svn15878.0-33.fc25.1.noarch
texlive-enctex-svn34957.0-33.fc25.1.noarch
texlive-ifetex-svn24853.1.2-33.fc25.1.noarch
texlive-ntgclass-svn15878.2.1a-33.fc25.1.noarch
texlive-tex-gyre-math-svn41264-33.fc25.1.noarch
texlive-bera-svn20031.0-33.fc25.1.noarch
texlive-ms-svn29849.0-33.fc25.1.noarch
texlive-pst-fill-svn15878.1.01-33.fc25.1.noarch
texlive-ctable-svn38672-33.fc25.1.noarch
texlive-extsizes-svn17263.1.4a-33.fc25.1.noarch
texlive-collection-latexrecommended-svn35765.0-33.20160520.fc25.1.noarch
dbus-devel-1.11.10-1.fc25.s390x
perl-Filter-1.57-1.fc25.s390x
krb5-workstation-1.14.4-7.fc25.s390x
python2-rpm-macros-3-12.fc25.noarch
gpg-pubkey-efe550f5-5220ba41
gpg-pubkey-81b46521-55b3ca9a
filesystem-3.2-37.fc24.s390x
libffi-3.1-9.fc24.s390x
keyutils-libs-1.5.9-8.fc24.s390x
libnfnetlink-1.0.1-8.fc24.s390x
libtheora-1.1.1-14.fc24.s390x
xml-common-0.6.3-44.fc24.noarch
autoconf-2.69-22.fc24.noarch
libXt-1.1.5-3.fc24.s390x
kbd-legacy-2.0.3-3.fc24.noarch
ghostscript-fonts-5.50-35.fc24.noarch
libXevie-1.0.3-11.fc24.s390x
libcap-2.25-2.fc25.s390x
mpfr-3.1.5-1.fc25.s390x
perl-Carp-1.40-365.fc25.noarch
libmnl-1.0.4-1.fc25.s390x
perl-Unicode-EastAsianWidth-1.33-8.fc25.noarch
libwayland-cursor-1.12.0-1.fc25.s390x
python-krbV-1.0.90-12.fc25.s390x
python2-urllib3-1.15.1-3.fc25.noarch
fipscheck-1.4.1-11.fc25.s390x
libndp-1.6-1.fc25.s390x
gnupg2-2.1.13-2.fc25.s390x
libXfixes-5.0.3-1.fc25.s390x
adwaita-icon-theme-3.22.0-1.fc25.noarch
dconf-0.26.0-1.fc25.s390x
ncurses-devel-6.0-6.20160709.fc25.s390x
dejagnu-1.6-1.fc25.noarch
libstdc++-devel-6.3.1-1.fc25.s390x
python-beautifulsoup4-4.5.3-1.fc25.noarch
device-mapper-1.02.136-3.fc25.s390x
subversion-1.9.5-1.fc25.s390x
libtool-ltdl-2.4.6-13.fc25.s390x
libevent-2.0.22-1.fc25.s390x
atk-devel-2.22.0-1.fc25.s390x
libev-4.24-1.fc25.s390x
xorg-x11-fonts-Type1-7.5-16.fc24.noarch
libtasn1-devel-4.10-1.fc25.s390x
vte291-devel-0.46.1-1.fc25.s390x
brlapi-devel-0.6.5-2.fc25.s390x
pulseaudio-libs-10.0-2.fc25.s390x
libnl3-cli-3.2.29-2.fc25.s390x
perl-libs-5.24.1-385.fc25.s390x
dbus-libs-1.11.10-1.fc25.s390x
mesa-libwayland-egl-devel-13.0.3-5.fc25.s390x
glib2-2.50.3-1.fc25.s390x
python3-firewall-0.4.4.4-1.fc25.noarch
python2-rpm-4.13.0.1-1.fc25.s390x
gnutls-3.5.10-1.fc25.s390x
java-1.8.0-openjdk-headless-1.8.0.121-8.b14.fc25.s390x
pango-devel-1.40.4-1.fc25.s390x
dnf-1.1.10-6.fc25.noarch
mesa-libEGL-devel-13.0.3-5.fc25.s390x
texlive-metafont-bin-svn40987-33.20160520.fc25.1.s390x
texlive-xkeyval-svn35741.2.7a-33.fc25.1.noarch
texlive-euler-svn17261.2.5-33.fc25.1.noarch
texlive-mptopdf-svn41282-33.fc25.1.noarch
texlive-wasy-svn35831.0-33.fc25.1.noarch
texlive-avantgar-svn31835.0-33.fc25.1.noarch
texlive-eurosym-svn17265.1.4_subrfix-33.fc25.1.noarch
texlive-knuth-lib-svn35820.0-33.fc25.1.noarch
texlive-parallel-svn15878.0-33.fc25.1.noarch
texlive-texlive-msg-translations-svn41431-33.fc25.1.noarch
texlive-latex-svn40218-33.fc25.1.noarch
texlive-lualatex-math-svn40621-33.fc25.1.noarch
texlive-auto-pst-pdf-svn23723.0.6-33.fc25.1.noarch
texlive-powerdot-svn38984-33.fc25.1.noarch
texlive-wasysym-svn15878.2.0-33.fc25.1.noarch
ImageMagick-libs-6.9.3.0-6.fc25.s390x
geoclue2-2.4.5-1.fc25.s390x
perl-IO-Socket-IP-0.39-1.fc25.noarch
gdb-7.12.1-47.fc25.s390x
python2-pyasn1-0.2.3-1.fc25.noarch
gpg-pubkey-34ec9cba-54e38751
gpg-pubkey-030d5aed-55b577f0
basesystem-11-2.fc24.noarch
libmpc-1.0.2-5.fc24.s390x
libunistring-0.9.4-3.fc24.s390x
libmodman-2.0.1-12.fc24.s390x
lsscsi-0.28-3.fc24.s390x
kbd-misc-2.0.3-3.fc24.noarch
rpmconf-base-1.0.18-2.fc25.noarch
libxml2-2.9.3-4.fc25.s390x
kmod-23-1.fc25.s390x
newt-0.52.19-2.fc25.s390x
perl-Text-Unidecode-1.27-3.fc25.noarch
plymouth-core-libs-0.9.3-0.6.20160620git0e65b86c.fc25.s390x
which-2.21-1.fc25.s390x
python3-slip-0.6.4-4.fc25.noarch
python3-systemd-232-1.fc25.s390x
python-lockfile-0.11.0-4.fc25.noarch
python2-requests-2.10.0-4.fc25.noarch
libarchive-3.2.2-1.fc25.s390x
libnghttp2-1.13.0-2.fc25.s390x
python-urlgrabber-3.10.1-9.fc25.noarch
iputils-20161105-1.fc25.s390x
rest-0.8.0-1.fc25.s390x
adwaita-cursor-theme-3.22.0-1.fc25.noarch
authconfig-6.2.10-14.fc25.s390x
expat-devel-2.2.0-1.fc25.s390x
automake-1.15-7.fc25.noarch
shared-mime-info-1.8-1.fc25.s390x
pigz-2.3.4-1.fc25.s390x
device-mapper-libs-1.02.136-3.fc25.s390x
dnsmasq-2.76-2.fc25.s390x
fedora-packager-0.6.0.1-1.fc25.noarch
gcc-c++-6.3.1-1.fc25.s390x
libwebp-0.5.2-1.fc25.s390x
boost-system-1.60.0-10.fc25.s390x
libasyncns-0.8-10.fc24.s390x
libXau-devel-1.0.8-6.fc24.s390x
libverto-libev-0.2.6-6.fc24.s390x
python3-html5lib-0.999-9.fc25.noarch
ttmkfdir-3.0.9-48.fc24.s390x
pulseaudio-libs-glib2-10.0-2.fc25.s390x
wpa_supplicant-2.6-1.fc25.s390x
texlive-lib-2016-33.20160520.fc25.s390x
mesa-libwayland-egl-13.0.3-5.fc25.s390x
libXi-devel-1.7.9-1.fc25.s390x
gdk-pixbuf2-2.36.5-1.fc25.s390x
python3-distro-1.0.3-1.fc25.noarch
rpm-plugin-systemd-inhibit-4.13.0.1-1.fc25.s390x
gnutls-c++-3.5.10-1.fc25.s390x
texlive-texlive-common-doc-svn40682-33.fc25.1.noarch
packagedb-cli-2.14.1-1.fc25.noarch
rpcbind-0.2.4-5.fc25.s390x
libdrm-devel-2.4.75-1.fc25.s390x
texlive-metafont-svn40793-33.fc25.1.noarch
texlive-tools-svn40934-33.fc25.1.noarch
texlive-enumitem-svn24146.3.5.2-33.fc25.1.noarch
texlive-mptopdf-bin-svn18674.0-33.20160520.fc25.1.noarch
texlive-underscore-svn18261.0-33.fc25.1.noarch
texlive-anysize-svn15878.0-33.fc25.1.noarch
texlive-euenc-svn19795.0.1h-33.fc25.1.noarch
texlive-kastrup-svn15878.0-33.fc25.1.noarch
texlive-paralist-svn39247-33.fc25.1.noarch
texlive-texlive-en-svn41185-33.fc25.1.noarch
texlive-tipa-svn29349.1.3-33.fc25.1.noarch
texlive-currfile-svn40725-33.fc25.1.noarch
texlive-pst-node-svn40743-33.fc25.1.noarch
texlive-pst-slpe-svn24391.1.31-33.fc25.1.noarch
texlive-typehtml-svn17134.0-33.fc25.1.noarch
SDL2-devel-2.0.5-3.fc25.s390x
audit-2.7.3-1.fc25.s390x
perl-Module-CoreList-5.20170320-1.fc25.noarch
libcroco-0.6.11-3.fc25.s390x
publicsuffix-list-dafsa-20170206-1.fc25.noarch
fontpackages-filesystem-1.44-17.fc24.noarch
groff-base-1.22.3-8.fc24.s390x
ilmbase-2.2.0-5.fc24.s390x
OpenEXR-libs-2.2.0-5.fc24.s390x
hesiod-3.2.1-6.fc24.s390x
sysfsutils-2.1.0-19.fc24.s390x
ocaml-srpm-macros-2-4.fc24.noarch
mailx-12.5-19.fc24.s390x
ncurses-libs-6.0-6.20160709.fc25.s390x
ipset-libs-6.29-1.fc25.s390x
gmp-devel-6.1.1-1.fc25.s390x
python-pip-8.1.2-2.fc25.noarch
harfbuzz-1.3.2-1.fc25.s390x
python2-iniparse-0.4-20.fc25.noarch
python3-iniparse-0.4-20.fc25.noarch
python3-kickstart-2.32-1.fc25.noarch
perl-Net-SSLeay-1.78-1.fc25.s390x
drpm-0.3.0-3.fc25.s390x
glib-networking-2.50.0-1.fc25.s390x
webkitgtk3-2.4.11-3.fc25.s390x
libXaw-1.0.13-4.fc25.s390x
sudo-1.8.18p1-1.fc25.s390x
xorg-x11-font-utils-7.5-32.fc25.s390x
hardlink-1.1-1.fc25.s390x
libcom_err-1.43.3-1.fc25.s390x
iproute-4.6.0-6.fc25.s390x
python2-dateutil-2.6.0-1.fc25.noarch
libXpm-3.5.12-1.fc25.s390x
python2-smmap-2.0.1-1.fc25.noarch
kernel-4.9.3-200.fc25.s390x
poppler-data-0.4.7-6.fc25.noarch
nspr-devel-4.13.1-1.fc25.s390x
librbd1-10.2.4-2.fc25.s390x
libsndfile-1.0.27-1.fc25.s390x
perl-Digest-MD5-2.55-2.fc25.s390x
wayland-protocols-devel-1.7-1.fc25.noarch
libacl-devel-2.2.52-11.fc24.s390x
texi2html-5.0-4.fc24.noarch
libxkbcommon-0.7.1-1.fc25.s390x
freetype-2.6.5-3.fc25.s390x
libuuid-devel-2.28.2-2.fc25.s390x
coreutils-common-8.25-16.fc25.s390x
gdb-headless-7.12.1-47.fc25.s390x
nss-sysinit-3.29.3-1.0.fc25.s390x
libcacard-2.5.3-1.fc25.s390x
perl-threads-shared-1.55-1.fc25.s390x
python2-rpkg-1.49-2.fc25.noarch
libwmf-lite-0.2.8.4-50.fc25.s390x
mesa-libGL-13.0.3-5.fc25.s390x
unbound-libs-1.6.0-6.fc25.s390x
texlive-tetex-svn41059-33.fc25.1.noarch
texlive-thumbpdf-svn34621.3.16-33.fc25.1.noarch
texlive-carlisle-svn18258.0-33.fc25.1.noarch
texlive-makeindex-bin-svn40473-33.20160520.fc25.1.s390x
texlive-pdftex-svn41149-33.fc25.1.noarch
texlive-csquotes-svn39538-33.fc25.1.noarch
texlive-courier-svn35058.0-33.fc25.1.noarch
texlive-helvetic-svn31835.0-33.fc25.1.noarch
texlive-mfnfss-svn19410.0-33.fc25.1.noarch
texlive-sepnum-svn20186.2.0-33.fc25.1.noarch
texlive-utopia-svn15878.0-33.fc25.1.noarch
texlive-luatexbase-svn38550-33.fc25.1.noarch
texlive-pst-3d-svn17257.1.10-33.fc25.1.noarch
texlive-latex-bin-bin-svn14050.0-33.20160520.fc25.1.noarch
texlive-l3experimental-svn41163-33.fc25.1.noarch
bind99-libs-9.9.9-4.P6.fc25.s390x
net-tools-2.0-0.40.20160329git.fc25.s390x
perl-Pod-Perldoc-3.28-1.fc25.noarch
openssl-1.0.2k-1.fc25.s390x
man-pages-4.06-4.fc25.noarch
gpg-pubkey-95a43f54-5284415a
dejavu-fonts-common-2.35-3.fc24.noarch
libSM-1.2.2-4.fc24.s390x
diffutils-3.3-13.fc24.s390x
libogg-1.3.2-5.fc24.s390x
hunspell-en-US-0.20140811.1-5.fc24.noarch
libdaemon-0.14-10.fc24.s390x
patch-2.7.5-3.fc24.s390x
libsysfs-2.1.0-19.fc24.s390x
procmail-3.22-39.fc24.s390x
libXdamage-1.1.4-8.fc24.s390x
libotf-0.9.13-7.fc24.s390x
urw-fonts-2.4-22.fc24.noarch
crontabs-1.11-12.20150630git.fc24.noarch
ppp-2.4.7-9.fc24.s390x
polkit-0.113-5.fc24.s390x
cyrus-sasl-2.1.26-26.2.fc24.s390x
zlib-devel-1.2.8-10.fc24.s390x
time-1.7-49.fc24.s390x
gpg-pubkey-fdb19c98-56fd6333
fedora-release-25-1.noarch
libcap-ng-0.7.8-1.fc25.s390x
gdbm-1.12-1.fc25.s390x
binutils-2.26.1-1.fc25.s390x
lcms2-2.8-2.fc25.s390x
libcomps-0.1.7-5.fc25.s390x
less-481-6.fc25.s390x
apr-1.5.2-4.fc25.s390x
perl-constant-1.33-367.fc25.noarch
perl-Data-Dumper-2.161-1.fc25.s390x
ipcalc-0.1.8-1.fc25.s390x
libteam-1.26-1.fc25.s390x
gmp-c++-6.1.1-1.fc25.s390x
fontconfig-2.12.1-1.fc25.s390x
enchant-1.6.0-14.fc25.s390x
pyliblzma-0.5.3-16.fc25.s390x
libsepol-devel-2.5-10.fc25.s390x
python3-ordered-set-2.0.0-4.fc25.noarch
python3-rpmconf-1.0.18-2.fc25.noarch
python-ipaddress-1.0.16-3.fc25.noarch
python2-kerberos-1.2.5-1.fc25.s390x
python2-pysocks-1.5.6-5.fc25.noarch
fipscheck-lib-1.4.1-11.fc25.s390x
libatomic_ops-7.4.4-1.fc25.s390x
net-snmp-agent-libs-5.7.3-13.fc25.s390x
dracut-044-78.fc25.s390x
python2-pygpgme-0.3-18.fc25.s390x
libsoup-2.56.0-2.fc25.s390x
orc-0.4.26-1.fc25.s390x
yum-utils-1.1.31-511.fc25.noarch
libXrender-0.9.10-1.fc25.s390x
libXrandr-1.5.1-1.fc25.s390x
go-srpm-macros-2-7.fc25.noarch
gnupg2-smime-2.1.13-2.fc25.s390x
guile-devel-2.0.13-1.fc25.s390x
uboot-tools-2016.09.01-2.fc25.s390x
pykickstart-2.32-1.fc25.noarch
python-bunch-1.0.1-9.fc25.noarch
perl-generators-1.10-1.fc25.noarch
perl-Mozilla-CA-20160104-3.fc25.noarch
glibc-all-langpacks-2.24-4.fc25.s390x
bzip2-libs-1.0.6-21.fc25.s390x
libpng-1.6.27-1.fc25.s390x
desktop-file-utils-0.23-2.fc25.s390x
python2-cccolutils-1.4-1.fc25.s390x
libcurl-7.51.0-4.fc25.s390x
cups-libs-2.2.0-5.fc25.s390x
python2-lxml-3.7.2-1.fc25.s390x
redhat-rpm-config-45-1.fc25.noarch
elfutils-libs-0.168-1.fc25.s390x
device-mapper-event-libs-1.02.136-3.fc25.s390x
lvm2-libs-2.02.167-3.fc25.s390x
elfutils-0.168-1.fc25.s390x
python2-gitdb-2.0.0-1.fc25.noarch
gcc-gfortran-6.3.1-1.fc25.s390x
libselinux-python-2.5-13.fc25.s390x
openjpeg2-2.1.2-3.fc25.s390x
js-jquery-2.2.4-1.fc25.noarch
boost-thread-1.60.0-10.fc25.s390x
json-c-0.12-7.fc24.s390x
librbd-devel-10.2.4-2.fc25.s390x
libXcursor-devel-1.1.14-6.fc24.s390x
python3-beautifulsoup4-4.5.3-1.fc25.noarch
latex2html-2012-7.fc24.noarch
lksctp-tools-1.0.16-5.fc24.s390x
vte291-0.46.1-1.fc25.s390x
at-spi2-core-devel-2.22.0-1.fc25.s390x
libfdt-1.4.2-1.fc25.s390x
libXft-devel-2.3.2-4.fc24.s390x
libattr-devel-2.4.47-16.fc24.s390x
libiscsi-devel-1.15.0-2.fc24.s390x
gettext-0.19.8.1-3.fc25.s390x
libjpeg-turbo-devel-1.5.1-0.fc25.s390x
libX11-1.6.4-4.fc25.s390x
pulseaudio-libs-devel-10.0-2.fc25.s390x
ccache-3.3.3-1.fc25.s390x
systemd-libs-231-14.fc25.s390x
file-5.29-3.fc25.s390x
nss-softokn-freebl-3.29.3-1.0.fc25.s390x
libepoxy-devel-1.4.1-1.fc25.s390x
krb5-libs-1.14.4-7.fc25.s390x
libmount-2.28.2-2.fc25.s390x
ghostscript-core-9.20-6.fc25.s390x
python3-decorator-4.0.11-1.fc25.noarch
rpm-plugin-selinux-4.13.0.1-1.fc25.s390x
python3-hawkey-0.6.4-1.fc25.s390x
nss-devel-3.29.3-1.0.fc25.s390x
libidn2-0.16-1.fc25.s390x
perl-threads-2.15-1.fc25.s390x
tzdata-java-2017b-1.fc25.noarch
python-srpm-macros-3-12.fc25.noarch
gdk-pixbuf2-devel-2.36.5-1.fc25.s390x
libsmartcols-2.28.2-2.fc25.s390x
glusterfs-api-3.10.0-1.fc25.s390x
mesa-libGLES-13.0.3-5.fc25.s390x
kernel-core-4.10.5-200.fc25.s390x
kernel-modules-4.10.5-200.fc25.s390x
jasper-libs-1.900.13-2.fc25.s390x
texlive-kpathsea-svn41139-33.fc25.1.noarch
texlive-amsmath-svn41561-33.fc25.1.noarch
texlive-thumbpdf-bin-svn6898.0-33.20160520.fc25.1.noarch
texlive-psnfss-svn33946.9.2a-33.fc25.1.noarch
texlive-subfig-svn15878.1.3-33.fc25.1.noarch
texlive-fancybox-svn18304.1.4-33.fc25.1.noarch
texlive-lua-alt-getopt-svn29349.0.7.0-33.fc25.1.noarch
texlive-natbib-svn20668.8.31b-33.fc25.1.noarch
texlive-pdftex-bin-svn40987-33.20160520.fc25.1.s390x
texlive-xdvi-svn40768-33.fc25.1.noarch
texlive-crop-svn15878.1.5-33.fc25.1.noarch
texlive-babel-english-svn30264.3.3p-33.fc25.1.noarch
texlive-cmextra-svn32831.0-33.fc25.1.noarch
texlive-fancyhdr-svn15878.3.1-33.fc25.1.noarch
texlive-luatex-svn40963-33.fc25.1.noarch
texlive-knuth-local-svn38627-33.fc25.1.noarch
texlive-mflogo-font-svn36898.1.002-33.fc25.1.noarch
texlive-parskip-svn19963.2.0-33.fc25.1.noarch
texlive-section-svn20180.0-33.fc25.1.noarch
texlive-textcase-svn15878.0-33.fc25.1.noarch
texlive-updmap-map-svn41159-33.fc25.1.noarch
texlive-attachfile-svn38830-33.fc25.1.noarch
texlive-luaotfload-svn40902-33.fc25.1.noarch
texlive-unicode-math-svn38462-33.fc25.1.noarch
texlive-fancyvrb-svn18492.2.8-33.fc25.1.noarch
texlive-pst-pdf-bin-svn7838.0-33.20160520.fc25.1.noarch
texlive-amscls-svn36804.0-33.fc25.1.noarch
texlive-ltxmisc-svn21927.0-33.fc25.1.noarch
texlive-breqn-svn38099.0.98d-33.fc25.1.noarch
texlive-xetex-def-svn40327-33.fc25.1.noarch
glusterfs-extra-xlators-3.10.0-1.fc25.s390x
bluez-libs-devel-5.43-2.fc25.s390x
openssh-server-7.4p1-4.fc25.s390x
sendmail-8.15.2-8.fc25.s390x
python-firewall-0.4.4.4-1.fc25.noarch
perl-Test-Harness-3.38-1.fc25.noarch
python3-sssdconfig-1.15.2-1.fc25.noarch
python-magic-5.29-3.fc25.noarch
tzdata-2017b-1.fc25.noarch
hunspell-1.4.1-2.fc25.s390x
gpg-pubkey-8e1431d5-53bcbac7
zlib-1.2.8-10.fc24.s390x
sed-4.2.2-15.fc24.s390x
p11-kit-0.23.2-2.fc24.s390x
psmisc-22.21-8.fc24.s390x
gpm-libs-1.20.7-9.fc24.s390x
zip-3.0-16.fc24.s390x
hostname-3.15-7.fc24.s390x
libyubikey-1.13-2.fc24.s390x
sg3_utils-libs-1.41-3.fc24.s390x
polkit-pkla-compat-0.1-7.fc24.s390x
passwd-0.79-8.fc24.s390x
trousers-0.3.13-6.fc24.s390x
grubby-8.40-3.fc24.s390x
rootfiles-8.1-19.fc24.noarch
nettle-3.3-1.fc25.s390x
jansson-2.9-1.fc25.s390x
libksba-1.3.5-1.fc25.s390x
perl-Text-ParseWords-3.30-365.fc25.noarch
perl-PathTools-3.63-366.fc25.s390x
perl-File-Temp-0.23.04-365.fc25.noarch
fuse-libs-2.9.7-1.fc25.s390x
perl-Pod-Escapes-1.07-365.fc25.noarch
perl-Term-ANSIColor-4.05-2.fc25.noarch
perl-URI-1.71-5.fc25.noarch
libXfont-1.5.2-1.fc25.s390x
python-six-1.10.0-3.fc25.noarch
dbus-glib-0.108-1.fc25.s390x
gobject-introspection-1.50.0-1.fc25.s390x
libpwquality-1.3.0-6.fc25.s390x
python-gobject-base-3.22.0-1.fc25.s390x
python-html5lib-0.999-9.fc25.noarch
python3-dbus-1.2.4-2.fc25.s390x
python3-chardet-2.3.0-1.fc25.noarch
python3-urllib3-1.15.1-3.fc25.noarch
python-offtrac-0.1.0-7.fc25.noarch
python2-cryptography-1.5.3-3.fc25.s390x
python2-requests-kerberos-0.10.0-2.fc25.noarch
libserf-1.3.9-1.fc25.s390x
libdatrie-0.2.9-3.fc25.s390x
s390utils-base-1.36.0-1.fc25.s390x
kpartx-0.4.9-83.fc25.s390x
s390utils-cpuplugd-1.36.0-1.fc25.s390x
rpmconf-1.0.18-2.fc25.noarch
s390utils-osasnmpd-1.36.0-1.fc25.s390x
python-dnf-plugins-extras-common-0.0.12-4.fc25.noarch
fpc-srpm-macros-1.0-1.fc25.noarch
libuser-0.62-4.fc25.s390x
man-db-2.7.5-3.fc25.s390x
sqlite-3.14.2-1.fc25.s390x
python-systemd-doc-232-1.fc25.s390x
libdb-5.3.28-16.fc25.s390x
lz4-1.7.5-1.fc25.s390x
tar-1.29-3.fc25.s390x
emacs-common-25.1-3.fc25.s390x
unzip-6.0-31.fc25.s390x
bodhi-client-0.9.12.2-6.fc25.noarch
glibc-headers-2.24-4.fc25.s390x
kernel-core-4.9.3-200.fc25.s390x
cairo-1.14.8-1.fc25.s390x
ca-certificates-2017.2.11-1.0.fc25.noarch
NetworkManager-glib-1.4.4-3.fc25.s390x
gcc-go-6.3.1-1.fc25.s390x
cracklib-dicts-2.9.6-4.fc25.s390x
iproute-tc-4.6.0-6.fc25.s390x
libselinux-python3-2.5-13.fc25.s390x
python2-enchant-1.6.8-1.fc25.noarch
boost-iostreams-1.60.0-10.fc25.s390x
userspace-rcu-0.9.2-2.fc25.s390x
libXext-devel-1.3.3-4.fc24.s390x
libXrandr-devel-1.5.1-1.fc25.s390x
perl-XML-XPath-1.39-1.fc25.noarch
python3-lxml-3.7.2-1.fc25.s390x
vte-profile-0.46.1-1.fc25.s390x
sqlite-devel-3.14.2-1.fc25.s390x
libiscsi-1.15.0-2.fc24.s390x
fontconfig-devel-2.12.1-1.fc25.s390x
libfdt-devel-1.4.2-1.fc25.s390x
ceph-devel-compat-10.2.4-2.fc25.s390x
zlib-static-1.2.8-10.fc24.s390x
chrpath-0.16-3.fc24.s390x
python-2.7.13-1.fc25.s390x
perl-Git-2.9.3-2.fc25.noarch
kernel-core-4.9.5-200.fc25.s390x
info-6.1-4.fc25.s390x
libtiff-4.0.7-2.fc25.s390x
iptables-libs-1.6.0-3.fc25.s390x
bind-license-9.10.4-4.P6.fc25.noarch
lua-5.3.4-1.fc25.s390x
glusterfs-libs-3.10.0-1.fc25.s390x
glusterfs-client-xlators-3.10.0-1.fc25.s390x
libfdisk-2.28.2-2.fc25.s390x
nss-pem-1.0.3-2.fc25.s390x
libsolv-0.6.26-1.fc25.s390x
dnf-plugins-core-0.1.21-5.fc25.noarch
selinux-policy-3.13.1-225.11.fc25.noarch
perl-Errno-1.25-385.fc25.s390x
perl-Storable-2.56-368.fc25.s390x
python2-decorator-4.0.11-1.fc25.noarch
pcre-utf16-8.40-5.fc25.s390x
mariadb-common-10.1.21-3.fc25.s390x
glusterfs-3.10.0-1.fc25.s390x
systemtap-client-3.1-2.fc25.s390x
glusterfs-server-3.10.0-1.fc25.s390x
libnetfilter_conntrack-1.0.6-2.fc25.s390x
bluez-libs-5.43-2.fc25.s390x
texlive-texlive.infra-bin-svn40312-33.20160520.fc25.1.s390x
texlive-ifluatex-svn41346-33.fc25.1.noarch
texlive-fp-svn15878.0-33.fc25.1.noarch
texlive-latex-fonts-svn28888.0-33.fc25.1.noarch
texlive-bibtex-bin-svn40473-33.20160520.fc25.1.s390x
texlive-glyphlist-svn28576.0-33.fc25.1.noarch
texlive-marvosym-svn29349.2.2a-33.fc25.1.noarch
texlive-tex-bin-svn40987-33.20160520.fc25.1.s390x
texlive-texconfig-svn40768-33.fc25.1.noarch
texlive-wasy2-ps-svn35830.0-33.fc25.1.noarch
texlive-psfrag-svn15878.3.04-33.fc25.1.noarch
texlive-charter-svn15878.0-33.fc25.1.noarch
texlive-ec-svn25033.1.0-33.fc25.1.noarch
texlive-lineno-svn21442.4.41-33.fc25.1.noarch
texlive-hyphen-base-svn41138-33.fc25.1.noarch
texlive-manfnt-font-svn35799.0-33.fc25.1.noarch
texlive-ncntrsbk-svn31835.0-33.fc25.1.noarch
texlive-pst-math-svn34786.0.63-33.fc25.1.noarch
texlive-symbol-svn31835.0-33.fc25.1.noarch
texlive-environ-svn33821.0.3-33.fc25.1.noarch
texlive-algorithms-svn38085.0.1-33.fc25.1.noarch
texlive-ifplatform-svn21156.0.4-33.fc25.1.noarch
texlive-eso-pic-svn37925.2.0g-33.fc25.1.noarch
texlive-xcolor-svn41044-33.fc25.1.noarch
texlive-pst-eps-svn15878.1.0-33.fc25.1.noarch
texlive-pst-text-svn15878.1.00-33.fc25.1.noarch
texlive-rotating-svn16832.2.16b-33.fc25.1.noarch
texlive-pdfpages-svn40638-33.fc25.1.noarch
texlive-cm-super-svn15878.0-33.fc25.1.noarch
texlive-xetex-svn41438-33.fc25.1.noarch
glusterfs-devel-3.10.0-1.fc25.s390x
gtk3-devel-3.22.9-2.fc25.s390x
dnf-yum-1.1.10-6.fc25.noarch
mariadb-libs-10.1.21-3.fc25.s390x
java-1.8.0-openjdk-1.8.0.121-8.b14.fc25.s390x
rpmlint-1.9-8.fc25.noarch
systemtap-sdt-devel-3.1-2.fc25.s390x
libseccomp-devel-2.3.2-1.fc25.s390x
telnet-0.17-67.fc25.s390x
gpgme-1.8.0-10.fc25.s390x
apr-util-1.5.4-3.fc24.s390x
rsync-3.1.2-2.fc24.s390x
jbigkit-libs-2.1-5.fc24.s390x
pixman-0.34.0-2.fc24.s390x
dwz-0.12-2.fc24.s390x
expect-5.45-22.fc24.s390x
libsigsegv-2.10-10.fc24.s390x
fakeroot-libs-1.20.2-4.fc24.s390x
m17n-lib-1.7.0-5.fc24.s390x
libverto-0.2.6-6.fc24.s390x
libXmu-1.1.2-4.fc24.s390x
libXcursor-1.1.14-6.fc24.s390x
python-kitchen-1.2.4-2.fc24.noarch
polkit-libs-0.113-5.fc24.s390x
fakeroot-1.20.2-4.fc24.s390x
blktrace-1.1.0-3.fc24.s390x
usermode-1.111-8.fc24.s390x
kbd-2.0.3-3.fc24.s390x
libaio-devel-0.3.110-6.fc24.s390x
web-assets-filesystem-5-4.fc24.noarch
expat-2.2.0-1.fc25.s390x
libgpg-error-1.24-1.fc25.s390x
libgcrypt-1.6.6-1.fc25.s390x
findutils-4.6.0-8.fc25.s390x
libassuan-2.4.3-1.fc25.s390x
libusbx-1.0.21-1.fc25.s390x
libxslt-1.1.28-13.fc25.s390x
libmetalink-0.1.3-1.fc25.s390x
perl-File-Path-2.12-365.fc25.noarch
perl-MIME-Base64-3.15-365.fc25.s390x
ncurses-6.0-6.20160709.fc25.s390x
libwayland-server-1.12.0-1.fc25.s390x
perl-Fedora-VSP-0.001-4.fc25.noarch
perl-libintl-perl-1.26-1.fc25.s390x
shadow-utils-4.2.1-11.fc25.s390x
atk-2.22.0-1.fc25.s390x
pam-1.3.0-1.fc25.s390x
harfbuzz-icu-1.3.2-1.fc25.s390x
libsecret-0.18.5-2.fc25.s390x
s390utils-iucvterm-1.36.0-1.fc25.s390x
python3-requests-2.10.0-4.fc25.noarch
pyusb-1.0.0-2.fc25.noarch
python-enum34-1.0.4-6.fc25.noarch
pyOpenSSL-16.0.0-2.fc25.noarch
pyxattr-0.5.3-8.fc25.s390x
libbabeltrace-1.4.0-3.fc25.s390x
libthai-0.1.25-1.fc25.s390x
deltarpm-3.6-17.fc25.s390x
s390utils-mon_statd-1.36.0-1.fc25.s390x
device-mapper-multipath-0.4.9-83.fc25.s390x
python3-pygpgme-0.3-18.fc25.s390x
libreport-filesystem-2.8.0-1.fc25.s390x
ghc-srpm-macros-1.4.2-4.fc25.noarch
rpmdevtools-8.9-1.fc25.noarch
python-dnf-plugins-extras-migrate-0.0.12-4.fc25.noarch
perl-IO-Socket-SSL-2.038-1.fc25.noarch
mc-4.8.18-2.fc25.s390x
perl-File-ShareDir-1.102-7.fc25.noarch
tcl-8.6.6-1.fc25.s390x
glibc-2.24-4.fc25.s390x
elfutils-libelf-0.168-1.fc25.s390x
perl-Scalar-List-Utils-1.47-1.fc25.s390x
bzip2-1.0.6-21.fc25.s390x
libss-1.43.3-1.fc25.s390x
libselinux-utils-2.5-13.fc25.s390x
policycoreutils-2.5-19.fc25.s390x
koji-1.11.0-1.fc25.noarch
python3-enchant-1.6.8-1.fc25.noarch
python2-dockerfile-parse-0.0.5-7.fc25.noarch
systemd-bootchart-231-2.fc25.s390x
gcc-objc-6.3.1-1.fc25.s390x
e2fsprogs-1.43.3-1.fc25.s390x
libstdc++-static-6.3.1-1.fc25.s390x
libpng-devel-1.6.27-1.fc25.s390x
perl-XML-Parser-2.44-5.fc25.s390x
lttng-ust-2.8.1-2.fc25.s390x
libXfixes-devel-5.0.3-1.fc25.s390x
libXcomposite-devel-0.4.4-8.fc24.s390x
quota-nls-4.03-7.fc25.noarch
python3-javapackages-4.7.0-6.1.fc25.noarch
libcephfs_jni-devel-10.2.4-2.fc25.s390x
keyutils-libs-devel-1.5.9-8.fc24.s390x
libicu-devel-57.1-4.fc25.s390x
harfbuzz-devel-1.3.2-1.fc25.s390x
libidn-devel-1.33-1.fc25.s390x
libnfs-1.9.8-2.fc24.s390x
libssh2-devel-1.8.0-1.fc25.s390x
qemu-sanity-check-nodeps-1.1.5-5.fc24.s390x
alsa-lib-devel-1.1.1-2.fc25.s390x
libnl3-3.2.29-2.fc25.s390x
git-core-doc-2.9.3-2.fc25.s390x
git-2.9.3-2.fc25.s390x
kernel-modules-4.9.5-200.fc25.s390x
libpsl-0.17.0-1.fc25.s390x
lua-libs-5.3.4-1.fc25.s390x
libseccomp-2.3.2-1.fc25.s390x
nss-util-devel-3.29.3-1.0.fc25.s390x
nss-softokn-freebl-devel-3.29.3-1.0.fc25.s390x
copy-jdk-configs-2.2-2.fc25.noarch
system-python-libs-3.5.3-3.fc25.s390x
json-glib-1.2.6-1.fc25.s390x
python3-libs-3.5.3-3.fc25.s390x
nss-3.29.3-1.0.fc25.s390x
hawkey-0.6.4-1.fc25.s390x
python2-dnf-1.1.10-6.fc25.noarch
bind-libs-lite-9.10.4-4.P6.fc25.s390x
perl-IO-1.36-385.fc25.s390x
vim-filesystem-8.0.425-1.fc25.s390x
python2-GitPython-2.1.3-1.fc25.noarch
pcre-devel-8.40-5.fc25.s390x
linux-firmware-20170313-72.git695f2d6d.fc25.noarch
libdrm-2.4.75-1.fc25.s390x
mesa-libEGL-13.0.3-5.fc25.s390x
systemd-container-231-14.fc25.s390x
gnutls-dane-3.5.10-1.fc25.s390x
gtk3-3.22.9-2.fc25.s390x
texlive-tetex-bin-svn36770.0-33.20160520.fc25.1.noarch
texlive-amsfonts-svn29208.3.04-33.fc25.1.noarch
texlive-babel-svn40706-33.fc25.1.noarch
texlive-colortbl-svn29803.v1.0a-33.fc25.1.noarch
texlive-babelbib-svn25245.1.31-33.fc25.1.noarch
texlive-footmisc-svn23330.5.5b-33.fc25.1.noarch
texlive-makeindex-svn40768-33.fc25.1.noarch
texlive-plain-svn40274-33.fc25.1.noarch
texlive-texconfig-bin-svn29741.0-33.20160520.fc25.1.noarch
texlive-zapfding-svn31835.0-33.fc25.1.noarch
texlive-microtype-svn41127-33.fc25.1.noarch
texlive-bookman-svn31835.0-33.fc25.1.noarch
texlive-dvisvgm-def-svn41011-33.fc25.1.noarch
texlive-finstrut-svn21719.0.5-33.fc25.1.noarch
texlive-hyph-utf8-svn41189-33.fc25.1.noarch
texlive-lualibs-svn40370-33.fc25.1.noarch
texlive-mparhack-svn15878.1.4-33.fc25.1.noarch
texlive-pspicture-svn15878.0-33.fc25.1.noarch
texlive-soul-svn15878.2.4-33.fc25.1.noarch
texlive-trimspaces-svn15878.1.1-33.fc25.1.noarch
texlive-varwidth-svn24104.0.92-33.fc25.1.noarch
texlive-geometry-svn19716.5.6-33.fc25.1.noarch
texlive-memoir-svn41203-33.fc25.1.noarch
texlive-pgf-svn40966-33.fc25.1.noarch
texlive-pst-coil-svn37377.1.07-33.fc25.1.noarch
texlive-pst-plot-svn41242-33.fc25.1.noarch
texlive-latex-bin-svn41438-33.fc25.1.noarch
texlive-ucs-svn35853.2.2-33.fc25.1.noarch
texlive-ae-svn15878.1.4-33.fc25.1.noarch
texlive-xetex-bin-svn41091-33.20160520.fc25.1.s390x
glusterfs-api-devel-3.10.0-1.fc25.s390x
mesa-libGL-devel-13.0.3-5.fc25.s390x
fedora-upgrade-26.1-1.fc25.noarch
fedpkg-1.28-1.fc25.noarch
vim-enhanced-8.0.425-1.fc25.s390x
perl-Thread-Queue-3.12-1.fc25.noarch
gstreamer1-plugins-base-1.10.4-1.fc25.s390x
screen-4.5.1-1.fc25.s390x
strace-4.16-1.fc25.s390x
fedora-repos-25-3.noarch
libacl-2.2.52-11.fc24.s390x
cdparanoia-libs-10.2-21.fc24.s390x
ustr-1.0.4-21.fc24.s390x
libusb-0.1.5-7.fc24.s390x
readline-devel-6.3-8.fc24.s390x
chkconfig-1.8-1.fc25.s390x
avahi-libs-0.6.32-4.fc25.s390x
perl-Unicode-Normalize-1.25-365.fc25.s390x
perl-libnet-3.10-1.fc25.noarch
perl-podlators-4.09-1.fc25.noarch
graphite2-1.3.6-1.fc25.s390x
dbus-python-1.2.4-2.fc25.s390x
libgnome-keyring-3.12.0-7.fc25.s390x
python-backports-1.0-8.fc25.s390x
python-pycparser-2.14-7.fc25.noarch
plymouth-scripts-0.9.3-0.6.20160620git0e65b86c.fc25.s390x
cronie-1.5.1-2.fc25.s390x
python2-librepo-1.7.18-3.fc25.s390x
at-spi2-core-2.22.0-1.fc25.s390x
libXv-1.0.11-1.fc25.s390x
python2-ndg_httpsclient-0.4.0-4.fc25.noarch
btrfs-progs-4.6.1-1.fc25.s390x
libgcc-6.3.1-1.fc25.s390x
libgomp-6.3.1-1.fc25.s390x
perl-Encode-2.88-5.fc25.s390x
cracklib-2.9.6-4.fc25.s390x
libobjc-6.3.1-1.fc25.s390x
gcc-6.3.1-1.fc25.s390x
python3-dnf-plugin-system-upgrade-0.7.1-4.fc25.noarch
NetworkManager-1.4.4-3.fc25.s390x
glibc-static-2.24-4.fc25.s390x
boost-random-1.60.0-10.fc25.s390x
libref_array-0.1.5-29.fc25.s390x
libXrender-devel-0.9.10-1.fc25.s390x
javapackages-tools-4.7.0-6.1.fc25.noarch
keyutils-1.5.9-8.fc24.s390x
libcom_err-devel-1.43.3-1.fc25.s390x
graphite2-devel-1.3.6-1.fc25.s390x
lzo-minilzo-2.08-8.fc24.s390x
libusbx-devel-1.0.21-1.fc25.s390x
virglrenderer-devel-0.5.0-1.20160411git61846f92f.fc25.s390x
acpica-tools-20160831-1.fc25.s390x
grep-2.27-2.fc25.s390x
dnf-conf-1.1.10-6.fc25.noarch
crypto-policies-20160921-4.gitf3018dd.fc25.noarch
gtk-update-icon-cache-3.22.9-2.fc25.s390x
rpm-build-libs-4.13.0.1-1.fc25.s390x
libnfsidmap-0.27-1.fc25.s390x
systemtap-devel-3.1-2.fc25.s390x
pcre2-10.23-4.fc25.s390x
systemd-231-14.fc25.s390x
gssproxy-0.7.0-2.fc25.s390x
SDL2-2.0.5-3.fc25.s390x
texlive-etex-pkg-svn39355-33.fc25.1.noarch
texlive-multido-svn18302.1.42-33.fc25.1.noarch
texlive-gsftopk-svn40768-33.fc25.1.noarch
texlive-pst-ovl-svn40873-33.fc25.1.noarch
texlive-ltabptch-svn17533.1.74d-33.fc25.1.noarch
texlive-cite-svn36428.5.5-33.fc25.1.noarch
texlive-fpl-svn15878.1.002-33.fc25.1.noarch
texlive-mathpazo-svn15878.1.003-33.fc25.1.noarch
texlive-rcs-svn15878.0-33.fc25.1.noarch
texlive-type1cm-svn21820.0-33.fc25.1.noarch
texlive-l3kernel-svn41246-33.fc25.1.noarch
texlive-hyperref-svn41396-33.fc25.1.noarch
texlive-pst-tree-svn24142.1.12-33.fc25.1.noarch
texlive-sansmathaccent-svn30187.0-33.fc25.1.noarch
texlive-dvipdfmx-bin-svn40273-33.20160520.fc25.1.s390x
texlive-zapfchan-svn31835.0-33.fc25.1.noarch
firewalld-0.4.4.4-1.fc25.noarch
glib2-static-2.50.3-1.fc25.s390x
libmicrohttpd-0.9.52-3.fc25.s390x
perl-open-1.10-385.fc25.noarch
bash-completion-2.5-1.fc25.noarch
gpg-pubkey-a29cb19c-53bcbba6
m4-1.4.17-9.fc24.s390x
liblockfile-1.09-4.fc24.s390x
sg3_utils-1.41-3.fc24.s390x
libXinerama-1.1.3-6.fc24.s390x
libXft-2.3.2-4.fc24.s390x
tcp_wrappers-libs-7.6-83.fc25.s390x
perl-Text-Tabs+Wrap-2013.0523-365.fc25.noarch
perl-Error-0.17024-7.fc25.noarch
perl-Term-Cap-1.17-365.fc25.noarch
perl-Pod-Usage-1.69-1.fc25.noarch
device-mapper-persistent-data-0.6.3-1.fc25.s390x
net-snmp-libs-5.7.3-13.fc25.s390x
libgusb-0.2.9-1.fc25.s390x
python3-six-1.10.0-3.fc25.noarch
python3-pysocks-1.5.6-5.fc25.noarch
python-chardet-2.3.0-1.fc25.noarch
python2-cffi-1.7.0-2.fc25.s390x
gc-devel-7.4.4-1.fc25.s390x
plymouth-0.9.3-0.6.20160620git0e65b86c.fc25.s390x
ebtables-2.0.10-21.fc25.s390x
python3-librepo-1.7.18-3.fc25.s390x
net-snmp-5.7.3-13.fc25.s390x
at-spi2-atk-2.22.0-1.fc25.s390x
avahi-autoipd-0.6.32-4.fc25.s390x
libcrypt-nss-2.24-4.fc25.s390x
libgo-6.3.1-1.fc25.s390x
cpp-6.3.1-1.fc25.s390x
glibc-devel-2.24-4.fc25.s390x
kernel-modules-4.9.3-200.fc25.s390x
emacs-25.1-3.fc25.s390x
pyparsing-2.1.10-1.fc25.noarch
libproxy-0.4.14-1.fc25.s390x
python3-pyparsing-2.1.10-1.fc25.noarch
libcollection-0.7.0-29.fc25.s390x
libcephfs-devel-10.2.4-2.fc25.s390x
libXdamage-devel-1.1.4-8.fc24.s390x
libverto-devel-0.2.6-6.fc24.s390x
snappy-1.1.3-2.fc24.s390x
cairo-gobject-devel-1.14.8-1.fc25.s390x
cyrus-sasl-devel-2.1.26-26.2.fc24.s390x
kernel-devel-4.9.5-200.fc25.s390x
libXi-1.7.9-1.fc25.s390x
distribution-gpg-keys-1.11-1.fc25.noarch
texlive-base-2016-33.20160520.fc25.noarch
gstreamer1-1.10.4-1.fc25.s390x
python3-rpm-4.13.0.1-1.fc25.s390x
systemtap-runtime-3.1-2.fc25.s390x
perl-SelfLoader-1.23-385.fc25.noarch
pcre-utf32-8.40-5.fc25.s390x
dbus-1.11.10-1.fc25.s390x
nfs-utils-2.1.1-2.rc1.fc25.s390x
bind99-license-9.9.9-4.P6.fc25.noarch
texlive-booktabs-svn40846-33.fc25.1.noarch
texlive-lm-svn28119.2.004-33.fc25.1.noarch
texlive-gsftopk-bin-svn40473-33.20160520.fc25.1.s390x
texlive-tex-svn40793-33.fc25.1.noarch
texlive-fancyref-svn15878.0.9c-33.fc25.1.noarch
texlive-chngcntr-svn17157.1.0a-33.fc25.1.noarch
texlive-fix2col-svn38770-33.fc25.1.noarch
texlive-marginnote-svn41382-33.fc25.1.noarch
texlive-pxfonts-svn15878.0-33.fc25.1.noarch
texlive-txfonts-svn15878.0-33.fc25.1.noarch
texlive-l3packages-svn41246-33.fc25.1.noarch
texlive-oberdiek-svn41346-33.fc25.1.noarch
texlive-pst-tools-svn34067.0.05-33.fc25.1.noarch
texlive-tex-gyre-svn18651.2.004-33.fc25.1.noarch
texlive-dvipdfmx-svn41149-33.fc25.1.noarch
texlive-collection-fontsrecommended-svn35830.0-33.20160520.fc25.1.noarch
gnutls-devel-3.5.10-1.fc25.s390x
libcacard-devel-2.5.3-1.fc25.s390x
selinux-policy-targeted-3.13.1-225.11.fc25.noarch
ykpers-1.18.0-2.fc25.s390x
python2-idna-2.5-1.fc25.noarch
python-async-0.6.1-9.fc22.s390x
dejavu-sans-mono-fonts-2.35-3.fc24.noarch
popt-1.16-7.fc24.s390x
cyrus-sasl-lib-2.1.26-26.2.fc24.s390x
xz-5.2.2-2.fc24.s390x
libpipeline-1.4.1-2.fc24.s390x
pinentry-0.9.7-2.fc24.s390x
pth-2.0.7-27.fc24.s390x
libsepol-2.5-10.fc25.s390x
sqlite-libs-3.14.2-1.fc25.s390x
libxcb-1.12-1.fc25.s390x
libicu-57.1-4.fc25.s390x
perl-Getopt-Long-2.49.1-1.fc25.noarch
avahi-glib-0.6.32-4.fc25.s390x
python3-pip-8.1.2-2.fc25.noarch
python3-libcomps-0.1.7-5.fc25.s390x
python-slip-0.6.4-4.fc25.noarch
python2-libcomps-0.1.7-5.fc25.s390x
gc-7.4.4-1.fc25.s390x
s390utils-cmsfs-1.36.0-1.fc25.s390x
newt-python-0.52.19-2.fc25.s390x
valgrind-3.12.0-1.fc25.s390x
emacs-filesystem-25.1-3.fc25.noarch
libdb-utils-5.3.28-16.fc25.s390x
qt5-srpm-macros-5.7.1-1.fc25.noarch
elfutils-default-yama-scope-0.168-1.fc25.noarch
device-mapper-event-1.02.136-3.fc25.s390x
perl-Class-Inspector-1.31-2.fc25.noarch
poppler-0.45.0-2.fc25.s390x
libbasicobjects-0.1.1-29.fc25.s390x
libradosstriper1-10.2.4-2.fc25.s390x
libXxf86vm-devel-1.1.4-3.fc24.s390x
gsm-1.0.16-1.fc25.s390x
zziplib-0.13.62-7.fc24.s390x
libpaper-1.1.24-12.fc24.s390x
libini_config-1.3.0-29.fc25.s390x
snappy-devel-1.1.3-2.fc24.s390x
libcap-ng-devel-0.7.8-1.fc25.s390x
libxkbcommon-devel-0.7.1-1.fc25.s390x
kernel-4.9.5-200.fc25.s390x
audit-libs-2.7.3-1.fc25.s390x
nss-softokn-3.29.3-1.0.fc25.s390x
openssl-libs-1.0.2k-1.fc25.s390x
libkadm5-1.14.4-7.fc25.s390x
rpm-libs-4.13.0.1-1.fc25.s390x
nss-tools-3.29.3-1.0.fc25.s390x
perl-5.24.1-385.fc25.s390x
pcre2-utf32-10.23-4.fc25.s390x
util-linux-2.28.2-2.fc25.s390x
mesa-libGLES-devel-13.0.3-5.fc25.s390x
libICE-1.0.9-8.fc25.s390x
texlive-etoolbox-svn38031.2.2a-33.fc25.1.noarch
texlive-dvips-svn41149-33.fc25.1.noarch
texlive-latexconfig-svn40274-33.fc25.1.noarch
texlive-tex-ini-files-svn40533-33.fc25.1.noarch
texlive-qstest-svn15878.0-33.fc25.1.noarch
texlive-cmap-svn41168-33.fc25.1.noarch
texlive-luatex-bin-svn41091-33.20160520.fc25.1.s390x
texlive-mflogo-svn38628-33.fc25.1.noarch
texlive-sansmath-svn17997.1.1-33.fc25.1.noarch
texlive-unicode-data-svn39808-33.fc25.1.noarch
texlive-luaotfload-bin-svn34647.0-33.20160520.fc25.1.noarch
texlive-listings-svn37534.1.6-33.fc25.1.noarch
texlive-pstricks-svn41321-33.fc25.1.noarch
texlive-metalogo-svn18611.0.12-33.fc25.1.noarch
texlive-collection-latex-svn41011-33.20160520.fc25.1.noarch
ghostscript-9.20-6.fc25.s390x
kernel-4.10.5-200.fc25.s390x
pcre-static-8.40-5.fc25.s390x
python2-dnf-plugins-core-0.1.21-5.fc25.noarch
xkeyboard-config-2.20-2.fc25.noarch
libattr-2.4.47-16.fc24.s390x
acl-2.2.52-11.fc24.s390x
libvisual-0.4.0-20.fc24.s390x
libpcap-1.7.4-2.fc24.s390x
libutempter-1.1.6-8.fc24.s390x
libgudev-230-3.fc24.s390x
popt-devel-1.16-7.fc24.s390x
make-4.1-5.fc24.s390x
hicolor-icon-theme-0.15-3.fc24.noarch
setup-2.10.4-1.fc25.noarch
bash-4.3.43-4.fc25.s390x
nspr-4.13.1-1.fc25.s390x
libjpeg-turbo-1.5.1-0.fc25.s390x
perl-Socket-2.024-1.fc25.s390x
perl-HTTP-Tiny-0.070-1.fc25.noarch
ipset-6.29-1.fc25.s390x
python2-setuptools-25.1.1-1.fc25.noarch
gsettings-desktop-schemas-3.22.0-1.fc25.s390x
python3-setuptools-25.1.1-1.fc25.noarch
python-slip-dbus-0.6.4-4.fc25.noarch
python2-ply-3.8-2.fc25.noarch
dtc-1.4.2-1.fc25.s390x
guile-2.0.13-1.fc25.s390x
cronie-anacron-1.5.1-2.fc25.s390x
libXtst-1.2.3-1.fc25.s390x
iso-codes-3.70-1.fc25.noarch
s390utils-1.36.0-1.fc25.s390x
python-backports-ssl_match_hostname-3.5.0.1-3.fc25.noarch
fedora-cert-0.6.0.1-1.fc25.noarch
libstdc++-6.3.1-1.fc25.s390x
subversion-libs-1.9.5-1.fc25.s390x
libgfortran-6.3.1-1.fc25.s390x
libtasn1-4.10-1.fc25.s390x
dnf-plugin-system-upgrade-0.7.1-4.fc25.noarch
lvm2-2.02.167-3.fc25.s390x
libselinux-devel-2.5-13.fc25.s390x
perl-Time-Local-1.250-1.fc25.noarch
libtirpc-1.0.1-3.rc3.fc25.s390x
libradosstriper-devel-10.2.4-2.fc25.s390x
flac-libs-1.3.2-1.fc25.s390x
perl-Digest-1.17-366.fc25.noarch
teckit-2.5.1-15.fc24.s390x
libpath_utils-0.2.1-29.fc25.s390x
attr-2.4.47-16.fc24.s390x
usbredir-0.7.1-2.fc24.s390x
cairo-devel-1.14.8-1.fc25.s390x
lzo-devel-2.08-8.fc24.s390x
libcap-devel-2.25-2.fc25.s390x
opus-1.1.3-2.fc25.s390x
pcre-8.40-5.fc25.s390x
firewalld-filesystem-0.4.4.4-1.fc25.noarch
coreutils-8.25-16.fc25.s390x
krb5-devel-1.14.4-7.fc25.s390x
rpm-4.13.0.1-1.fc25.s390x
openldap-2.4.44-7.fc25.s390x
kernel-devel-4.10.5-200.fc25.s390x
pcre2-utf16-10.23-4.fc25.s390x
systemd-pam-231-14.fc25.s390x
glusterfs-fuse-3.10.0-1.fc25.s390x
libbsd-0.8.3-1.fc25.s390x
texlive-url-svn32528.3.4-33.fc25.1.noarch
texlive-dvips-bin-svn40987-33.20160520.fc25.1.s390x
texlive-index-svn24099.4.1beta-33.fc25.1.noarch
texlive-setspace-svn24881.6.7a-33.fc25.1.noarch
texlive-mathtools-svn38833-33.fc25.1.noarch
texlive-cm-svn32865.0-33.fc25.1.noarch
texlive-graphics-def-svn41879-33.fc25.1.noarch
texlive-mdwtools-svn15878.1.05.4-33.fc25.1.noarch
texlive-rsfs-svn15878.0-33.fc25.1.noarch
texlive-ucharcat-svn38907-33.fc25.1.noarch
texlive-fontspec-svn41262-33.fc25.1.noarch
texlive-showexpl-svn32737.v0.3l-33.fc25.1.noarch
texlive-pstricks-add-svn40744-33.fc25.1.noarch
texlive-beamer-svn36461.3.36-33.fc25.1.noarch
texlive-collection-basic-svn41149-33.20160520.fc25.1.noarch
ghostscript-x11-9.20-6.fc25.s390x
mock-1.3.4-1.fc25.noarch
pcre2-devel-10.23-4.fc25.s390x
rpm-build-4.13.0.1-1.fc25.s390x
xemacs-filesystem-21.5.34-20.20170124hgf412e9f093d4.fc25.noarch
gpg-pubkey-a0a7badb-52844296
readline-6.3-8.fc24.s390x
cpio-2.12-3.fc24.s390x
p11-kit-trust-0.23.2-2.fc24.s390x
qrencode-libs-3.4.2-6.fc24.s390x
GeoIP-1.6.9-2.fc24.s390x
libXcomposite-0.4.4-8.fc24.s390x
procps-ng-3.3.10-11.fc24.s390x
GConf2-3.2.6-16.fc24.s390x
xz-devel-5.2.2-2.fc24.s390x
fedora-logos-22.0.0-3.fc24.s390x
gpg-pubkey-e372e838-56fd7943
kmod-libs-23-1.fc25.s390x
perl-parent-0.236-1.fc25.noarch
perl-TermReadKey-2.37-1.fc25.s390x
dhcp-libs-4.3.5-1.fc25.s390x
ncurses-c++-libs-6.0-6.20160709.fc25.s390x
gzip-1.8-1.fc25.s390x
python3-gobject-base-3.22.0-1.fc25.s390x
python2-yubico-1.3.2-3.fc25.noarch
s390utils-ziomon-1.36.0-1.fc25.s390x
librepo-1.7.18-3.fc25.s390x
librsvg2-2.40.16-2.fc25.s390x
gnat-srpm-macros-4-1.fc25.noarch
python-decoratortools-1.8-12.fc25.noarch
m17n-db-1.7.0-7.fc25.noarch
glibc-common-2.24-4.fc25.s390x
e2fsprogs-libs-1.43.3-1.fc25.s390x
curl-7.51.0-4.fc25.s390x
libvorbis-1.3.5-1.fc25.s390x
gcc-gdb-plugin-6.3.1-1.fc25.s390x
perl-Time-HiRes-1.9741-1.fc25.s390x
npth-1.3-1.fc25.s390x
libcephfs1-10.2.4-2.fc25.s390x
wayland-devel-1.12.0-1.fc25.s390x
libxcb-devel-1.12-1.fc25.s390x
perl-encoding-2.19-5.fc25.s390x
python3-cssselect-0.9.2-1.fc25.noarch
gettext-libs-0.19.8.1-3.fc25.s390x
at-spi2-atk-devel-2.22.0-1.fc25.s390x
virglrenderer-0.5.0-1.20160411git61846f92f.fc25.s390x
pixman-devel-0.34.0-2.fc24.s390x
libnfs-devel-1.9.8-2.fc24.s390x
git-core-2.9.3-2.fc25.s390x
libX11-common-1.6.4-4.fc25.noarch
GeoIP-GeoLite-data-2017.01-1.fc25.noarch
file-libs-5.29-3.fc25.s390x
nss-softokn-devel-3.29.3-1.0.fc25.s390x
libblkid-2.28.2-2.fc25.s390x
python3-3.5.3-3.fc25.s390x
python2-hawkey-0.6.4-1.fc25.s390x
bind-libs-9.10.4-4.P6.fc25.s390x
vim-common-8.0.425-1.fc25.s390x
glib2-devel-2.50.3-1.fc25.s390x
mesa-libgbm-13.0.3-5.fc25.s390x
systemd-udev-231-14.fc25.s390x
gdk-pixbuf2-modules-2.36.5-1.fc25.s390x
texlive-ifxetex-svn19685.0.5-33.fc25.1.noarch
texlive-caption-svn41409-33.fc25.1.noarch
texlive-float-svn15878.1.3d-33.fc25.1.noarch
texlive-pdftex-def-svn22653.0.06d-33.fc25.1.noarch
texlive-xdvi-bin-svn40750-33.20160520.fc25.1.s390x
texlive-beton-svn15878.0-33.fc25.1.noarch
texlive-filecontents-svn24250.1.3-33.fc25.1.noarch
texlive-lm-math-svn36915.1.959-33.fc25.1.noarch
texlive-pslatex-svn16416.0-33.fc25.1.noarch
texlive-times-svn35058.0-33.fc25.1.noarch
texlive-breakurl-svn29901.1.40-33.fc25.1.noarch
texlive-filehook-svn24280.0.5d-33.fc25.1.noarch
texlive-pst-pdf-svn31660.1.1v-33.fc25.1.noarch
texlive-seminar-svn34011.1.62-33.fc25.1.noarch
texlive-xetexconfig-svn41133-33.fc25.1.noarch
python2-gluster-3.10.0-1.fc25.s390x
systemtap-3.1-2.fc25.s390x
python-rpm-macros-3-12.fc25.noarch
rpm-devel-4.13.0.1-1.fc25.s390x
vim-minimal-8.0.425-1.fc25.s390x
=== TEST BEGIN ===
Using CC: /home/fam/bin/cc

ERROR: libav check failed
       Make sure to have the libav libs and headers installed.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
Re: [Qemu-devel] [PATCH] Video and sound capture to a videofile through ffmpeg
Posted by no-reply@patchew.org 6 years, 11 months ago
Hi,

This series failed automatic build test. Please find the testing commands and
their output below. If you have docker installed, you can probably reproduce it
locally.

Subject: [Qemu-devel] [PATCH] Video and sound capture to a videofile through ffmpeg
Message-id: 1493894491-26130-1-git-send-email-vip-ak47@yandex.ru
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
make docker-test-quick@centos6
make docker-test-mingw@fedora
make docker-test-build@min-glib
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]         patchew/1493894491-26130-1-git-send-email-vip-ak47@yandex.ru -> patchew/1493894491-26130-1-git-send-email-vip-ak47@yandex.ru
Switched to a new branch 'test'
827fcdc Video and sound capture to a videofile through ffmpeg

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-y9kq66m0/src/dtc'...
Submodule path 'dtc': checked out '558cd81bdd432769b59bff01240c44f82cfb1a9d'
  BUILD   centos6
make[1]: Entering directory '/var/tmp/patchew-tester-tmp-y9kq66m0/src'
  ARCHIVE qemu.tgz
  ARCHIVE dtc.tgz
  COPY    RUNNER
    RUN test-quick in qemu:centos6 
Packages installed:
SDL-devel-1.2.14-7.el6_7.1.x86_64
ccache-3.1.6-2.el6.x86_64
epel-release-6-8.noarch
gcc-4.4.7-17.el6.x86_64
git-1.7.1-4.el6_7.1.x86_64
glib2-devel-2.28.8-5.el6.x86_64
libfdt-devel-1.4.0-1.el6.x86_64
make-3.81-23.el6.x86_64
package g++ is not installed
pixman-devel-0.32.8-1.el6.x86_64
tar-1.23-15.el6_8.x86_64
zlib-devel-1.2.3-29.el6.x86_64

Environment variables:
PACKAGES=libfdt-devel ccache     tar git make gcc g++     zlib-devel glib2-devel SDL-devel pixman-devel     epel-release
HOSTNAME=f74894737199
TERM=xterm
MAKEFLAGS= -j8
HISTSIZE=1000
J=8
USER=root
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
MAIL=/var/spool/mail/root
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
LANG=en_US.UTF-8
TARGET_LIST=
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
LOGNAME=root
LESSOPEN=||/usr/bin/lesspipe.sh %s
FEATURES= dtc
DEBUG=
G_BROKEN_FILENAMES=1
CCACHE_HASHDIR=
_=/usr/bin/env

Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu --prefix=/var/tmp/qemu-build/install
No C++ compiler available; disabling C++ specific optional code

ERROR: libav check failed
       Make sure to have the libav libs and headers installed.

tests/docker/Makefile.include:118: recipe for target 'docker-run' failed
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory '/var/tmp/patchew-tester-tmp-y9kq66m0/src'
tests/docker/Makefile.include:149: recipe for target 'docker-run-test-quick@centos6' failed
make: *** [docker-run-test-quick@centos6] Error 2
=== OUTPUT END ===

Test command exited with code: 2


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
Re: [Qemu-devel] [PATCH] Video and sound capture to a videofile through ffmpeg
Posted by Marc-André Lureau 6 years, 11 months ago
Hi

On Thu, May 4, 2017 at 2:42 PM Alex K <vip-ak47@yandex.ru> wrote:

> Hello everyone,
>
> I've made a patch that adds ability to record video of what's going on
> inside qemu. It uses ffmpeg libraries. Basically, the patch adds
> 2 new commands to the console:
> capture_start path framerate
> capture_stop
>
> path is required
> framerate could be 24, 25, 30 or 60. Default is 60
> video codec is always h264
>
> The patch uses ffmpeg so you will need to install these packages:
> ffmpeg libavformat-dev libavcodec-dev libavutil-dev libswscale-dev
>
>
Why not use spice or vnc to do the recording in a seperate process? This
would not require any change in qemu. If there is already a client
connected, it would need better multi-client support though (spice has some
experimental support).


> This is my first time posting here, so please correct me if I'm doing
> something wrong


> Signed-off-by: Alex K <vip-ak47@yandex.ru>
> ---
>  configure                          |  20 +
>  default-configs/i386-softmmu.mak   |   1 +
>  default-configs/x86_64-softmmu.mak |   1 +
>  hmp-commands.hx                    |  34 ++
>  hmp.h                              |   2 +
>  hw/display/Makefile.objs           |   2 +
>  hw/display/capture.c               | 761
> +++++++++++++++++++++++++++++++++++++
>  hw/display/capture.h               |  78 ++++
>  8 files changed, 899 insertions(+)
>  create mode 100644 hw/display/capture.c
>  create mode 100644 hw/display/capture.h
>
> diff --git a/configure b/configure
> index 48a9370..a6ddbf0 100755
> --- a/configure
> +++ b/configure
> @@ -281,6 +281,7 @@ opengl=""
>  opengl_dmabuf="no"
>  avx2_opt="no"
>  zlib="yes"
> +libav="yes"
>  lzo=""
>  snappy=""
>  bzip2=""
> @@ -1993,6 +1994,25 @@ if test "$seccomp" != "no" ; then
>          seccomp="no"
>      fi
>  fi
> +#########################################
> +# libav check
> +
> +if test "$libav" != "no" ; then
> +    cat > $TMPC << EOF
> +#include <libavcodec/avcodec.h>
> +#include <libavformat/avformat.h>
> +
> +int main(void){ av_register_all(); avcodec_register_all(); return 0; }
> +EOF
> +    if compile_prog "" "-lm -lpthread -lavformat -lavcodec -lavutil
> -lswscale -lswresample" ; then
> +        :
> +    else
> +        error_exit "libav check failed" \
> +            "Make sure to have the libav libs and headers installed."
> +    fi
> +fi
> +LIBS="$LIBS -lm -lpthread -lavformat -lavcodec -lavutil -lswscale
> -lswresample"
> +
>  ##########################################
>  # xen probe
>
> diff --git a/default-configs/i386-softmmu.mak
> b/default-configs/i386-softmmu.mak
> index d2ab2f6..35ce513 100644
> --- a/default-configs/i386-softmmu.mak
> +++ b/default-configs/i386-softmmu.mak
> @@ -59,3 +59,4 @@ CONFIG_SMBIOS=y
>  CONFIG_HYPERV_TESTDEV=$(CONFIG_KVM)
>  CONFIG_PXB=y
>  CONFIG_ACPI_VMGENID=y
> +CONFIG_CAPTURE=y
> diff --git a/default-configs/x86_64-softmmu.mak
> b/default-configs/x86_64-softmmu.mak
> index 9bde2f1..b9a7175 100644
> --- a/default-configs/x86_64-softmmu.mak
> +++ b/default-configs/x86_64-softmmu.mak
> @@ -59,3 +59,4 @@ CONFIG_SMBIOS=y
>  CONFIG_HYPERV_TESTDEV=$(CONFIG_KVM)
>  CONFIG_PXB=y
>  CONFIG_ACPI_VMGENID=y
> +CONFIG_CAPTURE=y
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 0aca984..9066aac 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -1809,3 +1809,37 @@ ETEXI
>  STEXI
>  @end table
>  ETEXI
> +
> +    {
> +        .name       = "capture_start",
> +        .args_type  = "filename:F,fps:i?",
> +        .params     = "filename [framerate]",
> +        .help       = "Start video capture",
> +        .cmd        = hmp_capture_start,
> +    },
> +
> +STEXI
> +@item capture_start @var{filename} [@var{framerate}]
> +@findex capture_start
> +Start video capture.
> +Capture video into @var{filename} with framerate @var{framerate}.
> +
> +Defaults:
> +@itemize @minus
> +@item framerate = 60
> +@end itemize
> +ETEXI
> +
> +    {
> +        .name       = "capture_stop",
> +        .args_type  = "",
> +        .params     = "",
> +        .help       = "Stop video capture",
> +        .cmd        = hmp_capture_stop,
> +    },
> +
> +STEXI
> +@item capture_stop
> +@findex capture_stop
> +Stop video capture.
> +ETEXI
> diff --git a/hmp.h b/hmp.h
> index 799fd37..36c7a4d 100644
> --- a/hmp.h
> +++ b/hmp.h
> @@ -138,5 +138,7 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const
> QDict *qdict);
>  void hmp_info_dump(Monitor *mon, const QDict *qdict);
>  void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict);
>  void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict);
> +void hmp_capture_start(Monitor *mon, const QDict *qdict);
> +void hmp_capture_stop(Monitor *mon, const QDict *qdict);
>
>  #endif
> diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
> index 551c050..a918896 100644
> --- a/hw/display/Makefile.objs
> +++ b/hw/display/Makefile.objs
> @@ -20,6 +20,8 @@ common-obj-$(CONFIG_ZAURUS) += tc6393xb.o
>
>  common-obj-$(CONFIG_MILKYMIST_TMU2) += milkymist-tmu2.o
>
> +obj-$(CONFIG_CAPTURE) += capture.o
> +
>  obj-$(CONFIG_OMAP) += omap_dss.o
>  obj-$(CONFIG_OMAP) += omap_lcdc.o
>  obj-$(CONFIG_PXA2XX) += pxa2xx_lcd.o
> diff --git a/hw/display/capture.c b/hw/display/capture.c
> new file mode 100644
> index 0000000..c89aaa0
> --- /dev/null
> +++ b/hw/display/capture.c
> @@ -0,0 +1,761 @@
> +#include "capture.h"
> +
> +static void sound_capture_notify(void *opaque, audcnotification_e cmd)
> +{
> +    (void) opaque;
> +    (void) cmd;
> +}
> +
> +static void sound_capture_destroy(void *opaque)
> +{
> +    (void) opaque;
> +}
> +
> +static void write_empty_sound(void *opaque, struct
> CaptureThreadWorkerData *data)
> +{
> +    AVFormatContext *oc = data->oc;
> +    OutputStream *ost = &data->audio_stream;
> +
> +    AVFrame *tmp = ost->tmp_frame;
> +    ost->tmp_frame = ost->empty_frame;
> +    double newlen = write_audio_frame(oc, ost);
> +    ost->tmp_frame = tmp;
> +
> +    if (newlen >= 0.0) {
> +        data->video_len = newlen;
> +    }
> +}
> +
> +static void sound_capture_capture(void *opaque, void *buf, int size)
> +{
> +    int bufsize = size;
> +    SoundCapture *wav = opaque;
> +    AVFrame *frame;
> +    int sampleCount;
> +    double len1, len2, delta;
> +    int8_t *q;
> +    int buffpos;
> +
> +    /*int32_t n = 0;
> +    int i = 0;
> +    for(i=0;i<size;i++) {
> +        int8_t a = ((int8_t*)buf)[i];
> +        n+=a;
> +    }
> +    wav->bytes += size;
> +    if(n==0)
> +        return;
> +    printf("%d\n",n);*/
> +    frame = wav->data->audio_stream.tmp_frame;
> +    sampleCount = frame->nb_samples * 4;
> +
> +    len1 = wav->data->video_len;
> +    len2 = wav->data->video_len2;
> +    delta = len1 - len2;
> +
> +    while (delta < 0.0) {
> +        write_empty_sound(opaque, wav->data);
> +
> +        len1 = wav->data->video_len;
> +        len2 = wav->data->video_len2;
> +        delta = len1 - len2;
> +    }
> +
> +    q = (int8_t *)frame->data[0];
> +
> +    buffpos = 0;
> +    while (bufsize > 0) {
> +        int start = wav->bufferPos;
> +        int freeSpace = sampleCount - start;
> +
> +        int willWrite = freeSpace;
> +        if (willWrite > bufsize) {
> +            willWrite = bufsize;
> +        }
> +
> +        memcpy(q + start, buf + buffpos, willWrite);
> +        bufsize -= willWrite;
> +        buffpos += willWrite;
> +
> +        freeSpace = sampleCount - start - willWrite;
> +
> +        if (freeSpace == 0) {
> +            double newlen = write_audio_frame(wav->data->oc,
> &wav->data->audio_stream);
> +
> +            if (newlen >= 0.0) {
> +                wav->data->video_len = newlen;
> +            }
> +            wav->bufferPos = 0;
> +        } else {
> +            wav->bufferPos = start + willWrite;
> +        }
> +    }
> +}
> +
> +static void sound_capture_capture_destroy(void *opaque)
> +{
> +    SoundCapture *wav = opaque;
> +
> +    AUD_del_capture (wav->cap, wav);
> +}
> +
> +static int sound_capture_start_capture(struct CaptureThreadWorkerData
> *data)
> +{
> +    Monitor *mon = cur_mon;
> +    SoundCapture *wav;
> +    struct audsettings as;
> +    struct audio_capture_ops ops;
> +    CaptureVoiceOut *cap;
> +
> +    as.freq = 44100;
> +    as.nchannels = 2;
> +    as.fmt = AUD_FMT_S16;
> +    as.endianness = 0;
> +
> +    ops.notify = sound_capture_notify;
> +    ops.capture = sound_capture_capture;
> +    ops.destroy = sound_capture_destroy;
> +
> +    wav = g_malloc0(sizeof(*wav));
> +
> +
> +    cap = AUD_add_capture(&as, &ops, wav);
> +    if (!cap) {
> +        monitor_printf(mon, "Failed to add audio capture\n");
> +        goto error_free;
> +    }
> +
> +    wav->bufferPos = 0;
> +    wav->data = data;
> +    wav->cap = cap;
> +    data->soundCapture = wav;
> +    return 0;
> +
> +error_free:
> +    g_free(wav);
> +    return -1;
> +}
> +
> +static int write_frame(AVFormatContext *fmt_ctx, const AVRational
> *time_base,
> +                        AVStream *st, AVPacket *pkt)
> +{
> +    /* rescale output packet timestamp values from codec to stream
> timebase */
> +    av_packet_rescale_ts(pkt, *time_base, st->time_base);
> +    pkt->stream_index = st->index;
> +    /* Write the compressed frame to the media file. */
> +    return av_interleaved_write_frame(fmt_ctx, pkt);
> +}
> +
> +/* Add an output stream. */
> +static void add_video_stream(OutputStream *ost, AVFormatContext *oc,
> +                       AVCodec **codec,
> +                       enum AVCodecID codec_id,
> +                       int w, int h, int bit_rate, int framerate)
> +{
> +    AVCodecContext *c;
> +    /* find the encoder */
> +    *codec = avcodec_find_encoder(codec_id);
> +    if (!(*codec)) {
> +        fprintf(stderr, "Could not find encoder for '%s'\n",
> +                avcodec_get_name(codec_id));
> +        exit(1);
> +    }
> +    ost->st = avformat_new_stream(oc, *codec);
> +    if (!ost->st) {
> +        fprintf(stderr, "Could not allocate stream\n");
> +        exit(1);
> +    }
> +    ost->st->id = oc->nb_streams - 1;
> +    c = ost->st->codec;
> +    if ((*codec)->type == AVMEDIA_TYPE_VIDEO) {
> +        c->codec_id = codec_id;
> +        c->bit_rate = bit_rate;
> +        /* Resolution must be a multiple of two. */
> +        c->width    = w;
> +        c->height   = h;
> +        /* timebase: This is the fundamental unit of time (in seconds) in
> terms
> +         * of which frame timestamps are represented. For fixed-fps
> content,
> +         * timebase should be 1/framerate and timestamp increments should
> be
> +         * identical to 1. */
> +        ost->st->time_base = (AVRational){ 1, framerate };
> +        c->time_base = ost->st->time_base;
> +        c->gop_size  = 12; /* emit one intra frame every 12 frames at
> most */
> +        c->pix_fmt   = AV_PIX_FMT_YUV420P;
> +        if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
> +            /* just for testing, we also add B frames */
> +            c->max_b_frames = 2;
> +        }
> +        if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
> +            /* Needed to avoid using macroblocks in which some coeffs
> overflow.
> +             * This does not happen with normal video, it just happens
> here as
> +             * the motion of the chroma plane does not match the luma
> plane. */
> +            c->mb_decision = 2;
> +        }
> +    } else {
> +        fprintf(stderr, "Wrong stream type\n");
> +        exit(1);
> +    }
> +    /* Some formats want stream headers to be separate. */
> +    if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
> +        c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
> +    }
> +}
> +
> +static void add_audio_stream(OutputStream *ost, AVFormatContext *oc,
> +                             AVCodec **codec,
> +                             enum AVCodecID codec_id)
> +{
> +    AVCodecContext *c;
> +    int i;
> +    /* find the encoder */
> +    *codec = avcodec_find_encoder(codec_id);
> +    if (!(*codec)) {
> +        fprintf(stderr, "Could not find encoder for '%s'\n",
> +                avcodec_get_name(codec_id));
> +        exit(1);
> +    }
> +    ost->st = avformat_new_stream(oc, *codec);
> +    if (!ost->st) {
> +        fprintf(stderr, "Could not allocate stream\n");
> +        exit(1);
> +    }
> +    ost->st->id = oc->nb_streams - 1;
> +    c = ost->st->codec;
> +    if ((*codec)->type == AVMEDIA_TYPE_AUDIO) {
> +        c->sample_fmt = AV_SAMPLE_FMT_FLTP;
> +        c->bit_rate    = 128000;
> +        c->sample_rate = 44100;
> +        c->channels    =
> av_get_channel_layout_nb_channels(c->channel_layout);
> +        c->channel_layout = AV_CH_LAYOUT_STEREO;
> +        if ((*codec)->channel_layouts) {
> +            c->channel_layout = (*codec)->channel_layouts[0];
> +            for (i = 0; (*codec)->channel_layouts[i]; i++) {
> +                if ((*codec)->channel_layouts[i] == AV_CH_LAYOUT_STEREO) {
> +                    c->channel_layout = AV_CH_LAYOUT_STEREO;
> +                }
> +            }
> +        }
> +        c->channels   =
> av_get_channel_layout_nb_channels(c->channel_layout);
> +        ost->st->time_base = (AVRational){ 1, c->sample_rate };
> +    } else {
> +        fprintf(stderr, "Wrong stream type\n");
> +        exit(1);
> +    }
> +    /* Some formats want stream headers to be separate. */
> +    if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
> +        c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
> +    }
> +}
> +/**************************************************************/
> +/* audio output */
> +static AVFrame *alloc_audio_frame(enum AVSampleFormat sample_fmt,
> +                                  uint64_t channel_layout,
> +                                  int sample_rate, int nb_samples)
> +{
> +    AVFrame *frame = av_frame_alloc();
> +    int ret;
> +    if (!frame) {
> +        fprintf(stderr, "Error allocating an audio frame\n");
> +        exit(1);
> +    }
> +    frame->format = sample_fmt;
> +    frame->channel_layout = channel_layout;
> +    frame->sample_rate = sample_rate;
> +    frame->nb_samples = nb_samples;
> +    if (nb_samples) {
> +        ret = av_frame_get_buffer(frame, 0);
> +        if (ret < 0) {
> +            fprintf(stderr, "Error allocating an audio buffer\n");
> +            exit(1);
> +        }
> +    }
> +    return frame;
> +}
> +
> +static void open_audio(AVFormatContext *oc, AVCodec *codec,
> +                       OutputStream *ost, AVDictionary *opt_arg)
> +{
> +    AVCodecContext *c;
> +    int nb_samples;
> +    int ret;
> +    AVDictionary *opt = NULL;
> +    c = ost->st->codec;
> +    /* open it */
> +    av_dict_copy(&opt, opt_arg, 0);
> +    ret = avcodec_open2(c, codec, &opt);
> +    av_dict_free(&opt);
> +    if (ret < 0) {
> +        fprintf(stderr, "Could not open audio codec: %s\n",
> av_err2str(ret));
> +        exit(1);
> +    }
> +    nb_samples = c->frame_size;
> +    ost->frame     = alloc_audio_frame(c->sample_fmt, c->channel_layout,
> +                                       c->sample_rate, nb_samples);
> +
> +    ost->tmp_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16,
> c->channel_layout,
> +                                       c->sample_rate, nb_samples);
> +    ost->tmp_frame->pts = 0;
> +
> +    ost->empty_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16,
> c->channel_layout,
> +                                       c->sample_rate, nb_samples);
> +    int sampleCount = nb_samples * 4;
> +    int8_t *q = (int8_t *)ost->empty_frame->data[0];
> +    memset(q, 0, sampleCount);
> +
> +    /* create resampler context */
> +    ost->swr_ctx = swr_alloc();
> +    if (!ost->swr_ctx) {
> +        fprintf(stderr, "Could not allocate resampler context\n");
> +        exit(1);
> +    }
> +    /* set options */
> +    av_opt_set_int       (ost->swr_ctx, "in_channel_count",
> c->channels,       0);
> +    av_opt_set_int       (ost->swr_ctx, "in_sample_rate",
> c->sample_rate,    0);
> +    av_opt_set_sample_fmt(ost->swr_ctx, "in_sample_fmt",
>  AV_SAMPLE_FMT_S16, 0);
> +    av_opt_set_int       (ost->swr_ctx, "out_channel_count",
> c->channels,       0);
> +    av_opt_set_int       (ost->swr_ctx, "out_sample_rate",
>  c->sample_rate,    0);
> +    av_opt_set_sample_fmt(ost->swr_ctx, "out_sample_fmt",
> c->sample_fmt,     0);
> +    /* initialize the resampling context */
> +    if (swr_init(ost->swr_ctx) < 0) {
> +        fprintf(stderr, "Failed to initialize the resampling context\n");
> +        exit(1);
> +    }
> +}
> +
> +/*
> + * encode one audio frame and send it to the muxer
> + */
> +static double write_audio_frame(AVFormatContext *oc, OutputStream *ost)
> +{
> +    AVCodecContext *c;
> +    AVPacket pkt = { 0 };
> +    AVFrame *frame;
> +    int ret;
> +    int got_packet;
> +    int dst_nb_samples;
> +    av_init_packet(&pkt);
> +    c = ost->st->codec;
> +    frame = ost->tmp_frame;
> +    frame->pts = frame->pts + 1;
> +    double videolen = -1.0;
> +    if (frame) {
> +        /* convert samples from native format to destination codec format,
> +         * using the resampler */
> +        /* compute destination number of samples */
> +        dst_nb_samples = av_rescale_rnd(
> +            swr_get_delay(ost->swr_ctx, c->sample_rate) +
> frame->nb_samples,
> +            c->sample_rate, c->sample_rate, AV_ROUND_UP);
> +        av_assert0(dst_nb_samples == frame->nb_samples);
> +        /* when we pass a frame to the encoder, it may keep a reference
> to it
> +         * internally;
> +         * make sure we do not overwrite it here
> +         */
> +        ret = av_frame_make_writable(ost->frame);
> +        if (ret < 0) {
> +            exit(1);
> +        }
> +        /* convert to destination format */
> +        ret = swr_convert(ost->swr_ctx,
> +                          ost->frame->data, dst_nb_samples,
> +                          (const uint8_t **)frame->data,
> frame->nb_samples);
> +        if (ret < 0) {
> +            fprintf(stderr, "Error while converting\n");
> +            exit(1);
> +        }
> +        frame = ost->frame;
> +        frame->pts = av_rescale_q(ost->samples_count,
> +                                  (AVRational){1, c->sample_rate},
> +                                  c->time_base);
> +
> +        videolen = (double)frame->pts / c->sample_rate;
> +        ost->samples_count += dst_nb_samples;
> +    }
> +    ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet);
> +    if (ret < 0) {
> +        fprintf(stderr, "Error encoding audio frame: %s\n",
> av_err2str(ret));
> +        exit(1);
> +    }
> +    if (got_packet) {
> +        ret = write_frame(oc, &c->time_base, ost->st, &pkt);
> +        if (ret < 0) {
> +            fprintf(stderr, "Error while writing audio frame: %s\n",
> +                    av_err2str(ret));
> +            exit(1);
> +        }
> +    }
> +    return videolen;
> +}
> +static void write_delayed_audio_frames(void)
> +{
> +    struct CaptureThreadWorkerData *data = capture_get_data();
> +    AVFormatContext *oc = data->oc;
> +    OutputStream *ost = &data->audio_stream;
> +    AVCodecContext *c = ost->st->codec;
> +
> +    AVPacket pkt = { 0 };
> +    pkt.data = NULL;
> +    pkt.size = 0;
> +    av_init_packet(&pkt);
> +    int got_output = 1;
> +    int ret;
> +    while (got_output) {
> +
> +        ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);
> +        if (ret < 0) {
> +            fprintf(stderr, "Error encoding frame\n");
> +            exit(1);
> +        }
> +
> +        if (got_output) {
> +            ret = write_frame(oc, &c->time_base, ost->st, &pkt);
> +            av_free_packet(&pkt);
> +        }
> +    }
> +}
> +/**************************************************************/
> +/* video output */
> +static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int
> height)
> +{
> +    AVFrame *picture;
> +    int ret;
> +    picture = av_frame_alloc();
> +    if (!picture) {
> +        return NULL;
> +    }
> +    picture->format = pix_fmt;
> +    picture->width  = width;
> +    picture->height = height;
> +    /* allocate the buffers for the frame data */
> +    ret = av_frame_get_buffer(picture, 32);
> +    if (ret < 0) {
> +        fprintf(stderr, "Could not allocate frame data.\n");
> +        exit(1);
> +    }
> +    return picture;
> +}
> +
> +static void open_video(AVFormatContext *oc, AVCodec *codec,
> +                       OutputStream *ost, AVDictionary *opt_arg)
> +{
> +    int ret;
> +    AVCodecContext *c = ost->st->codec;
> +    AVDictionary *opt = NULL;
> +    av_dict_copy(&opt, opt_arg, 0);
> +    /* open the codec */
> +    ret = avcodec_open2(c, codec, &opt);
> +    av_dict_free(&opt);
> +    if (ret < 0) {
> +        fprintf(stderr, "Could not open video codec: %s\n",
> av_err2str(ret));
> +        exit(1);
> +    }
> +    /* allocate and init a re-usable frame */
> +    ost->frame = alloc_picture(c->pix_fmt, c->width, c->height);
> +    if (!ost->frame) {
> +        fprintf(stderr, "Could not allocate video frame\n");
> +        exit(1);
> +    }
> +}
> +
> +static AVFrame *get_filled_image(void)
> +{
> +    QemuConsole *con = qemu_console_lookup_by_index(0);
> +    DisplaySurface *surface;
> +    surface = qemu_console_surface(con);
> +
> +    if (con == NULL) {
> +        fprintf(stderr, "There is no QemuConsole I can screendump
> from.\n");
> +        return NULL;
> +    }
> +
> +    int ourW = pixman_image_get_width(surface->image);
> +    int ourH = pixman_image_get_height(surface->image);
> +
> +    AVFrame *pict = alloc_picture(AV_PIX_FMT_RGB32, ourW, ourH);
> +    av_frame_make_writable(pict);
> +
> +    uint8_t* picdata = (uint8_t *)pixman_image_get_data(surface->image);
> +
> +    memcpy(pict->data[0], picdata, ourW * ourH * 4);
> +    return pict;
> +}
> +
> +static AVFrame *get_video_frame(OutputStream *ost, int64_t frame)
> +{
> +    AVCodecContext *c = ost->st->codec;
> +
> +    AVFrame *pict = get_filled_image();
> +    if (pict == NULL) {
> +        return NULL;
> +    }
> +
> +    struct SwsContext *swsContext = sws_getContext(
> +        pict->width, pict->height, pict->format,
> +        ost->frame->width, ost->frame->height,
> +        ost->frame->format, SWS_BICUBIC, NULL, NULL, NULL);
> +    sws_scale(swsContext, (const uint8_t * const *)pict->data,
> +              pict->linesize , 0, c->height, ost->frame->data,
> +              ost->frame->linesize);
> +
> +    av_frame_free(&pict);
> +    sws_freeContext(swsContext);
> +
> +    if (frame <= ost->frame->pts) {
> +        ost->frame->pts = ost->frame->pts + 1;
> +    } else {
> +        ost->frame->pts = frame;
> +    }
> +
> +    return ost->frame;
> +}
> +/*
> + * encode one video frame and send it to the muxer
> + */
> +static void write_video_frame(AVFormatContext *oc,
> +                              OutputStream *ost, int frameNumber)
> +{
> +    int ret;
> +    AVCodecContext *c;
> +    AVFrame *frame;
> +    int got_packet = 0;
> +    AVPacket pkt = { 0 };
> +
> +    frame = get_video_frame(ost, frameNumber);
> +    if (frame == NULL) {
> +        return;
> +    }
> +
> +    c = ost->st->codec;
> +    av_init_packet(&pkt);
> +    /* encode the image */
> +    ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
> +    if (ret < 0) {
> +        fprintf(stderr, "Error encoding video frame: %s\n",
> av_err2str(ret));
> +        exit(1);
> +    }
> +    if (got_packet) {
> +        ret = write_frame(oc, &c->time_base, ost->st, &pkt);
> +    } else {
> +        ret = 0;
> +    }
> +    if (ret < 0) {
> +        fprintf(stderr, "Error while writing video frame: %s\n",
> av_err2str(ret));
> +        return;
> +    }
> +}
> +
> +static void write_delayed_video_frames(void)
> +{
> +    struct CaptureThreadWorkerData *data = capture_get_data();
> +    AVFormatContext *oc = data->oc;
> +    OutputStream *ost = &data->stream;
> +    AVCodecContext *c = ost->st->codec;
> +
> +    AVPacket pkt = { 0 };
> +    pkt.data = NULL;
> +    pkt.size = 0;
> +    av_init_packet(&pkt);
> +    int got_output = 1;
> +    int ret;
> +    while (got_output) {
> +        ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
> +        if (ret < 0) {
> +            fprintf(stderr, "Error encoding frame\n");
> +            exit(1);
> +        }
> +
> +        if (got_output) {
> +            ret = write_frame(oc, &c->time_base, ost->st, &pkt);
> +            av_free_packet(&pkt);
> +        }
> +    }
> +}
> +
> +static void close_stream(AVFormatContext *oc, OutputStream *ost)
> +{
> +    avcodec_close(ost->st->codec);
> +    av_frame_free(&ost->frame);
> +    av_frame_free(&ost->tmp_frame);
> +    sws_freeContext(ost->sws_ctx);
> +    swr_free(&ost->swr_ctx);
> +}
> +
> +static int ends_with(const char *str, const char *suffix)
> +{
> +    if (!str || !suffix) {
> +        return 0;
> +    }
> +    size_t lenstr = strlen(str);
> +    size_t lensuffix = strlen(suffix);
> +    if (lensuffix >  lenstr) {
> +        return 0;
> +    }
> +    return strncmp(str + lenstr - lensuffix, suffix, lensuffix) == 0;
> +}
> +
> +static struct CaptureThreadWorkerData *capture_get_data(void)
> +{
> +    static struct CaptureThreadWorkerData data = {0};
> +    return &data;
> +}
> +
> +static void capture_timer(void *p)
> +{
> +    struct CaptureThreadWorkerData *data = (struct
> CaptureThreadWorkerData *)p;
> +    if (!data->is_capturing) {
> +        return;
> +    }
> +
> +    int64_t n = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> +    int64_t intdelta = (n - data->time) / 100000;
> +    double delta = (double)intdelta / 10000;
> +    data->delta += delta;
> +    data->time   = n;
> +
> +    while (data->delta > (1.0 / data->framerate)) {
> +        data->delta -= 1.0 / data->framerate;
> +
> +        av_frame_make_writable(data->stream.frame);
> +        write_video_frame(data->oc, &data->stream,
> +            (int)(floor(data->video_len * (double)data->framerate +
> 0.5)));
> +    }
> +    data->video_len2 = data->video_len2 + delta;
> +
> +    int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> +    if (data->is_capturing) {
> +        timer_mod_ns(data->timer, now + 10000000);
> +    }
> +}
> +
> +static void capture_powerdown_req(void)
> +{
> +    if (capture_stop()) {
> +        printf("Capture stoped\n");
> +    }
> +}
> +
> +void hmp_capture_start(Monitor *mon, const QDict *qdict)
> +{
> +    const char *filename = qdict_get_str(qdict, "filename");
> +    int framerate = qdict_get_try_int(qdict, "fps", 60);
> +
> +    struct CaptureThreadWorkerData *data = capture_get_data();
> +    if (!data->is_loaded) {
> +        av_register_all();
> +        avcodec_register_all();
> +        data->codec = avcodec_find_encoder(AV_CODEC_ID_H264);
> +        if (!data->codec) {
> +            fprintf(stderr, "codec not found\n");
> +            return;
> +        }
> +        data->c = NULL;
> +        data->is_loaded = 1;
> +        atexit(capture_powerdown_req);
> +    }
> +
> +    if (data->is_capturing == 0) {
> +        if (!ends_with(filename, ".mp4")
> +         && !ends_with(filename, ".mpg")
> +         && !ends_with(filename, ".avi")) {
> +            monitor_printf(mon, "Invalid file format, use .mp4 or
> .mpg\n");
> +            return;
> +        }
> +        if (framerate != 60 && framerate != 30
> +         && framerate != 24 && framerate != 25) {
> +            monitor_printf(mon, "Invalid framerate, valid values are: 24,
> 25, 30, 60\n");
> +            return;
> +        }
> +        monitor_printf(mon, "Capture started to file: %s\n", filename);
> +
> +        data->framerate = framerate;
> +        data->frame = 0;
> +
> +        data->delta = 0.0;
> +        data->time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> +
> +        data->video_len = 0.0;
> +        data->video_len2 = 0.0;
> +
> +        QemuConsole *con = qemu_console_lookup_by_index(0);
> +        DisplaySurface *surface;
> +        surface = qemu_console_surface(con);
> +        int resW = pixman_image_get_width(surface->image);
> +        int resH = pixman_image_get_height(surface->image);
> +
> +        OutputStream video_st = { 0 };
> +        data->stream = video_st;
> +        OutputStream audio_st = { 0 };
> +        data->audio_stream = audio_st;
> +
> +        avformat_alloc_output_context2(&data->oc, NULL, "avi", filename);
> +        AVOutputFormat *fmt;
> +        fmt = data->oc->oformat;
> +
> +        add_video_stream(&data->stream, data->oc, &data->codec,
> +                         fmt->video_codec, resW, resH, 4000000,
> framerate);
> +        add_audio_stream(&data->audio_stream, data->oc,
> &data->audio_codec,
> +                         fmt->audio_codec);
> +
> +        open_video(data->oc, data->codec, &data->stream, NULL);
> +        open_audio(data->oc, data->audio_codec, &data->audio_stream,
> NULL);
> +
> +        int ret = avio_open(&data->oc->pb, filename, AVIO_FLAG_WRITE);
> +        if (ret < 0) {
> +            fprintf(stderr, "Could not open '%s': %s\n", filename,
> +                    av_err2str(ret));
> +            return;
> +        }
> +        ret = avformat_write_header(data->oc, NULL);
> +        if (ret < 0) {
> +            fprintf(stderr, "Error occurred when opening output file:
> %s\n",
> +                    av_err2str(ret));
> +            return;
> +        }
> +
> +        data->is_capturing = 1;
> +
> +        if (data->timer) {
> +            timer_free(data->timer);
> +        }
> +        data->timer = timer_new_ns(QEMU_CLOCK_REALTIME, capture_timer,
> data);
> +        int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> +        timer_mod_ns(data->timer, now + 1000000000 / data->framerate);
> +
> +        sound_capture_start_capture(data);
> +    } else {
> +        monitor_printf(mon, "Already capturing\n");
> +    }
> +}
> +
> +static int capture_stop(void)
> +{
> +    struct CaptureThreadWorkerData *data = capture_get_data();
> +    if (!data->is_loaded) {
> +        return 0;
> +    }
> +
> +    if (data->is_capturing) {
> +        data->is_capturing = 0;
> +
> +        write_delayed_video_frames();
> +        write_delayed_audio_frames();
> +
> +        av_write_trailer(data->oc);
> +        close_stream(data->oc, &data->stream);
> +        close_stream(data->oc, &data->audio_stream);
> +        avio_closep(&data->oc->pb);
> +        avformat_free_context(data->oc);
> +
> +        sound_capture_capture_destroy(data->soundCapture);
> +        return 1;
> +    }
> +    return 0;
> +}
> +
> +void hmp_capture_stop(Monitor *mon, const QDict *qdict)
> +{
> +    if (capture_stop()) {
> +        monitor_printf(mon, "Capture stopped\n");
> +    } else {
> +        monitor_printf(mon, "Not capturing\n");
> +    }
> +}
> diff --git a/hw/display/capture.h b/hw/display/capture.h
> new file mode 100644
> index 0000000..73c79f1
> --- /dev/null
> +++ b/hw/display/capture.h
> @@ -0,0 +1,78 @@
> +#ifndef CAPTURE_H
> +#define CAPTURE_H
> +
> +#include "qemu/osdep.h"
> +#include "monitor/monitor.h"
> +#include "ui/console.h"
> +#include "qemu/timer.h"
> +#include "audio/audio.h"
> +
> +#include <libavcodec/avcodec.h>
> +#include <libavformat/avformat.h>
> +#include "libavutil/frame.h"
> +#include "libavutil/imgutils.h"
> +#include <libswscale/swscale.h>
> +#include <libavutil/avassert.h>
> +#include <libavutil/channel_layout.h>
> +#include <libavutil/opt.h>
> +#include <libavutil/mathematics.h>
> +#include <libavutil/timestamp.h>
> +#include <libswresample/swresample.h>
> +
> +void hmp_capture_start(Monitor *mon, const QDict *qdict);
> +void hmp_capture_stop(Monitor *mon, const QDict *qdict);
> +
> +typedef struct OutputStream {
> +    AVStream *st;
> +    int samples_count;
> +    AVFrame *frame;
> +    AVFrame *tmp_frame;
> +    AVFrame *empty_frame;
> +    struct SwsContext *sws_ctx;
> +    struct SwrContext *swr_ctx;
> +} OutputStream;
> +
> +struct CaptureThreadWorkerData {
> +    QEMUTimer *timer;
> +    int frame;
> +    int is_loaded;
> +    int is_capturing;
> +    int framerate;
> +    double video_len;
> +    double video_len2;
> +    CaptureState *wavCapture;
> +
> +    AVCodec *codec;
> +    AVCodecContext *c;
> +
> +    AVFrame *picture;
> +    AVPacket pkt;
> +
> +    AVCodec *audio_codec;
> +    OutputStream stream;
> +    OutputStream audio_stream;
> +    AVFormatContext *oc;
> +
> +    int64_t time;
> +    double delta;
> +
> +    void *soundCapture;
> +};
> +
> +typedef struct {
> +    int bytes;
> +    CaptureVoiceOut *cap;
> +    struct CaptureThreadWorkerData *data;
> +    int bufferPos;
> +} SoundCapture;
> +
> +static int sound_capture_start_capture(struct CaptureThreadWorkerData
> *data);
> +static int ends_with(const char *str, const char *suffix);
> +static struct CaptureThreadWorkerData *capture_get_data(void);
> +static void write_delayed_audio_frames(void);
> +static void write_delayed_video_frames(void);
> +static int capture_stop(void);
> +static double write_audio_frame(AVFormatContext *oc, OutputStream *ost);
> +static void write_empty_sound(void *opaque, struct
> CaptureThreadWorkerData* data);
> +
> +#endif
> --
> 2.7.4
>
>
> --
Marc-André Lureau
Re: [Qemu-devel] [PATCH] Video and sound capture to a videofile through ffmpeg
Posted by Daniel P. Berrange 6 years, 11 months ago
On Thu, May 04, 2017 at 01:41:31PM +0300, Alex K wrote:
> Hello everyone,
> 
> I've made a patch that adds ability to record video of what's going on
> inside qemu. It uses ffmpeg libraries. Basically, the patch adds
> 2 new commands to the console:
> capture_start path framerate
> capture_stop
> 
> path is required
> framerate could be 24, 25, 30 or 60. Default is 60
> video codec is always h264
> 
> The patch uses ffmpeg so you will need to install these packages:
> ffmpeg libavformat-dev libavcodec-dev libavutil-dev libswscale-dev

I wonder if this is not something that is better handled outside of
QEMU. eg there are quite a few programs already that can record
videos from a VNC stream, and there are libraries that can be used
to build custom solutions for either SPICE or VNC too. These would
give much more configurability in terms of encoding options than
this proposal does.

Including h264 support in QEMU also raises some potential legal issues
since organizations claim royalties on anyone using h264 encoders, so
IMHO it is preferrable to avoid this in QEMU entirely.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH] Video and sound capture to a videofile through ffmpeg
Posted by Fam Zheng 6 years, 11 months ago
On Thu, 05/04 13:41, Alex K wrote:
> Hello everyone,

Hi Alex, thanks for posting the patch! I don't know much about display and sound
in QEMU, so just making some superficial points.
> 
> I've made a patch that adds ability to record video of what's going on
> inside qemu. It uses ffmpeg libraries. Basically, the patch adds
> 2 new commands to the console:
> capture_start path framerate
> capture_stop

Sounds like a good idea. In addition, I think it's worth to be added to QMP too.

> 
> path is required
> framerate could be 24, 25, 30 or 60. Default is 60
> video codec is always h264
> 
> The patch uses ffmpeg so you will need to install these packages:
> ffmpeg libavformat-dev libavcodec-dev libavutil-dev libswscale-dev
> 
> This is my first time posting here, so please correct me if I'm doing
> something wrong

This line can be moved after a '---' line following the 'signed-off-by' line,
taht way it doesn't go into the git history when your patch is applied by
maintainers, as it is useless there.

> 
> Signed-off-by: Alex K <vip-ak47@yandex.ru>
> ---
>  configure                          |  20 +
>  default-configs/i386-softmmu.mak   |   1 +
>  default-configs/x86_64-softmmu.mak |   1 +
>  hmp-commands.hx                    |  34 ++
>  hmp.h                              |   2 +
>  hw/display/Makefile.objs           |   2 +
>  hw/display/capture.c               | 761 +++++++++++++++++++++++++++++++++++++
>  hw/display/capture.h               |  78 ++++
>  8 files changed, 899 insertions(+)
>  create mode 100644 hw/display/capture.c
>  create mode 100644 hw/display/capture.h
> 
> diff --git a/configure b/configure
> index 48a9370..a6ddbf0 100755
> --- a/configure
> +++ b/configure
> @@ -281,6 +281,7 @@ opengl=""
>  opengl_dmabuf="no"
>  avx2_opt="no"
>  zlib="yes"
> +libav="yes"
>  lzo=""
>  snappy=""
>  bzip2=""
> @@ -1993,6 +1994,25 @@ if test "$seccomp" != "no" ; then
>          seccomp="no"
>      fi
>  fi
> +#########################################
> +# libav check
> +

Use $pkg_config?

> +if test "$libav" != "no" ; then
> +    cat > $TMPC << EOF
> +#include <libavcodec/avcodec.h>
> +#include <libavformat/avformat.h>
> +
> +int main(void){ av_register_all(); avcodec_register_all(); return 0; }
> +EOF
> +    if compile_prog "" "-lm -lpthread -lavformat -lavcodec -lavutil -lswscale -lswresample" ; then
> +        :
> +    else
> +        error_exit "libav check failed" \
> +            "Make sure to have the libav libs and headers installed."

Please don't make this an error - the dependency should be optional.

> +    fi
> +fi
> +LIBS="$LIBS -lm -lpthread -lavformat -lavcodec -lavutil -lswscale -lswresample"
> +

Please don't extend $LIBS, use something like AV_LIBS and only add it to the
object that uses the library, with per object flags.

Also, add AV_CFLAGS if necessary.

See also how $curl_libs and friends are created and used in configure and
Makefile.


>  ##########################################
>  # xen probe
>  
> diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
> index d2ab2f6..35ce513 100644
> --- a/default-configs/i386-softmmu.mak
> +++ b/default-configs/i386-softmmu.mak
> @@ -59,3 +59,4 @@ CONFIG_SMBIOS=y
>  CONFIG_HYPERV_TESTDEV=$(CONFIG_KVM)
>  CONFIG_PXB=y
>  CONFIG_ACPI_VMGENID=y
> +CONFIG_CAPTURE=y
> diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
> index 9bde2f1..b9a7175 100644
> --- a/default-configs/x86_64-softmmu.mak
> +++ b/default-configs/x86_64-softmmu.mak
> @@ -59,3 +59,4 @@ CONFIG_SMBIOS=y
>  CONFIG_HYPERV_TESTDEV=$(CONFIG_KVM)
>  CONFIG_PXB=y
>  CONFIG_ACPI_VMGENID=y
> +CONFIG_CAPTURE=y

These two hunks are wrong. Probe and generate it in configure, and config.h.

See how CONFIG_CURL is handled in configure and Makefiles.

For more information, see docs/build-system.txt. But I believe following the
libcurl example is enough.

> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 0aca984..9066aac 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -1809,3 +1809,37 @@ ETEXI
>  STEXI
>  @end table
>  ETEXI
> +
> +    {
> +        .name       = "capture_start",
> +        .args_type  = "filename:F,fps:i?",
> +        .params     = "filename [framerate]",
> +        .help       = "Start video capture",
> +        .cmd        = hmp_capture_start,
> +    },
> +
> +STEXI
> +@item capture_start @var{filename} [@var{framerate}]
> +@findex capture_start
> +Start video capture.
> +Capture video into @var{filename} with framerate @var{framerate}.

Is there an fps limit? Is it possible to do 0.5 fps?

> +
> +Defaults:
> +@itemize @minus
> +@item framerate = 60
> +@end itemize
> +ETEXI
> +
> +    {
> +        .name       = "capture_stop",
> +        .args_type  = "",
> +        .params     = "",
> +        .help       = "Stop video capture",
> +        .cmd        = hmp_capture_stop,
> +    },
> +
> +STEXI
> +@item capture_stop
> +@findex capture_stop
> +Stop video capture.
> +ETEXI
> diff --git a/hmp.h b/hmp.h
> index 799fd37..36c7a4d 100644
> --- a/hmp.h
> +++ b/hmp.h
> @@ -138,5 +138,7 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict);
>  void hmp_info_dump(Monitor *mon, const QDict *qdict);
>  void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict);
>  void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict);
> +void hmp_capture_start(Monitor *mon, const QDict *qdict);
> +void hmp_capture_stop(Monitor *mon, const QDict *qdict);
>  
>  #endif
> diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
> index 551c050..a918896 100644
> --- a/hw/display/Makefile.objs
> +++ b/hw/display/Makefile.objs
> @@ -20,6 +20,8 @@ common-obj-$(CONFIG_ZAURUS) += tc6393xb.o
>  
>  common-obj-$(CONFIG_MILKYMIST_TMU2) += milkymist-tmu2.o
>  
> +obj-$(CONFIG_CAPTURE) += capture.o
> +
>  obj-$(CONFIG_OMAP) += omap_dss.o
>  obj-$(CONFIG_OMAP) += omap_lcdc.o
>  obj-$(CONFIG_PXA2XX) += pxa2xx_lcd.o
> diff --git a/hw/display/capture.c b/hw/display/capture.c
> new file mode 100644
> index 0000000..c89aaa0
> --- /dev/null
> +++ b/hw/display/capture.c
> @@ -0,0 +1,761 @@

A copy right header is mandatory for this source file.

Please also include "qemu/osdep.h" before any other headers.

> +#include "capture.h"
> +
> +static void sound_capture_notify(void *opaque, audcnotification_e cmd)
> +{
> +    (void) opaque;
> +    (void) cmd;

These lines are not needed per QEMU's compiler warning level.

> +}
> +
> +static void sound_capture_destroy(void *opaque)
> +{
> +    (void) opaque;

This one too.

> +}
> +
> +static void write_empty_sound(void *opaque, struct CaptureThreadWorkerData *data)
> +{
> +    AVFormatContext *oc = data->oc;
> +    OutputStream *ost = &data->audio_stream;
> +
> +    AVFrame *tmp = ost->tmp_frame;
> +    ost->tmp_frame = ost->empty_frame;
> +    double newlen = write_audio_frame(oc, ost);
> +    ost->tmp_frame = tmp;
> +
> +    if (newlen >= 0.0) {
> +        data->video_len = newlen;
> +    }
> +}
> +
> +static void sound_capture_capture(void *opaque, void *buf, int size)
> +{
> +    int bufsize = size;
> +    SoundCapture *wav = opaque;
> +    AVFrame *frame;
> +    int sampleCount;
> +    double len1, len2, delta;
> +    int8_t *q;
> +    int buffpos;
> +
> +    /*int32_t n = 0;
> +    int i = 0;
> +    for(i=0;i<size;i++) {
> +        int8_t a = ((int8_t*)buf)[i];
> +        n+=a;
> +    }
> +    wav->bytes += size;
> +    if(n==0)
> +        return;
> +    printf("%d\n",n);*/
> +    frame = wav->data->audio_stream.tmp_frame;
> +    sampleCount = frame->nb_samples * 4;
> +
> +    len1 = wav->data->video_len;
> +    len2 = wav->data->video_len2;
> +    delta = len1 - len2;
> +
> +    while (delta < 0.0) {
> +        write_empty_sound(opaque, wav->data);
> +
> +        len1 = wav->data->video_len;
> +        len2 = wav->data->video_len2;
> +        delta = len1 - len2;
> +    }
> +
> +    q = (int8_t *)frame->data[0];
> +
> +    buffpos = 0;
> +    while (bufsize > 0) {
> +        int start = wav->bufferPos;
> +        int freeSpace = sampleCount - start;
> +
> +        int willWrite = freeSpace;
> +        if (willWrite > bufsize) {
> +            willWrite = bufsize;
> +        }
> +
> +        memcpy(q + start, buf + buffpos, willWrite);
> +        bufsize -= willWrite;
> +        buffpos += willWrite;
> +
> +        freeSpace = sampleCount - start - willWrite;
> +
> +        if (freeSpace == 0) {
> +            double newlen = write_audio_frame(wav->data->oc, &wav->data->audio_stream);
> +
> +            if (newlen >= 0.0) {
> +                wav->data->video_len = newlen;
> +            }
> +            wav->bufferPos = 0;
> +        } else {
> +            wav->bufferPos = start + willWrite;
> +        }
> +    }
> +}
> +
> +static void sound_capture_capture_destroy(void *opaque)
> +{
> +    SoundCapture *wav = opaque;
> +
> +    AUD_del_capture (wav->cap, wav);
> +}
> +
> +static int sound_capture_start_capture(struct CaptureThreadWorkerData *data)
> +{
> +    Monitor *mon = cur_mon;
> +    SoundCapture *wav;
> +    struct audsettings as;
> +    struct audio_capture_ops ops;
> +    CaptureVoiceOut *cap;
> +
> +    as.freq = 44100;
> +    as.nchannels = 2;
> +    as.fmt = AUD_FMT_S16;
> +    as.endianness = 0;
> +
> +    ops.notify = sound_capture_notify;
> +    ops.capture = sound_capture_capture;
> +    ops.destroy = sound_capture_destroy;
> +
> +    wav = g_malloc0(sizeof(*wav));
> +
> +
> +    cap = AUD_add_capture(&as, &ops, wav);
> +    if (!cap) {
> +        monitor_printf(mon, "Failed to add audio capture\n");
> +        goto error_free;
> +    }
> +
> +    wav->bufferPos = 0;
> +    wav->data = data;
> +    wav->cap = cap;
> +    data->soundCapture = wav;
> +    return 0;
> +
> +error_free:
> +    g_free(wav);
> +    return -1;
> +}
> +
> +static int write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base,
> +                        AVStream *st, AVPacket *pkt)

Parameter list is off by one column.

> +{
> +    /* rescale output packet timestamp values from codec to stream timebase */
> +    av_packet_rescale_ts(pkt, *time_base, st->time_base);
> +    pkt->stream_index = st->index;
> +    /* Write the compressed frame to the media file. */
> +    return av_interleaved_write_frame(fmt_ctx, pkt);
> +}
> +
> +/* Add an output stream. */
> +static void add_video_stream(OutputStream *ost, AVFormatContext *oc,
> +                       AVCodec **codec,
> +                       enum AVCodecID codec_id,
> +                       int w, int h, int bit_rate, int framerate)

Parameter list indentation is off.
> +{
> +    AVCodecContext *c;
> +    /* find the encoder */
> +    *codec = avcodec_find_encoder(codec_id);
> +    if (!(*codec)) {
> +        fprintf(stderr, "Could not find encoder for '%s'\n",
> +                avcodec_get_name(codec_id));
> +        exit(1);

Can this be handled more gracefully instead of exit? (The same question to all
other 'exits' in this patch).

> +    }
> +    ost->st = avformat_new_stream(oc, *codec);
> +    if (!ost->st) {
> +        fprintf(stderr, "Could not allocate stream\n");
> +        exit(1);
> +    }
> +    ost->st->id = oc->nb_streams - 1;
> +    c = ost->st->codec;
> +    if ((*codec)->type == AVMEDIA_TYPE_VIDEO) {
> +        c->codec_id = codec_id;
> +        c->bit_rate = bit_rate;
> +        /* Resolution must be a multiple of two. */
> +        c->width    = w;
> +        c->height   = h;
> +        /* timebase: This is the fundamental unit of time (in seconds) in terms
> +         * of which frame timestamps are represented. For fixed-fps content,
> +         * timebase should be 1/framerate and timestamp increments should be
> +         * identical to 1. */
> +        ost->st->time_base = (AVRational){ 1, framerate };
> +        c->time_base = ost->st->time_base;
> +        c->gop_size  = 12; /* emit one intra frame every 12 frames at most */
> +        c->pix_fmt   = AV_PIX_FMT_YUV420P;
> +        if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
> +            /* just for testing, we also add B frames */
> +            c->max_b_frames = 2;
> +        }
> +        if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
> +            /* Needed to avoid using macroblocks in which some coeffs overflow.
> +             * This does not happen with normal video, it just happens here as
> +             * the motion of the chroma plane does not match the luma plane. */
> +            c->mb_decision = 2;
> +        }
> +    } else {
> +        fprintf(stderr, "Wrong stream type\n");
> +        exit(1);
> +    }
> +    /* Some formats want stream headers to be separate. */
> +    if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
> +        c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
> +    }
> +}
> +
> +static void add_audio_stream(OutputStream *ost, AVFormatContext *oc,
> +                             AVCodec **codec,
> +                             enum AVCodecID codec_id)
> +{
> +    AVCodecContext *c;
> +    int i;
> +    /* find the encoder */
> +    *codec = avcodec_find_encoder(codec_id);
> +    if (!(*codec)) {
> +        fprintf(stderr, "Could not find encoder for '%s'\n",
> +                avcodec_get_name(codec_id));
> +        exit(1);
> +    }
> +    ost->st = avformat_new_stream(oc, *codec);
> +    if (!ost->st) {
> +        fprintf(stderr, "Could not allocate stream\n");
> +        exit(1);
> +    }
> +    ost->st->id = oc->nb_streams - 1;
> +    c = ost->st->codec;
> +    if ((*codec)->type == AVMEDIA_TYPE_AUDIO) {
> +        c->sample_fmt = AV_SAMPLE_FMT_FLTP;
> +        c->bit_rate    = 128000;
> +        c->sample_rate = 44100;
> +        c->channels    = av_get_channel_layout_nb_channels(c->channel_layout);
> +        c->channel_layout = AV_CH_LAYOUT_STEREO;
> +        if ((*codec)->channel_layouts) {
> +            c->channel_layout = (*codec)->channel_layouts[0];
> +            for (i = 0; (*codec)->channel_layouts[i]; i++) {
> +                if ((*codec)->channel_layouts[i] == AV_CH_LAYOUT_STEREO) {
> +                    c->channel_layout = AV_CH_LAYOUT_STEREO;
> +                }
> +            }
> +        }
> +        c->channels   = av_get_channel_layout_nb_channels(c->channel_layout);
> +        ost->st->time_base = (AVRational){ 1, c->sample_rate };
> +    } else {
> +        fprintf(stderr, "Wrong stream type\n");
> +        exit(1);
> +    }
> +    /* Some formats want stream headers to be separate. */
> +    if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
> +        c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
> +    }
> +}
> +/**************************************************************/
> +/* audio output */
> +static AVFrame *alloc_audio_frame(enum AVSampleFormat sample_fmt,
> +                                  uint64_t channel_layout,
> +                                  int sample_rate, int nb_samples)
> +{
> +    AVFrame *frame = av_frame_alloc();
> +    int ret;
> +    if (!frame) {
> +        fprintf(stderr, "Error allocating an audio frame\n");
> +        exit(1);
> +    }
> +    frame->format = sample_fmt;
> +    frame->channel_layout = channel_layout;
> +    frame->sample_rate = sample_rate;
> +    frame->nb_samples = nb_samples;
> +    if (nb_samples) {
> +        ret = av_frame_get_buffer(frame, 0);
> +        if (ret < 0) {
> +            fprintf(stderr, "Error allocating an audio buffer\n");
> +            exit(1);
> +        }
> +    }
> +    return frame;
> +}
> +
> +static void open_audio(AVFormatContext *oc, AVCodec *codec,
> +                       OutputStream *ost, AVDictionary *opt_arg)
> +{
> +    AVCodecContext *c;
> +    int nb_samples;
> +    int ret;
> +    AVDictionary *opt = NULL;
> +    c = ost->st->codec;
> +    /* open it */
> +    av_dict_copy(&opt, opt_arg, 0);
> +    ret = avcodec_open2(c, codec, &opt);
> +    av_dict_free(&opt);
> +    if (ret < 0) {
> +        fprintf(stderr, "Could not open audio codec: %s\n", av_err2str(ret));
> +        exit(1);
> +    }
> +    nb_samples = c->frame_size;
> +    ost->frame     = alloc_audio_frame(c->sample_fmt, c->channel_layout,
> +                                       c->sample_rate, nb_samples);
> +
> +    ost->tmp_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, c->channel_layout,
> +                                       c->sample_rate, nb_samples);
> +    ost->tmp_frame->pts = 0;
> +
> +    ost->empty_frame = alloc_audio_frame(AV_SAMPLE_FMT_S16, c->channel_layout,
> +                                       c->sample_rate, nb_samples);
> +    int sampleCount = nb_samples * 4;
> +    int8_t *q = (int8_t *)ost->empty_frame->data[0];
> +    memset(q, 0, sampleCount);
> +
> +    /* create resampler context */
> +    ost->swr_ctx = swr_alloc();
> +    if (!ost->swr_ctx) {
> +        fprintf(stderr, "Could not allocate resampler context\n");
> +        exit(1);
> +    }
> +    /* set options */
> +    av_opt_set_int       (ost->swr_ctx, "in_channel_count",  c->channels,       0);
> +    av_opt_set_int       (ost->swr_ctx, "in_sample_rate",    c->sample_rate,    0);
> +    av_opt_set_sample_fmt(ost->swr_ctx, "in_sample_fmt",     AV_SAMPLE_FMT_S16, 0);
> +    av_opt_set_int       (ost->swr_ctx, "out_channel_count", c->channels,       0);
> +    av_opt_set_int       (ost->swr_ctx, "out_sample_rate",   c->sample_rate,    0);
> +    av_opt_set_sample_fmt(ost->swr_ctx, "out_sample_fmt",    c->sample_fmt,     0);
> +    /* initialize the resampling context */
> +    if (swr_init(ost->swr_ctx) < 0) {
> +        fprintf(stderr, "Failed to initialize the resampling context\n");
> +        exit(1);
> +    }
> +}
> +
> +/*
> + * encode one audio frame and send it to the muxer
> + */
> +static double write_audio_frame(AVFormatContext *oc, OutputStream *ost)
> +{
> +    AVCodecContext *c;
> +    AVPacket pkt = { 0 };
> +    AVFrame *frame;
> +    int ret;
> +    int got_packet;
> +    int dst_nb_samples;
> +    av_init_packet(&pkt);
> +    c = ost->st->codec;
> +    frame = ost->tmp_frame;
> +    frame->pts = frame->pts + 1;
> +    double videolen = -1.0;
> +    if (frame) {
> +        /* convert samples from native format to destination codec format,
> +         * using the resampler */
> +        /* compute destination number of samples */
> +        dst_nb_samples = av_rescale_rnd(
> +            swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples,
> +            c->sample_rate, c->sample_rate, AV_ROUND_UP);
> +        av_assert0(dst_nb_samples == frame->nb_samples);
> +        /* when we pass a frame to the encoder, it may keep a reference to it
> +         * internally;
> +         * make sure we do not overwrite it here
> +         */
> +        ret = av_frame_make_writable(ost->frame);
> +        if (ret < 0) {
> +            exit(1);
> +        }
> +        /* convert to destination format */
> +        ret = swr_convert(ost->swr_ctx,
> +                          ost->frame->data, dst_nb_samples,
> +                          (const uint8_t **)frame->data, frame->nb_samples);
> +        if (ret < 0) {
> +            fprintf(stderr, "Error while converting\n");
> +            exit(1);
> +        }
> +        frame = ost->frame;
> +        frame->pts = av_rescale_q(ost->samples_count,
> +                                  (AVRational){1, c->sample_rate},
> +                                  c->time_base);
> +
> +        videolen = (double)frame->pts / c->sample_rate;
> +        ost->samples_count += dst_nb_samples;
> +    }
> +    ret = avcodec_encode_audio2(c, &pkt, frame, &got_packet);
> +    if (ret < 0) {
> +        fprintf(stderr, "Error encoding audio frame: %s\n", av_err2str(ret));
> +        exit(1);
> +    }
> +    if (got_packet) {
> +        ret = write_frame(oc, &c->time_base, ost->st, &pkt);
> +        if (ret < 0) {
> +            fprintf(stderr, "Error while writing audio frame: %s\n",
> +                    av_err2str(ret));
> +            exit(1);
> +        }
> +    }
> +    return videolen;
> +}

Add a blank line?

> +static void write_delayed_audio_frames(void)
> +{
> +    struct CaptureThreadWorkerData *data = capture_get_data();
> +    AVFormatContext *oc = data->oc;
> +    OutputStream *ost = &data->audio_stream;
> +    AVCodecContext *c = ost->st->codec;
> +
> +    AVPacket pkt = { 0 };
> +    pkt.data = NULL;
> +    pkt.size = 0;
> +    av_init_packet(&pkt);
> +    int got_output = 1;
> +    int ret;
> +    while (got_output) {
> +
> +        ret = avcodec_encode_audio2(c, &pkt, NULL, &got_output);
> +        if (ret < 0) {
> +            fprintf(stderr, "Error encoding frame\n");
> +            exit(1);
> +        }
> +
> +        if (got_output) {
> +            ret = write_frame(oc, &c->time_base, ost->st, &pkt);
> +            av_free_packet(&pkt);
> +        }
> +    }
> +}

Blank line.

> +/**************************************************************/
> +/* video output */
> +static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height)
> +{
> +    AVFrame *picture;
> +    int ret;
> +    picture = av_frame_alloc();
> +    if (!picture) {
> +        return NULL;
> +    }
> +    picture->format = pix_fmt;
> +    picture->width  = width;
> +    picture->height = height;
> +    /* allocate the buffers for the frame data */
> +    ret = av_frame_get_buffer(picture, 32);
> +    if (ret < 0) {
> +        fprintf(stderr, "Could not allocate frame data.\n");
> +        exit(1);
> +    }
> +    return picture;
> +}
> +
> +static void open_video(AVFormatContext *oc, AVCodec *codec,
> +                       OutputStream *ost, AVDictionary *opt_arg)
> +{
> +    int ret;
> +    AVCodecContext *c = ost->st->codec;
> +    AVDictionary *opt = NULL;
> +    av_dict_copy(&opt, opt_arg, 0);
> +    /* open the codec */
> +    ret = avcodec_open2(c, codec, &opt);
> +    av_dict_free(&opt);
> +    if (ret < 0) {
> +        fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));
> +        exit(1);
> +    }
> +    /* allocate and init a re-usable frame */
> +    ost->frame = alloc_picture(c->pix_fmt, c->width, c->height);
> +    if (!ost->frame) {
> +        fprintf(stderr, "Could not allocate video frame\n");
> +        exit(1);
> +    }
> +}
> +
> +static AVFrame *get_filled_image(void)
> +{
> +    QemuConsole *con = qemu_console_lookup_by_index(0);
> +    DisplaySurface *surface;
> +    surface = qemu_console_surface(con);
> +
> +    if (con == NULL) {
> +        fprintf(stderr, "There is no QemuConsole I can screendump from.\n");
> +        return NULL;
> +    }
> +
> +    int ourW = pixman_image_get_width(surface->image);
> +    int ourH = pixman_image_get_height(surface->image);
> +
> +    AVFrame *pict = alloc_picture(AV_PIX_FMT_RGB32, ourW, ourH);
> +    av_frame_make_writable(pict);
> +
> +    uint8_t* picdata = (uint8_t *)pixman_image_get_data(surface->image);
> +
> +    memcpy(pict->data[0], picdata, ourW * ourH * 4);
> +    return pict;
> +}
> +
> +static AVFrame *get_video_frame(OutputStream *ost, int64_t frame)
> +{
> +    AVCodecContext *c = ost->st->codec;
> +
> +    AVFrame *pict = get_filled_image();
> +    if (pict == NULL) {
> +        return NULL;
> +    }
> +
> +    struct SwsContext *swsContext = sws_getContext(
> +        pict->width, pict->height, pict->format,
> +        ost->frame->width, ost->frame->height,
> +        ost->frame->format, SWS_BICUBIC, NULL, NULL, NULL);
> +    sws_scale(swsContext, (const uint8_t * const *)pict->data,
> +              pict->linesize , 0, c->height, ost->frame->data,
> +              ost->frame->linesize);
> +
> +    av_frame_free(&pict);
> +    sws_freeContext(swsContext);
> +
> +    if (frame <= ost->frame->pts) {
> +        ost->frame->pts = ost->frame->pts + 1;
> +    } else {
> +        ost->frame->pts = frame;
> +    }
> +
> +    return ost->frame;
> +}

Blank line.

> +/*
> + * encode one video frame and send it to the muxer
> + */
> +static void write_video_frame(AVFormatContext *oc,
> +                              OutputStream *ost, int frameNumber)
> +{
> +    int ret;
> +    AVCodecContext *c;
> +    AVFrame *frame;
> +    int got_packet = 0;
> +    AVPacket pkt = { 0 };
> +
> +    frame = get_video_frame(ost, frameNumber);
> +    if (frame == NULL) {
> +        return;
> +    }
> +
> +    c = ost->st->codec;
> +    av_init_packet(&pkt);
> +    /* encode the image */
> +    ret = avcodec_encode_video2(c, &pkt, frame, &got_packet);
> +    if (ret < 0) {
> +        fprintf(stderr, "Error encoding video frame: %s\n", av_err2str(ret));
> +        exit(1);
> +    }
> +    if (got_packet) {
> +        ret = write_frame(oc, &c->time_base, ost->st, &pkt);
> +    } else {
> +        ret = 0;
> +    }
> +    if (ret < 0) {
> +        fprintf(stderr, "Error while writing video frame: %s\n", av_err2str(ret));
> +        return;
> +    }
> +}
> +
> +static void write_delayed_video_frames(void)
> +{
> +    struct CaptureThreadWorkerData *data = capture_get_data();
> +    AVFormatContext *oc = data->oc;
> +    OutputStream *ost = &data->stream;
> +    AVCodecContext *c = ost->st->codec;
> +
> +    AVPacket pkt = { 0 };
> +    pkt.data = NULL;
> +    pkt.size = 0;
> +    av_init_packet(&pkt);
> +    int got_output = 1;
> +    int ret;
> +    while (got_output) {
> +        ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
> +        if (ret < 0) {
> +            fprintf(stderr, "Error encoding frame\n");
> +            exit(1);
> +        }
> +
> +        if (got_output) {
> +            ret = write_frame(oc, &c->time_base, ost->st, &pkt);
> +            av_free_packet(&pkt);
> +        }
> +    }
> +}
> +
> +static void close_stream(AVFormatContext *oc, OutputStream *ost)
> +{
> +    avcodec_close(ost->st->codec);
> +    av_frame_free(&ost->frame);
> +    av_frame_free(&ost->tmp_frame);
> +    sws_freeContext(ost->sws_ctx);
> +    swr_free(&ost->swr_ctx);
> +}
> +
> +static int ends_with(const char *str, const char *suffix)
> +{
> +    if (!str || !suffix) {
> +        return 0;
> +    }
> +    size_t lenstr = strlen(str);
> +    size_t lensuffix = strlen(suffix);
> +    if (lensuffix >  lenstr) {
> +        return 0;
> +    }
> +    return strncmp(str + lenstr - lensuffix, suffix, lensuffix) == 0;
> +}
> +
> +static struct CaptureThreadWorkerData *capture_get_data(void)
> +{
> +    static struct CaptureThreadWorkerData data = {0};
> +    return &data;
> +}
> +
> +static void capture_timer(void *p)
> +{
> +    struct CaptureThreadWorkerData *data = (struct CaptureThreadWorkerData *)p;
> +    if (!data->is_capturing) {
> +        return;
> +    }
> +
> +    int64_t n = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> +    int64_t intdelta = (n - data->time) / 100000;
> +    double delta = (double)intdelta / 10000;
> +    data->delta += delta;
> +    data->time   = n;
> +
> +    while (data->delta > (1.0 / data->framerate)) {
> +        data->delta -= 1.0 / data->framerate;
> +
> +        av_frame_make_writable(data->stream.frame);
> +        write_video_frame(data->oc, &data->stream,
> +            (int)(floor(data->video_len * (double)data->framerate + 0.5)));
> +    }
> +    data->video_len2 = data->video_len2 + delta;
> +
> +    int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> +    if (data->is_capturing) {
> +        timer_mod_ns(data->timer, now + 10000000);
> +    }
> +}
> +
> +static void capture_powerdown_req(void)
> +{
> +    if (capture_stop()) {
> +        printf("Capture stoped\n");
> +    }
> +}
> +
> +void hmp_capture_start(Monitor *mon, const QDict *qdict)
> +{
> +    const char *filename = qdict_get_str(qdict, "filename");
> +    int framerate = qdict_get_try_int(qdict, "fps", 60);
> +
> +    struct CaptureThreadWorkerData *data = capture_get_data();
> +    if (!data->is_loaded) {
> +        av_register_all();
> +        avcodec_register_all();
> +        data->codec = avcodec_find_encoder(AV_CODEC_ID_H264);
> +        if (!data->codec) {
> +            fprintf(stderr, "codec not found\n");
> +            return;
> +        }
> +        data->c = NULL;
> +        data->is_loaded = 1;
> +        atexit(capture_powerdown_req);
> +    }
> +
> +    if (data->is_capturing == 0) {
> +        if (!ends_with(filename, ".mp4")
> +         && !ends_with(filename, ".mpg")
> +         && !ends_with(filename, ".avi")) {
> +            monitor_printf(mon, "Invalid file format, use .mp4 or .mpg\n");
> +            return;
> +        }
> +        if (framerate != 60 && framerate != 30
> +         && framerate != 24 && framerate != 25) {
> +            monitor_printf(mon, "Invalid framerate, valid values are: 24, 25, 30, 60\n");
> +            return;
> +        }
> +        monitor_printf(mon, "Capture started to file: %s\n", filename);
> +
> +        data->framerate = framerate;
> +        data->frame = 0;
> +
> +        data->delta = 0.0;
> +        data->time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> +
> +        data->video_len = 0.0;
> +        data->video_len2 = 0.0;
> +
> +        QemuConsole *con = qemu_console_lookup_by_index(0);
> +        DisplaySurface *surface;
> +        surface = qemu_console_surface(con);
> +        int resW = pixman_image_get_width(surface->image);
> +        int resH = pixman_image_get_height(surface->image);
> +
> +        OutputStream video_st = { 0 };
> +        data->stream = video_st;
> +        OutputStream audio_st = { 0 };
> +        data->audio_stream = audio_st;
> +
> +        avformat_alloc_output_context2(&data->oc, NULL, "avi", filename);
> +        AVOutputFormat *fmt;
> +        fmt = data->oc->oformat;
> +
> +        add_video_stream(&data->stream, data->oc, &data->codec,
> +                         fmt->video_codec, resW, resH, 4000000, framerate);
> +        add_audio_stream(&data->audio_stream, data->oc, &data->audio_codec,
> +                         fmt->audio_codec);
> +
> +        open_video(data->oc, data->codec, &data->stream, NULL);
> +        open_audio(data->oc, data->audio_codec, &data->audio_stream, NULL);
> +
> +        int ret = avio_open(&data->oc->pb, filename, AVIO_FLAG_WRITE);
> +        if (ret < 0) {
> +            fprintf(stderr, "Could not open '%s': %s\n", filename,
> +                    av_err2str(ret));
> +            return;
> +        }
> +        ret = avformat_write_header(data->oc, NULL);
> +        if (ret < 0) {
> +            fprintf(stderr, "Error occurred when opening output file: %s\n",
> +                    av_err2str(ret));
> +            return;
> +        }
> +
> +        data->is_capturing = 1;
> +
> +        if (data->timer) {
> +            timer_free(data->timer);
> +        }
> +        data->timer = timer_new_ns(QEMU_CLOCK_REALTIME, capture_timer, data);
> +        int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> +        timer_mod_ns(data->timer, now + 1000000000 / data->framerate);
> +
> +        sound_capture_start_capture(data);
> +    } else {
> +        monitor_printf(mon, "Already capturing\n");
> +    }
> +}
> +
> +static int capture_stop(void)
> +{
> +    struct CaptureThreadWorkerData *data = capture_get_data();
> +    if (!data->is_loaded) {
> +        return 0;
> +    }
> +
> +    if (data->is_capturing) {
> +        data->is_capturing = 0;
> +
> +        write_delayed_video_frames();
> +        write_delayed_audio_frames();
> +
> +        av_write_trailer(data->oc);
> +        close_stream(data->oc, &data->stream);
> +        close_stream(data->oc, &data->audio_stream);
> +        avio_closep(&data->oc->pb);
> +        avformat_free_context(data->oc);
> +
> +        sound_capture_capture_destroy(data->soundCapture);
> +        return 1;
> +    }
> +    return 0;
> +}
> +
> +void hmp_capture_stop(Monitor *mon, const QDict *qdict)
> +{
> +    if (capture_stop()) {
> +        monitor_printf(mon, "Capture stopped\n");
> +    } else {
> +        monitor_printf(mon, "Not capturing\n");
> +    }
> +}
> diff --git a/hw/display/capture.h b/hw/display/capture.h
> new file mode 100644
> index 0000000..73c79f1
> --- /dev/null
> +++ b/hw/display/capture.h
> @@ -0,0 +1,78 @@
> +#ifndef CAPTURE_H
> +#define CAPTURE_H
> +
> +#include "qemu/osdep.h"
> +#include "monitor/monitor.h"
> +#include "ui/console.h"
> +#include "qemu/timer.h"
> +#include "audio/audio.h"
> +
> +#include <libavcodec/avcodec.h>
> +#include <libavformat/avformat.h>
> +#include "libavutil/frame.h"
> +#include "libavutil/imgutils.h"
> +#include <libswscale/swscale.h>
> +#include <libavutil/avassert.h>
> +#include <libavutil/channel_layout.h>
> +#include <libavutil/opt.h>
> +#include <libavutil/mathematics.h>
> +#include <libavutil/timestamp.h>
> +#include <libswresample/swresample.h>
> +
> +void hmp_capture_start(Monitor *mon, const QDict *qdict);
> +void hmp_capture_stop(Monitor *mon, const QDict *qdict);
> +
> +typedef struct OutputStream {
> +    AVStream *st;
> +    int samples_count;
> +    AVFrame *frame;
> +    AVFrame *tmp_frame;
> +    AVFrame *empty_frame;
> +    struct SwsContext *sws_ctx;
> +    struct SwrContext *swr_ctx;
> +} OutputStream;
> +
> +struct CaptureThreadWorkerData {
> +    QEMUTimer *timer;
> +    int frame;
> +    int is_loaded;
> +    int is_capturing;
> +    int framerate;
> +    double video_len;
> +    double video_len2;
> +    CaptureState *wavCapture;
> +
> +    AVCodec *codec;
> +    AVCodecContext *c;
> +
> +    AVFrame *picture;
> +    AVPacket pkt;
> +
> +    AVCodec *audio_codec;
> +    OutputStream stream;
> +    OutputStream audio_stream;
> +    AVFormatContext *oc;
> +
> +    int64_t time;
> +    double delta;
> +
> +    void *soundCapture;
> +};
> +
> +typedef struct {
> +    int bytes;
> +    CaptureVoiceOut *cap;
> +    struct CaptureThreadWorkerData *data;
> +    int bufferPos;
> +} SoundCapture;
> +
> +static int sound_capture_start_capture(struct CaptureThreadWorkerData *data);
> +static int ends_with(const char *str, const char *suffix);
> +static struct CaptureThreadWorkerData *capture_get_data(void);
> +static void write_delayed_audio_frames(void);
> +static void write_delayed_video_frames(void);
> +static int capture_stop(void);
> +static double write_audio_frame(AVFormatContext *oc, OutputStream *ost);
> +static void write_empty_sound(void *opaque, struct CaptureThreadWorkerData* data);

What's the point of these prototypes? 'static' means they are private functions
so they needn't be listed in the header.

> +
> +#endif
> -- 
> 2.7.4
> 
> 

Fam

Re: [Qemu-devel] [PATCH] Video and sound capture to a videofile through ffmpeg
Posted by Gerd Hoffmann 6 years, 11 months ago
On Do, 2017-05-04 at 13:41 +0300, Alex K wrote:
> Hello everyone,
> 
> I've made a patch that adds ability to record video of what's going on
> inside qemu. It uses ffmpeg libraries. Basically, the patch adds
> 2 new commands to the console:
> capture_start path framerate
> capture_stop
> 
> path is required
> framerate could be 24, 25, 30 or 60. Default is 60
> video codec is always h264
> 
> The patch uses ffmpeg so you will need to install these packages:
> ffmpeg libavformat-dev libavcodec-dev libavutil-dev libswscale-dev
> 
> This is my first time posting here, so please correct me if I'm doing
> something wrong

First, as others already mentioned, it would be better to do this
outside qemu, as vnc or spice client.  spice is probably the better
choice as spice supports passing the guest display as dma-buf, which
saves the encode-as-spice and decode-spice steps.  And the dma-bufs can
be passed to a hardware encoder.

Second, this must be a compile time option.  Breaking the build in case
ffmpeg is not installed isn't an option.

Third, supporting H.264 only is a non-starter too.  Due to the patent
situation you can't expect distros shipping ffmpeg with H.264 support
enabled.

cheers,
  Gerd