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. 第1节 MapReduce入门:11、mapreduce程序的入门

    1.1.理解MapReduce思想 MapReduce思想在生活中处处可见.或多或少都曾接触过这种思想.MapReduce的思想核心是“分而治之”,适用于大量复杂的任务处理场景(大规模数据处理场景). ...

  2. bootstrap-table的一些基本使用及表内编辑的实现

    最近工作需要接触了bootstrap-table 所以研究了一下,并做了笔记,红色位置要特别注意 前端主要使用了 jquery bootstrap-table  bootstrap-edittable ...

  3. 51nod 1551 集合交易 最大权闭合子图

    题意: 市场中有n个集合在卖.我们想买到满足以下要求的一些集合,所买到集合的个数要等于所有买到的集合合并后的元素的个数. 每个集合有相应的价格,要使买到的集合花费最小. 这里我们的集合有一个特点:对于 ...

  4. Samba 学习笔记

    这个网站不错.https://www.ibm.com/developerworks/cn/linux/l-lpic3-311-1/

  5. 树莓派2-SSH

    树莓派3系统SSH是默认关闭的, 将SD卡插入linux, 在root 分区, 修改/etc/rc.local 在exit 0前增加一行 /ect/init.d/ssh start 将SD卡插回树莓派 ...

  6. UVA 1589 象棋

    题意: 给出一个黑方的将, 然后 红方有 2 ~ 7 个棋子, 给出摆放位置,问是否已经把黑将将死, 红方已经将军. 分析: 分情况处理, 车 马 炮, 红将情况跟车是一样的. 建一个数组board保 ...

  7. 3.2.11 行 vs 字符串

        了解行(line)与字符串(string)的差异是相当重要的.大部分简易程序都是处理输入数据的行,像 grep 与 egrep,以及 sed 大部分的工作(99%)都是这样.在这些情况下,不会 ...

  8. allegro中出光绘文件遇到问题的解决办法

    一:设置好光绘文件参数后,选择check dabase before artwork后,点击生成光绘时出现错误告警信息:    database has errors:artwork generati ...

  9. POJ-3041 Asteroids,二分匹配解决棋盘问题。

    Asteroids Time Limit: 1000MS   Memory Limit: 65536K       Description Bessie wants to navigate her s ...

  10. Light oj-1002 - Country Roads,迪杰斯特拉变形,不错不错~~

                                                                                               1002 - Co ...