height not divisible by 2

h.264 - FFMPEG (libx264) "height not divisible by 2" - Stack Overflow  https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2

After playing around with this a bit, I think I've answered my own question. Here is the solution in case anyone else runs into a similar issue... I had to add the below argument to the command:

-vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"

Command:

ffmpeg -r 24 -i frame_%05d.jpg -vcodec libx264 -y -an video.mp4 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"

Basically, .h264 needs even dimensions so this filter will:

  1. Divide the original height and width by 2
  2. Round it down to the nearest pixel
  3. Multiply it by 2 again, thus making it an even number

尺寸调整为不大于的最小偶数

from PIL import Image

f = 'my.jpg'
mid_icon = Image.open(f)
h, w = mid_icon.height, mid_icon.width
h, w = int(h / 2) * 2, int(w / 2) * 2
mid_icon = mid_icon.resize((w, h), Image.ANTIALIAS)
mid_icon.save(f)
from PIL import Image

def img_to_floor_even(f):
try:
fo = Image.open(f)
w, h = fo.width, fo.height
w_, h_ = int(w / 2) * 2, int(h / 2) * 2
if (w, h) != (w_, h):
fo = fo.resize((w_, h_), Image.ANTIALIAS)
fo.save(f)
except Exception as e:
print(e)
# log

  

  

height not divisible by 2的更多相关文章

  1. ffmpeg按比例缩放--"width / height not divisible by 2" 解决方法

    最近在处理视频的时候,有这么一个需求 如果视频的分辨率宽度大于960的话,就把宽度设为960,而高度按其比例进行缩放 如果视频的分辨率高度大于540的话,就把高度设为540,而宽度按其比例进行缩放 之 ...

  2. # [libx264 @ 00000275eb57fec0] height not divisible by 2 (520x325)

    # [libx264 @ 00000275eb57fec0] height not divisible by 2 (520x325)

  3. ffmpeg基本功能使用

    任务描述:由给定图像序列合成 24fps 视频 方案一 直接对图像进行操作,适用于图像名比较规范且默认即为所需顺序 ffmpeg -f image2 -i ./images_crop_%d.png - ...

  4. ffmpeg入门篇-滤镜的基本使用

    转发自白狼栈:查看原文 滤镜 什么是滤镜?百度百科介绍说"滤镜主要是用来实现图像的各种特殊效果......". 我们最早在ffmpeg是如何转码的一文中了解过滤镜,来回顾下当时的转 ...

  5. ffmpeg细节整理记录

    ffmpeg细节整理记录 1.-vcodec.-code:v.-c:v ffmpeg的官方文档 -vcodec 是 -code:v 别名. -vcodec codec (output) Set the ...

  6. [PyData] 03 - Data Representation

    Ref: http://blog.csdn.net/u013534498/article/details/51399035 如何在Python中实现这五类强大的概率分布 考虑下在mgrid上画二维概率 ...

  7. H5 canvas的 width、height 与style中宽高的区别

    Canvas 的width height属性 1.当使用width height属性时,显示正常不会被拉伸:如下 <canvas id="mycanvas" width=&q ...

  8. height:100% 布局

    常常会碰到需要填满整个浏览器,并且自适应高度的需求.首先肯定会想到给容器设定height:100%,但是会没有效果.原因是body没有高度,所以百分比无法生效. 解决方案:给html,body,标签都 ...

  9. 页面width与height使用百分比来划分不起作用解决办法--记录六

    有时候你写 <div style="width:80%;height:100%;border:1px solid red"></div> <div s ...

随机推荐

  1. JFinal项目eclipse出现the table mapping of model: com.gexin.model.scenic.Scenic not exists or the ActiveRecordPlugin not start.

    JFinal项目eclipse出现the table mapping of model: com.gexin.model.scenic.Scenic not exists or the ActiveR ...

  2. [Python3网络爬虫开发实战] 6.2-Ajax分析方法

    这里还以前面的微博为例,我们知道拖动刷新的内容由Ajax加载,而且页面的URL没有变化,那么应该到哪里去查看这些Ajax请求呢? 1. 查看请求 这里还需要借助浏览器的开发者工具,下面以Chrome浏 ...

  3. linux下nginx、php和mysql安装配置

    一.安装nginx 安装nginx yum install -y epel-release yum install nginx -y 查看nginx软件包包括了哪些文件 rpm -ql nginx 启 ...

  4. 在移动端H5开发中(关于安卓端position:fixed和position:absolute;和虚拟键盘冲突的问题,以及解决方案)

    一.在开发移动端webapp时,我们经常会遇到这样的问题,当我们需要在页面底部固定一个logo或者说明时,往往会采用position:fixed进行固定定位或者absolute定位到最底部 这是一个很 ...

  5. 集训第六周 E题

    E - 期望(经典问题) Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit S ...

  6. 【转】Asp.net MVC Comet推送

    原文链接:http://www.cnblogs.com/kissdodog/p/4283485.html 一.简介 在Asp.net MVC实现的Comet推送的原理很简单. 服务器端:接收到服务器发 ...

  7. Spark 静态内存管理

    作者编辑:杜晓蝶,王玮,任泽 Spark 静态内存管理详解 一. 内容简介 spark从1.6开始引入了动态内存管理模式,即执行内存和存储内存之间可以互相抢占.spark提供两种内存分配模式,即:静态 ...

  8. ehcache、memcache、redis三大缓存比较

    最近项目组有用到这三个缓存,去各自的官方看了下,觉得还真的各有千秋!今天特意归纳下各个缓存的优缺点,仅供参考!  Ehcache 在Java项目广泛的使用.它是一个开源的.设计于提高在数据从RDBMS ...

  9. ***mysql 用一个表的一列,去更新另一表的一列

    需求: 老板给了一个EXCEL数据,是本人提供的一个模板,含ID,现在相当于要导入这新增的一列数据到数据库中的某一个表. 方法一:用navicat,在excel中复制一列,再粘贴到navicat中的一 ...

  10. Mayor's posters POJ - 2528

    The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign h ...