FFMPEG 缩放视频而不过滤

标签 ffmpeg

我有兴趣在不应用任何过滤器或任何东西的情况下将视频缩放到更大的尺寸。输出视频应该看起来非常像素化。我如何在 FFMPEG 中做到这一点?

根据 Ronald S. Bultje 的建议,我正在使用邻居标志。我还决定使用 rawvideo 编解码器来避免压缩。

我正在运行的当前命令是

ffmpeg -i vid.avi -s 800x800 -sws_flags neighbor -sws_dither none -vcodec rawvideo vid2.avi

该命令的命令行输出是
ffmpeg version 2.7 Copyright (c) 2000-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, avi, from 'vid.avi':
  Duration: 00:00:25.00, start: 0.000000, bitrate: 226 kb/s
    Stream #0:0: Video: rawvideo, pal8, 80x80, 206 kb/s, 4 fps, 4 tbr, 4 tbn, 4 tbc
File 'vid2.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'vid2.avi':
  Metadata:
    ISFT            : Lavf56.36.100
    Stream #0:0: Video: rawvideo, pal8, 800x800, q=2-31, 200 kb/s, 4 fps, 4 tbn, 4 tbc
    Metadata:
      encoder         : Lavc56.41.100 rawvideo
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame=  100 fps=0.0 q=0.0 Lsize=   62608kB time=00:00:25.00 bitrate=20515.4kbits/s    
video:62600kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.012614%

最佳答案

ffmpeg -i infile -vf scale=WIDTH:HEIGHT:flags=neighbor outfile

或者
ffmpeg -i infile -s WIDTHxHEIGHT -sws_flags neighbor outfile

这里的关键部分是flags-sws_flags ,它选择过滤器(和其他与缩放相关的标志)。默认过滤器值为 bicublin (IIRC),即 bicubic亮度和 bilinear色度滤镜。 Nearest-neighbour会做你要求的。

scaler options列出其他缩放算法。

关于FFMPEG 缩放视频而不过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30992760/

相关文章:

php - 如何将调用程序的输出重定向到文件?

android - 我需要帮助制作视频拼贴,尝试了所有方法但没有成功

ffmpeg - Phpvideotoolkit - "maxlen ' = >' 3072 ' 在 buggedcom\phpvideotoolkit\src\PHPVideoToolkit\Mime.php 行 202"

ffmpeg - 输出文件为空,未编码任何内容(如果使用,请检查 -ss/-t/-frames 参数)

c - 如何使用 libAV 库(ffmpeg)将 H264 编码数据放入 .mp4 等容器中?

youtube - 如何将 mp4 纵横比更改为 16 :9 using ffmpeg?

安卓 NDK : Aborting stop?

video - FFMPEG 支持 HEVC 解码

android - FFmpeg4Android : How to select videos from gallery?

unity3d - 统一: Converting Texture2D to YUV420P using FFmpeg