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 <thibaut@debian.org>
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) {
