ffmpeg avs转avi无损转换

Ffmpeg avs to avi lossless conversion

如何在不损失质量的情况下将 avs(Avisynth 文件)转换为 avi?

首先,我将 avs 更改为 264:

ffmpeg -i "Source.avs" -c:v libx264 -preset veryslow -crf 24 "Output.264"

其次,我正在尝试将 264 格式转换为 avi:

ffmpeg -i "input.264" "output.avi"

最终的avi应该有将近200MB,但只有2MB。 264文件差不多有150MB,应该还好吧。我认为我应该在第二个命令中使用一些编解码器,但我不知道是哪个。这几天我一直在尝试更改此设置,但没有效果。

或者有没有264无损转换的方法,只有avs转avi?

感谢您的帮助。

编辑:

感谢您的解答。不幸的是,这两种方法都失败了。 首先给我一个视频,视频很模糊,我什么也看不到。

输出:

C:\Users\Piotr>"C:\Users\Piotr\Documents\Visual Studio 2010\Projects\SoRecorder\
SoRecorder\bin\Release\Ffmpeg\ffmpeg.exe" -i "C:\Users\Piotr\Documents\Visual St
udio 2010\Projects\SoRecorder\SoRecorder\bin\Release\Scripts\-2016-02-20.avs" -c
 copy "E:\-2016-02-20.avi"
ffmpeg version N-78559-g2e8ad2d Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --
enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-lib
x265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-d
ecklink --enable-zlib
  libavutil      55. 17.103 / 55. 17.103
  libavcodec     57. 24.103 / 57. 24.103
  libavformat    57. 25.100 / 57. 25.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 32.100 /  6. 32.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, avisynth, from 'C:\Users\Piotr\Documents\Visual Studio 2010\Projects\S
oRecorder\SoRecorder\bin\Release\Scripts\-2016-02-20.avs':
  Duration: 00:00:21.80, start: 0.000000, bitrate: 0 kb/s
    Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 1280x720, 15 fps, 15
 tbr, 15 tbn, 15 tbc
[avi @ 048d8cc0] bgra rawvideo cannot be written to avi, output file will be unr
eadable
Output #0, avi, to 'E:\-2016-02-20.avi':
  Metadata:
    ISFT            : Lavf57.25.100
    Stream #0:0: Video: rawvideo, bgra, 1280x720, q=2-31, 15 fps, 15 tbr, 15 tbn
, 15 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=   41 fps=0.0 q=-1.0 size=  147606kB time=00:00:02.73 bitrate=442385.6kbit
frame=   65 fps= 63 q=-1.0 size=  234006kB time=00:00:04.33 bitrate=442379.5kbit
frame=   93 fps= 60 q=-1.0 size=  334806kB time=00:00:06.20 bitrate=442376.3kbit
frame=  110 fps= 51 q=-1.0 size=  396006kB time=00:00:07.33 bitrate=442375.2kbit
frame=  116 fps= 42 q=-1.0 size=  417606kB time=00:00:07.73 bitrate=442374.9kbit
frame=  122 fps= 37 q=-1.0 size=  439206kB time=00:00:08.13 bitrate=442374.6kbit
frame=  128 fps= 33 q=-1.0 size=  460807kB time=00:00:08.53 bitrate=442374.3kbit
frame=  133 fps= 31 q=-1.0 size=  478807kB time=00:00:08.86 bitrate=442374.1kbit
frame=  139 fps= 29 q=-1.0 size=  500407kB time=00:00:09.26 bitrate=442373.8kbit
frame=  145 fps= 27 q=-1.0 size=  522007kB time=00:00:09.66 bitrate=442373.6kbit
frame=  151 fps= 25 q=-1.0 size=  543607kB time=00:00:10.06 bitrate=442373.5kbit
frame=  157 fps= 24 q=-1.0 size=  565207kB time=00:00:10.46 bitrate=442373.3kbit
frame=  163 fps= 23 q=-1.0 size=  586807kB time=00:00:10.86 bitrate=442373.1kbit
frame=  169 fps= 22 q=-1.0 size=  608407kB time=00:00:11.26 bitrate=442373.0kbit
frame=  175 fps= 21 q=-1.0 size=  630007kB time=00:00:11.66 bitrate=442372.8kbit
frame=  181 fps= 21 q=-1.0 size=  651607kB time=00:00:12.06 bitrate=442372.7kbit
frame=  187 fps= 20 q=-1.0 size=  673207kB time=00:00:12.46 bitrate=442372.6kbit
frame=  193 fps= 19 q=-1.0 size=  694807kB time=00:00:12.86 bitrate=442372.5kbit
frame=  199 fps= 19 q=-1.0 size=  716407kB time=00:00:13.26 bitrate=442372.4kbit
frame=  204 fps= 19 q=-1.0 size=  734407kB time=00:00:13.60 bitrate=442372.3kbit
frame=  210 fps= 18 q=-1.0 size=  756007kB time=00:00:14.00 bitrate=442372.2kbit
frame=  215 fps= 18 q=-1.0 size=  774007kB time=00:00:14.33 bitrate=442372.1kbit
frame=  221 fps= 18 q=-1.0 size=  795607kB time=00:00:14.73 bitrate=442372.1kbit
frame=  226 fps= 17 q=-1.0 size=  813607kB time=00:00:15.06 bitrate=442372.0kbit
frame=  232 fps= 17 q=-1.0 size=  835207kB time=00:00:15.46 bitrate=442371.9kbit
frame=  238 fps= 17 q=-1.0 size=  856807kB time=00:00:15.86 bitrate=442371.8kbit
frame=  244 fps= 17 q=-1.0 size=  878407kB time=00:00:16.26 bitrate=442371.7kbit
frame=  250 fps= 16 q=-1.0 size=  900007kB time=00:00:16.66 bitrate=442371.7kbit
frame=  256 fps= 16 q=-1.0 size=  921608kB time=00:00:17.06 bitrate=442371.6kbit
frame=  261 fps= 16 q=-1.0 size=  939608kB time=00:00:17.40 bitrate=442371.6kbit
frame=  267 fps= 16 q=-1.0 size=  961208kB time=00:00:17.80 bitrate=442371.5kbit
frame=  273 fps= 16 q=-1.0 size=  982808kB time=00:00:18.20 bitrate=442371.5kbit
frame=  278 fps= 16 q=-1.0 size= 1000808kB time=00:00:18.53 bitrate=442371.4kbit
frame=  284 fps= 15 q=-1.0 size= 1022408kB time=00:00:18.93 bitrate=442371.4kbit
frame=  290 fps= 15 q=-1.0 size= 1044008kB time=00:00:19.33 bitrate=442371.3kbit
frame=  296 fps= 15 q=-1.0 size= 1065615kB time=00:00:19.73 bitrate=442374.1kbit
frame=  302 fps= 15 q=-1.0 size= 1087215kB time=00:00:20.13 bitrate=442374.0kbit
frame=  308 fps= 15 q=-1.0 size= 1108815kB time=00:00:20.53 bitrate=442373.9kbit
frame=  314 fps= 15 q=-1.0 size= 1130415kB time=00:00:20.93 bitrate=442373.8kbit
frame=  320 fps= 15 q=-1.0 size= 1152015kB time=00:00:21.33 bitrate=442373.7kbit
frame=  326 fps= 15 q=-1.0 size= 1173615kB time=00:00:21.73 bitrate=442373.7kbit
frame=  327 fps= 15 q=-1.0 Lsize= 1177215kB time=00:00:21.80 bitrate=442373.8kbi
ts/s speed=0.967x
video:1177200kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxi
ng overhead: 0.001301%

编辑:PNG 命令后的输出:

C:\Users\Piotr>"C:\Users\Piotr\Documents\Visual Studio 2010\Projects\SoRecorder\
SoRecorder\bin\Release\Ffmpeg\ffmpeg.exe" -i "C:\Users\Piotr\Documents\Visual St
udio 2010\Projects\SoRecorder\SoRecorder\bin\Release\Scripts\-2016-02-21--1.avs"
 -c:v png -pix_fmt bgra "E:\-2016-02-21.avi"
ffmpeg version N-78559-g2e8ad2d Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --
enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-lib
x265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-d
ecklink --enable-zlib
  libavutil      55. 17.103 / 55. 17.103
  libavcodec     57. 24.103 / 57. 24.103
  libavformat    57. 25.100 / 57. 25.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 32.100 /  6. 32.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, avisynth, from 'C:\Users\Piotr\Documents\Visual Studio 2010\Projects\S
oRecorder\SoRecorder\bin\Release\Scripts\-2016-02-21--1.avs':
  Duration: 00:00:25.07, start: 0.000000, bitrate: 0 kb/s
    Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 640x480, 30 fps, 30
tbr, 30 tbn, 30 tbc
Incompatible pixel format 'bgra' for codec 'png', auto-selecting format 'rgba'
Output #0, avi, to 'E:\-2016-02-21.avi':
  Metadata:
    ISFT            : Lavf57.25.100
    Stream #0:0: Video: png (MPNG / 0x474E504D), rgba, 640x480, q=2-31, 200 kb/s
, 30 fps, 30 tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.24.103 png
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> png (native))
Press [q] to stop, [?] for help
frame=   18 fps=0.0 q=-0.0 size=   10716kB time=00:00:00.46 bitrate=188119.0kbit
frame=   35 fps= 34 q=-0.0 size=   23722kB time=00:00:01.03 bitrate=188065.8kbit
frame=   48 fps= 27 q=-0.0 size=   33668kB time=00:00:01.46 bitrate=188052.7kbit
frame=   61 fps= 26 q=-0.0 size=   43614kB time=00:00:01.90 bitrate=188045.7kbit
frame=   74 fps= 26 q=-0.0 size=   53560kB time=00:00:02.33 bitrate=188041.3kbit
frame=   89 fps= 26 q=-0.0 size=   65036kB time=00:00:02.83 bitrate=188037.8kbit
frame=  106 fps= 27 q=-0.0 size=   78042kB time=00:00:03.40 bitrate=188035.1kbit
frame=  123 fps= 28 q=-0.0 size=   91048kB time=00:00:03.96 bitrate=188033.2kbit
frame=  137 fps= 28 q=-0.0 size=  101759kB time=00:00:04.43 bitrate=188032.0kbit
frame=  155 fps= 28 q=-0.0 size=  115530kB time=00:00:05.03 bitrate=188030.8kbit
frame=  186 fps= 31 q=-0.0 size=  125735kB time=00:00:06.06 bitrate=169783.8kbit
frame=  224 fps= 35 q=-0.0 size=  133831kB time=00:00:07.33 bitrate=149501.7kbit
frame=  261 fps= 37 q=-0.0 size=  142679kB time=00:00:08.56 bitrate=136438.4kbit
frame=  300 fps= 40 q=-0.0 size=  151249kB time=00:00:09.86 bitrate=125577.5kbit
frame=  338 fps= 42 q=-0.0 size=  159452kB time=00:00:11.13 bitrate=117326.2kbit
frame=  371 fps= 44 q=-0.0 size=  169169kB time=00:00:12.23 bitrate=113283.3kbit
frame=  407 fps= 45 q=-0.0 size=  178924kB time=00:00:13.43 bitrate=109112.3kbit
frame=  444 fps= 47 q=-0.0 size=  187571kB time=00:00:14.66 bitrate=104767.1kbit
frame=  488 fps= 49 q=-0.0 size=  194672kB time=00:00:16.13 bitrate=98848.5kbits
frame=  535 fps= 51 q=-0.0 size=  199781kB time=00:00:17.70 bitrate=92463.5kbits
frame=  569 fps= 52 q=-0.0 size=  208530kB time=00:00:18.83 bitrate=90705.2kbits
frame=  604 fps= 52 q=-0.0 size=  216658kB time=00:00:20.00 bitrate=88743.0kbits
frame=  622 fps= 52 q=-0.0 size=  229851kB time=00:00:20.60 bitrate=91404.7kbits
frame=  639 fps= 51 q=-0.0 size=  242857kB time=00:00:21.16 bitrate=93991.3kbits
frame=  656 fps= 50 q=-0.0 size=  255863kB time=00:00:21.73 bitrate=96443.0kbits
frame=  673 fps= 49 q=-0.0 size=  268869kB time=00:00:22.30 bitrate=98770.1kbits
frame=  690 fps= 49 q=-0.0 size=  281875kB time=00:00:22.86 bitrate=100981.9kbit
frame=  707 fps= 48 q=-0.0 size=  294881kB time=00:00:23.43 bitrate=103086.7kbit
frame=  724 fps= 48 q=-0.0 size=  307887kB time=00:00:24.00 bitrate=105092.1kbit
frame=  741 fps= 47 q=-0.0 size=  320893kB time=00:00:24.56 bitrate=107005.0kbit
frame=  752 fps= 46 q=-0.0 Lsize=  332381kB time=00:00:25.06 bitrate=108624.9kbi
ts/s speed=1.54x
video:332357kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxin
g overhead: 0.007042%

您的 Avisynth 输入未压缩,因此您可以像这样将其包装在 AVI 中:

ffmpeg -i source.avs -c:v rawvideo -pix_fmt bgra source.avi

不需要通过 H.264 进行中介。在任何情况下,您的命令都不会产生无损 H.264。为此,您需要

ffmpeg -i "Source.avs" -c:v libx264rgb -crf 0 "Output.avi"

(如果源包含 alpha 通道,这将是不可接受的,因为 H.264 不支持 alpha)