ffmpeg resize maintain aspect - 找不到过滤器
ffmpeg resize maintain aspect - filter not found
我正在尝试创建保持原始外观的图像缩略图,但如果尺寸太远则将其裁剪。
找到了一个可能的代码片段 here
ffmpeg -i Einstein_500_459.jpg -vf scale="'if(gt(a,320/240),320,-1)':'if(gt(a,320/240),-1,240)'" Einstein_320x240_fit.png
但无法让 ffmpeg 执行它。因为它在终端中产生错误:
ffmpeg -i Einstein_500_459.jpg -vf scale="'if(gt(a,320/240),320,-1)':'if(gt(a,320/240),-1,240)'" Einstein_320x240_fit.png
ffmpeg version 0.10.12-7:0.10.12-1~precise1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 26 2014 09:49:36 with gcc 4.6.3
configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.12-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, image2, from 'Einstein_500_459.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p, 500x459 [SAR 300:300 DAR 500:459], 25 tbr, 25 tbn, 25 tbc
Incompatible pixel format 'yuvj444p' for codec 'png', auto-selecting format 'rgb24'
[buffer @ 0x236d720] w:500 h:459 pixfmt:yuvj444p tb:1/1000000 sar:300/300 sws_param:
[scale @ 0x235d5e0] [Eval @ 0x7fffcb68f270] Missing ')' or too many args in 'if(gt(a,320/240),320,-1)'
[scale @ 0x235d5e0] [Eval @ 0x7fffcb68f270] Missing ')' or too many args in 'if(gt(a,320/240),-1,240)'
Error when evaluating the expression 'if(gt(a,320/240),-1,240)'.
Maybe the expression for out_w:'if(gt(a,320/240),320,-1)' or for out_h:'if(gt(a,320/240),-1,240)' is self-referencing.
Error opening filters!
转义单引号后
ffmpeg -i Einstein_500_459.jpg -vf scale="\'if(gt(a,320/240),320,-1)\':\'if(gt(a,320/240),-1,240)\'" Einstein_320x240_fit.png
它产生错误
ffmpeg -i Einstein_500_459.jpg -vf scale="\'if(gt(a,320/240),320,-1)\':\'if(gt(a,320/240),-1,240)\'" Einstein_320x240_fit.png
ffmpeg version 0.10.12-7:0.10.12-1~precise1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 26 2014 09:49:36 with gcc 4.6.3
configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.12-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, image2, from 'Einstein_500_459.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p, 500x459 [SAR 300:300 DAR 500:459], 25 tbr, 25 tbn, 25 tbc
Incompatible pixel format 'yuvj444p' for codec 'png', auto-selecting format 'rgb24'
[buffer @ 0x1897720] w:500 h:459 pixfmt:yuvj444p tb:1/1000000 sar:300/300 sws_param:
No such filter: '320/240)'
Error opening filters!
这只是语法问题吗?还是我的 ffmpeg 遗漏了什么?或者是什么?
这是 ubuntu 12.04,我认为是 ffmpeg 的完整安装,而不是 libav 默认的东西。感谢您的帮助。
解决方案是为遇到此问题的其他人安装最新的 ffmpeg。
ffmpeg -i Einstein_500_459.jpg -vf scale="'if(gt(a,320/240),320,-1)':'if(gt(a,320/240),-1,240)'" Einstein_320x240_fit.png
此代码在 ubuntu 12.04 - ffmpeg 版本:2.8.3
上运行没有问题
ubuntu 12.04 或 14.04 HERE
上有编译最新 ffmpeg 的脚本
我正在尝试创建保持原始外观的图像缩略图,但如果尺寸太远则将其裁剪。 找到了一个可能的代码片段 here
ffmpeg -i Einstein_500_459.jpg -vf scale="'if(gt(a,320/240),320,-1)':'if(gt(a,320/240),-1,240)'" Einstein_320x240_fit.png
但无法让 ffmpeg 执行它。因为它在终端中产生错误:
ffmpeg -i Einstein_500_459.jpg -vf scale="'if(gt(a,320/240),320,-1)':'if(gt(a,320/240),-1,240)'" Einstein_320x240_fit.png
ffmpeg version 0.10.12-7:0.10.12-1~precise1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 26 2014 09:49:36 with gcc 4.6.3
configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.12-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, image2, from 'Einstein_500_459.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p, 500x459 [SAR 300:300 DAR 500:459], 25 tbr, 25 tbn, 25 tbc
Incompatible pixel format 'yuvj444p' for codec 'png', auto-selecting format 'rgb24'
[buffer @ 0x236d720] w:500 h:459 pixfmt:yuvj444p tb:1/1000000 sar:300/300 sws_param:
[scale @ 0x235d5e0] [Eval @ 0x7fffcb68f270] Missing ')' or too many args in 'if(gt(a,320/240),320,-1)'
[scale @ 0x235d5e0] [Eval @ 0x7fffcb68f270] Missing ')' or too many args in 'if(gt(a,320/240),-1,240)'
Error when evaluating the expression 'if(gt(a,320/240),-1,240)'.
Maybe the expression for out_w:'if(gt(a,320/240),320,-1)' or for out_h:'if(gt(a,320/240),-1,240)' is self-referencing.
Error opening filters!
转义单引号后
ffmpeg -i Einstein_500_459.jpg -vf scale="\'if(gt(a,320/240),320,-1)\':\'if(gt(a,320/240),-1,240)\'" Einstein_320x240_fit.png
它产生错误
ffmpeg -i Einstein_500_459.jpg -vf scale="\'if(gt(a,320/240),320,-1)\':\'if(gt(a,320/240),-1,240)\'" Einstein_320x240_fit.png
ffmpeg version 0.10.12-7:0.10.12-1~precise1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 26 2014 09:49:36 with gcc 4.6.3
configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.12-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, image2, from 'Einstein_500_459.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p, 500x459 [SAR 300:300 DAR 500:459], 25 tbr, 25 tbn, 25 tbc
Incompatible pixel format 'yuvj444p' for codec 'png', auto-selecting format 'rgb24'
[buffer @ 0x1897720] w:500 h:459 pixfmt:yuvj444p tb:1/1000000 sar:300/300 sws_param:
No such filter: '320/240)'
Error opening filters!
这只是语法问题吗?还是我的 ffmpeg 遗漏了什么?或者是什么? 这是 ubuntu 12.04,我认为是 ffmpeg 的完整安装,而不是 libav 默认的东西。感谢您的帮助。
解决方案是为遇到此问题的其他人安装最新的 ffmpeg。
ffmpeg -i Einstein_500_459.jpg -vf scale="'if(gt(a,320/240),320,-1)':'if(gt(a,320/240),-1,240)'" Einstein_320x240_fit.png
此代码在 ubuntu 12.04 - ffmpeg 版本:2.8.3
上运行没有问题ubuntu 12.04 或 14.04 HERE
上有编译最新 ffmpeg 的脚本