diff -Nru yorick-av-0.0.4/debian/changelog yorick-av-0.0.5/debian/changelog --- yorick-av-0.0.4/debian/changelog 2018-03-06 13:01:45.000000000 +0000 +++ yorick-av-0.0.5/debian/changelog 2018-05-30 01:11:11.000000000 +0000 @@ -1,3 +1,14 @@ +yorick-av (0.0.5-1) unstable; urgency=low + + * New upstream release. + * Bug fix: "FTBFS with FFmpeg 4.0", thanks to jcowgill@debian.org; + (Closes: #888359). + * Check against Policy 4.1.4 (priority optional, https in copyright + format). + * Add autopkgtest suite. + + -- Thibaut Paumard Wed, 30 May 2018 03:11:11 +0200 + yorick-av (0.0.4-2) unstable; urgency=low * Bug fix: "AVPacket timestamps need to be rescaled for most codecs" diff -Nru yorick-av-0.0.4/debian/control yorick-av-0.0.5/debian/control --- yorick-av-0.0.4/debian/control 2018-02-16 15:19:02.000000000 +0000 +++ yorick-av-0.0.5/debian/control 2018-05-30 01:10:11.000000000 +0000 @@ -1,15 +1,15 @@ Source: yorick-av Section: science -Priority: extra +Priority: optional Maintainer: Debian Science Maintainers Uploaders: Thibaut Paumard Build-Depends: debhelper (>= 9), yorick-dev (>= 2), libavformat-dev (>=6:9), libavutil-dev (>=6:9), libavcodec-dev (>=6:9), libswscale-dev (>=6:9) -Standards-Version: 3.9.8 -Vcs-Git: https://anonscm.debian.org/git/debian-science/packages/yorick-av.git -Vcs-Browser: https://anonscm.debian.org/gitweb/?p=debian-science/packages/yorick-av.git -Homepage: https://github.com/paumard/yorick-av +Standards-Version: 4.1.4 +Vcs-Git: https://salsa.debian.org/science-team/yorick-av.git +Vcs-Browser: https://salsa.debian.org/science-team/yorick-av +Homepage: https://github.com/paumard/yorick-av Package: yorick-av Architecture: any diff -Nru yorick-av-0.0.4/debian/copyright yorick-av-0.0.5/debian/copyright --- yorick-av-0.0.4/debian/copyright 2018-02-16 15:19:02.000000000 +0000 +++ yorick-av-0.0.5/debian/copyright 2018-05-29 22:33:01.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Contact: Thibaut Paumard Source: https://github.com/paumard/yorick-av diff -Nru yorick-av-0.0.4/debian/patches/ffmpeg_2.9.patch yorick-av-0.0.5/debian/patches/ffmpeg_2.9.patch --- yorick-av-0.0.4/debian/patches/ffmpeg_2.9.patch 2018-02-16 15:19:02.000000000 +0000 +++ yorick-av-0.0.5/debian/patches/ffmpeg_2.9.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -Description: Replace deprecated FFmpeg API -Author: Andreas Cadhalpun -Last-Update: <2015-11-02> - ---- yorick-av-0.0.3.orig/yav.c -+++ yorick-av-0.0.3/yav.c -@@ -30,6 +30,8 @@ - #include - #include - #include -+#include -+#include - #include - - #ifndef AVIO_FLAG_WRITE -@@ -53,7 +55,7 @@ - #define YAV_FRAME_RATE 24 - #define YAV_GOP_SIZE 25 - #define YAV_MAX_B_FRAMES 16 --#define YAV_PIX_FMT PIX_FMT_YUV420P /* default pix_fmt */ -+#define YAV_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */ - - inline int yav_arg_set(iarg) { return (iarg >= 0) && !yarg_nil(iarg); } - -@@ -231,7 +233,7 @@ Y_av_create(int argc) - switch (c->codec_id) { - case AV_CODEC_ID_RAWVIDEO: - case AV_CODEC_ID_GIF: -- if (!pix_fmt) c->pix_fmt = PIX_FMT_RGB24; -+ if (!pix_fmt) c->pix_fmt = AV_PIX_FMT_RGB24; - break; - case AV_CODEC_ID_MSMPEG4V3: - case AV_CODEC_ID_H263: -@@ -266,14 +268,14 @@ void yav_opencodec(yav_ctxt *obj, unsign - if (avcodec_open2(c, obj->codec, NULL) < 0) - y_error("could not open codec\n"); - -- obj->picture = avcodec_alloc_frame(); -+ obj->picture = av_frame_alloc(); - if (!obj->picture) - y_error("Could not allocate picture"); - - int size = avpicture_get_size(c->pix_fmt, c->width, c->height); - uint8_t *picture_buf = av_malloc(size); - if (!picture_buf) { -- av_freep(obj->picture); -+ av_frame_free(&obj->picture); - y_error("unable to allocate memory"); - } - avpicture_fill((AVPicture *)obj->picture, picture_buf, -@@ -285,20 +287,20 @@ void yav_opencodec(yav_ctxt *obj, unsign - /* if the output format is not RGB24, then a temporary RGB24 - picture is needed too. It is then converted to the required - output format */ -- if (c->pix_fmt != PIX_FMT_RGB24) { -- obj->tmp_picture = avcodec_alloc_frame(); -+ if (c->pix_fmt != AV_PIX_FMT_RGB24) { -+ obj->tmp_picture = av_frame_alloc(); - if (!obj->tmp_picture) { - y_error("Could not allocate picture"); - } -- size = avpicture_get_size(PIX_FMT_RGB24, c->width, c->height); -+ size = avpicture_get_size(AV_PIX_FMT_RGB24, c->width, c->height); - uint8_t *tmp_picture_buf = av_malloc(size); - if (!tmp_picture_buf) { -- av_freep(obj->tmp_picture); -- av_freep(obj->picture); -+ av_frame_free(&obj->tmp_picture); -+ av_frame_free(&obj->picture); - y_error("unable to allocate memory"); - } - avpicture_fill((AVPicture *)obj->tmp_picture, tmp_picture_buf, -- PIX_FMT_RGB24, c->width, c->height); -+ AV_PIX_FMT_RGB24, c->width, c->height); - } - } - -@@ -351,12 +353,12 @@ Y_av_write(int argc) - uint8_t *src[4] = {data, 0, 0, 0}; - int src_linesizes[4] = {3*c->width,0,0,0}; - -- if (c->pix_fmt != PIX_FMT_RGB24) { -+ if (c->pix_fmt != AV_PIX_FMT_RGB24) { - /* as we only generate a RGB24 picture, we must convert it - to the codec pixel format if needed */ - obj->img_convert_ctx = sws_getCachedContext(obj->img_convert_ctx, - c->width, c->height, -- PIX_FMT_RGB24, -+ AV_PIX_FMT_RGB24, - c->width, c->height, - c->pix_fmt, - SWS_BICUBIC, NULL, NULL, NULL); -@@ -364,14 +366,14 @@ Y_av_write(int argc) - y_error("Cannot initialize the conversion context"); - - av_image_copy(obj->tmp_picture->data, obj->tmp_picture->linesize, -- src, src_linesizes, PIX_FMT_RGB24, c->width, c->height); -+ src, src_linesizes, AV_PIX_FMT_RGB24, c->width, c->height); - sws_scale(obj->img_convert_ctx, - (const uint8_t * const*)obj->tmp_picture->data, - obj->tmp_picture->linesize, - 0, c->height, obj->picture->data, obj->picture->linesize); - } else { - av_image_copy(obj->picture->data, obj->picture->linesize, -- src, src_linesizes, PIX_FMT_RGB24, c->width, c->height); -+ src, src_linesizes, AV_PIX_FMT_RGB24, c->width, c->height); - } - - /* encode the image */ diff -Nru yorick-av-0.0.4/debian/patches/rescale-ts yorick-av-0.0.5/debian/patches/rescale-ts --- yorick-av-0.0.4/debian/patches/rescale-ts 2018-02-20 10:35:07.000000000 +0000 +++ yorick-av-0.0.5/debian/patches/rescale-ts 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -Description: Rescale frame timestamps - Without this, the timestamps are wrong with most codecs, making the - output garbage. -Author: Thibaut Paumard -Origin: vendor -Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=890880 -Forwarded: not-needed -Applied-Upstream: ed6b754e03f280708991f579db42dca136431c35 -Last-Update: 2018-02-20 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/yav.c -+++ b/yav.c -@@ -391,6 +391,7 @@ - AVPacket pkt; - av_init_packet(&pkt); - pkt.flags |= AV_PKT_FLAG_KEY; -+ av_packet_rescale_ts(&pkt, c->time_base, obj->video_st->time_base); - pkt.stream_index = obj->video_st->index; - pkt.data= obj->video_outbuf; - // pkt.size= out_size; -@@ -408,6 +409,7 @@ - } - /* If size is zero, it means the image was buffered. */ - if (!ret && got_packet && pkt.size) { -+ av_packet_rescale_ts(&pkt, c->time_base, obj->video_st->time_base); - pkt.stream_index = obj->video_st->index; - /* Write the compressed frame to the media file. */ - ret = av_interleaved_write_frame(obj->oc, &pkt); diff -Nru yorick-av-0.0.4/debian/patches/series yorick-av-0.0.5/debian/patches/series --- yorick-av-0.0.4/debian/patches/series 2018-03-06 12:05:17.000000000 +0000 +++ yorick-av-0.0.5/debian/patches/series 2018-05-29 19:54:39.000000000 +0000 @@ -1,2 +0,0 @@ -rescale-ts -vbv_buffer diff -Nru yorick-av-0.0.4/debian/patches/vbv_buffer yorick-av-0.0.5/debian/patches/vbv_buffer --- yorick-av-0.0.4/debian/patches/vbv_buffer 2018-03-06 12:56:28.000000000 +0000 +++ yorick-av-0.0.5/debian/patches/vbv_buffer 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -Description: Set VBV buffer size for MPEG1/2 files - FFmpeg emits warnings when producing MPEG1/2 files and the VBV buffer - size has not been set. The output files may then play sluggishly in - VLC. This backported patch sets a VBV buffer size sufficient to hold - one frame. -Author: Thibaut Paumard -Origin: backport -Bug-Debian: http://bugs.debian.org/892176 -Forwarded: not-needed -Applied-Upstream: 0.0.5 -Last-Update: 2018-03-06 ---- -This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ---- a/yav.c -+++ b/yav.c -@@ -259,6 +259,17 @@ - void yav_opencodec(yav_ctxt *obj, unsigned int width, unsigned int height) { - obj->video_st->codec->width=width; - obj->video_st->codec->height=height; -+ if (obj->video_st->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO || -+ obj->video_st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) { -+ AVCPBProperties *props; -+ props = (AVCPBProperties*) av_stream_new_side_data -+ (obj->video_st, AV_PKT_DATA_CPB_PROPERTIES, sizeof(*props)); -+ props->buffer_size = width*height*4; -+ props->max_bitrate = 0; -+ props->min_bitrate = 0; -+ props->avg_bitrate = 0; -+ props->vbv_delay = UINT64_MAX; -+ } - av_dump_format(obj->oc, 0, obj->oc->filename, 1); - - if (obj->video_st) { diff -Nru yorick-av-0.0.4/debian/tests/check yorick-av-0.0.5/debian/tests/check --- yorick-av-0.0.4/debian/tests/check 1970-01-01 00:00:00.000000000 +0000 +++ yorick-av-0.0.5/debian/tests/check 2018-05-30 00:35:17.000000000 +0000 @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +cp check.i ${AUTOPKGTEST_TMP} +cd ${AUTOPKGTEST_ARTIFACTS} +YAV_NODISPLAY=nodisplay yorick -batch ${AUTOPKGTEST_TMP}/check.i + +exit 0 diff -Nru yorick-av-0.0.4/debian/tests/control yorick-av-0.0.5/debian/tests/control --- yorick-av-0.0.4/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ yorick-av-0.0.5/debian/tests/control 2018-05-30 00:39:56.000000000 +0000 @@ -0,0 +1,2 @@ +Tests: check +Restrictions: allow-stderr diff -Nru yorick-av-0.0.4/yav.c yorick-av-0.0.5/yav.c --- yorick-av-0.0.4/yav.c 2016-02-23 07:52:18.000000000 +0000 +++ yorick-av-0.0.5/yav.c 2018-02-19 16:57:40.000000000 +0000 @@ -5,7 +5,7 @@ * example-output.c by Fabrice Bellard and keeps its license. * * Copyright (c) 2003 Fabrice Bellard - * Copyright (c) 2012-2013, 2016 Thibaut Paumard + * Copyright (c) 2012-2013, 2016, 2018 Thibaut Paumard * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -34,20 +34,10 @@ #include #include -#ifndef AVIO_FLAG_WRITE -# define AVIO_FLAG_WRITE AVIO_WRONLY -#endif - -#if (LIBAVFORMAT_VERSION_MAJOR < 53) || \ - ((LIBAVFORMAT_VERSION_MAJOR == 53) && (LIBAVFORMAT_VERSION_MINOR < 9)) -# define avformat_new_stream(a, b) av_new_stream(a, 0) -#endif -#if (LIBAVUTIL_VERSION_MAJOR < 50) || \ - ((LIBAVUTIL_VERSION_MAJOR == 50) && (LIBAVUTIL_VERSION_MINOR < 44)) - // av_opt_set missing at least until this version - int av_opt_set (void *obj, const char * name, const char * val, - int search_flags) - { y_error("av_opt_set unimplemented in this libav/ffmpeg"); return -1; } +/* Deprecated and removed from FFmpeg 3.5, still present in 3.2 */ +/* By assigning 0, (obj->oc->oformat->flags & AVFMT_RAWPICTURE) always evals to false. */ +#ifndef AVFMT_RAWPICTURE +# define AVFMT_RAWPICTURE 0 #endif /* default parameter values */ @@ -57,7 +47,7 @@ #define YAV_MAX_B_FRAMES 16 #define YAV_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */ -inline int yav_arg_set(iarg) { return (iarg >= 0) && !yarg_nil(iarg); } +inline int yav_arg_set(int iarg) { return (iarg >= 0) && !yarg_nil(iarg); } typedef struct yav_ctxt { AVFrame *picture, *tmp_picture; @@ -65,9 +55,10 @@ int frame_count, video_outbuf_size; AVOutputFormat *fmt; AVFormatContext *oc; - AVStream *audio_st, *video_st; + AVStream *video_st; struct SwsContext *img_convert_ctx; AVCodec *codec; + AVCodecContext *enc; int open; } yav_ctxt; void yav_free(void*obj); @@ -87,14 +78,43 @@ obj->video_st=0; obj->img_convert_ctx = 0; obj->codec=0; + obj->enc=0; obj->open=0; - // audio_st=0; return obj; } +void yav_write_frame(yav_ctxt * obj, AVFrame * frame) { + int ret = 0.; + /* Set frame to NULL to close movie */ + AVCodecContext * c = obj->enc; + /* encode the image */ + ret = avcodec_send_frame(c, frame); + if (ret<0) + y_errorn("Error submitting frame for encoding: %d", ret); + while (ret >=0) { + AVPacket pkt = { 0 }; + av_init_packet(&pkt); + ret = avcodec_receive_packet(c, &pkt); + if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { + y_errorn( "Error encoding a video frame: %d", ret); + } else if (ret >= 0) { + av_packet_rescale_ts(&pkt, c->time_base, obj->video_st->time_base); + pkt.stream_index = obj->video_st->index; + /* Write the compressed frame to the media file. */ + ret = av_interleaved_write_frame(obj->oc, &pkt); + if (ret < 0) { + y_errorn("Error while writing video frame: %d", ret); + } + } + } +} + void yav_free(void*obj_) { yav_ctxt * obj = (yav_ctxt *)obj_; - if (obj->open) av_write_trailer(obj->oc); + if (obj->open) { + yav_write_frame(obj, NULL); // flush buffer of encoded frames + av_write_trailer(obj->oc); + } if (obj->picture){ av_free(obj->picture->data[0]); av_free(obj->picture); @@ -109,7 +129,7 @@ //if (obj->frame_count); // if (obj->video_outbuf_size); if (obj->video_st) { - avcodec_close(obj->video_st->codec); + avcodec_close(obj->enc); obj->video_st=0; } if (obj->oc) { @@ -198,21 +218,26 @@ /* add the audio and video streams using the default format codecs and initialize the codecs */ obj->video_st = NULL; - // audio_st = NULL; if (obj->oc->oformat->video_codec != AV_CODEC_ID_NONE) { AVCodecContext *c; obj->video_st = avformat_new_stream(obj->oc, NULL); - c = obj->video_st->codec; if (vcodec) { obj->codec = avcodec_find_encoder_by_name(vcodec); if (!obj->codec) y_error("can't find requested codec"); - c->codec_id = obj->codec->id; } else { - c->codec_id = obj->oc->oformat->video_codec; - obj->codec = avcodec_find_encoder(c->codec_id); + obj->codec = avcodec_find_encoder(obj->oc->oformat->video_codec); if (!obj->codec) y_error("default codec not found"); } - c->codec_type = AVMEDIA_TYPE_VIDEO; + c = avcodec_alloc_context3(obj->codec); + if (!c) + y_error("Could not alloc an encoding context"); + obj->enc = c; + + /* Look for bugs, remove those checks in the future */ + if (c->codec_id != obj->codec->id) + y_error("c->codec_id != obj->codec->id"); + if (c->codec_type != AVMEDIA_TYPE_VIDEO) + y_error("c->codec_type != AVMEDIA_TYPE_VIDEO"); avcodec_get_context_defaults3(c, obj->codec); if (c->codec_id == AV_CODEC_ID_NONE) c->codec_id = obj->codec->id; @@ -224,10 +249,12 @@ c->bit_rate = params[0] ? params[0] : YAV_BIT_RATE; c->time_base.den = params[1] ? params[1] : YAV_FRAME_RATE; c->time_base.num = 1; + obj->video_st->time_base.den = c->time_base.den; + obj->video_st->time_base.num = c->time_base.num; c->gop_size = params[2] ? params[2] : YAV_GOP_SIZE; c->max_b_frames = (params[3]>=0) ? params[3] : YAV_MAX_B_FRAMES; if(obj->oc->oformat->flags & AVFMT_GLOBALHEADER) - c->flags |= CODEC_FLAG_GLOBAL_HEADER; + c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; // codec-specific limitations switch (c->codec_id) { @@ -257,29 +284,45 @@ } void yav_opencodec(yav_ctxt *obj, unsigned int width, unsigned int height) { - obj->video_st->codec->width=width; - obj->video_st->codec->height=height; + obj->enc->width=width; + obj->enc->height=height; + if (obj->enc->codec_id == AV_CODEC_ID_MPEG1VIDEO || + obj->enc->codec_id == AV_CODEC_ID_MPEG2VIDEO) { + AVCPBProperties *props; + props = (AVCPBProperties*) av_stream_new_side_data + (obj->video_st, AV_PKT_DATA_CPB_PROPERTIES, sizeof(*props)); + props->buffer_size = width*height*4; + props->max_bitrate = 0; + props->min_bitrate = 0; + props->avg_bitrate = 0; + props->vbv_delay = UINT64_MAX; + } av_dump_format(obj->oc, 0, obj->oc->filename, 1); if (obj->video_st) { AVCodecContext *c; - c = obj->video_st->codec; + c = obj->enc; if (avcodec_open2(c, obj->codec, NULL) < 0) y_error("could not open codec\n"); + avcodec_parameters_from_context(obj->video_st->codecpar, obj->enc); + obj->picture = av_frame_alloc(); if (!obj->picture) y_error("Could not allocate picture"); - int size = avpicture_get_size(c->pix_fmt, c->width, c->height); + int size = av_image_get_buffer_size(c->pix_fmt, c->width, c->height, 1); uint8_t *picture_buf = av_malloc(size); if (!picture_buf) { av_frame_free(&obj->picture); y_error("unable to allocate memory"); } - avpicture_fill((AVPicture *)obj->picture, picture_buf, - c->pix_fmt, c->width, c->height); + av_image_fill_arrays(obj->picture->data, obj->picture->linesize, picture_buf, + c->pix_fmt, c->width, c->height, 1); + obj->picture->width=c->width; + obj->picture->height=c->height; + obj->picture->format=c->pix_fmt; if (obj->oc->oformat->video_codec == AV_CODEC_ID_H264 || obj->oc->oformat->video_codec == AV_CODEC_ID_THEORA) obj->picture->pts=-1; @@ -292,15 +335,18 @@ if (!obj->tmp_picture) { y_error("Could not allocate picture"); } - size = avpicture_get_size(AV_PIX_FMT_RGB24, c->width, c->height); + size = av_image_get_buffer_size(AV_PIX_FMT_RGB24, c->width, c->height, 1); uint8_t *tmp_picture_buf = av_malloc(size); if (!tmp_picture_buf) { av_frame_free(&obj->tmp_picture); av_frame_free(&obj->picture); y_error("unable to allocate memory"); } - avpicture_fill((AVPicture *)obj->tmp_picture, tmp_picture_buf, - AV_PIX_FMT_RGB24, c->width, c->height); + av_image_fill_arrays(obj->tmp_picture->data, obj->tmp_picture->linesize, tmp_picture_buf, + AV_PIX_FMT_RGB24, c->width, c->height, 1); + obj->tmp_picture->width=c->width; + obj->tmp_picture->height=c->height; + obj->tmp_picture->format=c->pix_fmt; } } @@ -312,7 +358,9 @@ obj->open = 1; /* write the stream header, if any */ - avformat_write_header(obj->oc, NULL); + int ret = avformat_write_header(obj->oc, NULL); + if (ret<0) + y_errorn("Error writing header: %d", ret); } @@ -321,7 +369,7 @@ Y_av_codec_opt_set(int argc) { yav_ctxt * obj = yget_obj(argc-1, &yav_ops); - AVCodecContext *c = obj->video_st->codec; + AVCodecContext *c = obj->enc; char* name = ygets_q(argc-2); char* val = ygets_q(argc-3); @@ -335,7 +383,7 @@ Y_av_write(int argc) { yav_ctxt * obj = yget_obj(argc-1, &yav_ops); - AVCodecContext *c = obj->video_st->codec; + AVCodecContext *c = obj->enc; long ntot=0; long dims[Y_DIMSIZE]={0,0}; @@ -383,10 +431,8 @@ if (obj->oc->oformat->video_codec == AV_CODEC_ID_H264 || obj->oc->oformat->video_codec == AV_CODEC_ID_THEORA) ++obj->picture->pts; - int ret=0; - -#if (LIBAVCODEC_VERSION_MAJOR > 53) if (obj->oc->oformat->flags & AVFMT_RAWPICTURE) { + int ret=0; /* Raw video case - directly store the picture in the packet */ AVPacket pkt; av_init_packet(&pkt); @@ -396,49 +442,13 @@ // pkt.size= out_size; // pkt.data = dst_picture.data[0]; pkt.size = sizeof(AVPicture); + av_packet_rescale_ts(&pkt, c->time_base, obj->video_st->time_base); ret = av_interleaved_write_frame(obj->oc, &pkt); + if (ret<0) + y_errorn("Error writing frame: %d", ret); } else { - AVPacket pkt = { 0 }; - int got_packet; - av_init_packet(&pkt); - /* encode the image */ - ret = avcodec_encode_video2(c, &pkt, obj->picture, &got_packet); - if (ret < 0) { - y_errorn("Error encoding video frame: %d", ret); - } - /* If size is zero, it means the image was buffered. */ - if (!ret && got_packet && pkt.size) { - pkt.stream_index = obj->video_st->index; - /* Write the compressed frame to the media file. */ - ret = av_interleaved_write_frame(obj->oc, &pkt); - } else { - ret = 0; - } + yav_write_frame(obj, obj->picture); } -#else - int out_size - = avcodec_encode_video(c, obj->video_outbuf, obj->video_outbuf_size, - obj->picture); - /* if zero size, it means the image was buffered */ - if (out_size > 0) { - AVPacket pkt; - av_init_packet(&pkt); - - if (c->coded_frame->pts != AV_NOPTS_VALUE) - pkt.pts= av_rescale_q(c->coded_frame->pts, c->time_base, - obj->video_st->time_base); - if(c->coded_frame->key_frame) - pkt.flags |= AV_PKT_FLAG_KEY; - pkt.stream_index= obj->video_st->index; - pkt.data= obj->video_outbuf; - pkt.size= out_size; - /* write the compressed frame in the media file */ - ret = av_interleaved_write_frame(obj->oc, &pkt); - } -#endif - - if (ret != 0) - y_errorn("Error while writing video frame: %d", ret); /* return [] */ ypush_nil();