大约三月份的时候,我发现通过 ffmpeg 将 MPEG4 转换为 AMV以超级用户身份。并成功使用此命令将 MP4 转换为 AMV:
ffmpeg -i C:\Users\26591\Videos\WebADB-Demo.mp4 -s 160x120 -ac 1 -ar 22050 -vstrict -1 -r 25 -block_size 882 C:\Users\26591\Videos\WebADB-Demo.amv
当时我用的是windows的git版本的ffmpeg,在ubuntu上尝试运行这行代码的时候提示找不到amv流,后来在使用ffmpeg转换视频:AMV容器被拒绝的解决办法?
但是今天我在 ffmpeg 的 GIT 版本上尝试这段代码时,出现了错误信息:
C:\Users\26591\Documents>ffmpeg -i C:\Users\26591\Videos\WebADB-Demo.mp4 -s 160x120 -ac 1 -ar 22050 -vstrict -1 -r 25 -block_size 882 C:\Users\26591\Videos\WebADB-Demo.amv
ffmpeg version 2022-08-29-git-f99d15cca0-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 57. 34.100 / 57. 34.100
libavcodec 59. 42.103 / 59. 42.103
libavformat 59. 30.100 / 59. 30.100
libavdevice 59. 8.101 / 59. 8.101
libavfilter 8. 46.103 / 8. 46.103
libswscale 6. 8.104 / 6. 8.104
libswresample 4. 9.100 / 4. 9.100
libpostproc 56. 7.100 / 56. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\26591\Videos\WebADB-Demo.mp4':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: mp41avc1
creation_time : 2017-09-29T13:11:57.000000Z
encoder : vlc 2.2.6 stream output
encoder-eng : vlc 2.2.6 stream output
Duration: 00:00:11.96, start: 0.000000, bitrate: 720 kb/s
Stream #0:0[0x1](eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080, 719 kb/s, 24.92 fps, 25 tbr, 1000k tbn (default)
Metadata:
creation_time : 2017-09-29T13:11:57.000000Z
handler_name : VideoHandler
vendor_id : [0][0][0][0]
Codec AVOption block_size (set the block size) specified for output file #0 (C:\Users\26591\Videos\WebADB-Demo.amv) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
File 'C:\Users\26591\Videos\WebADB-Demo.amv' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> amv (native))
Press [q] to stop, [?] for help
[swscaler @ 0000028e3b9d6d00] [swscaler @ 0000028e3be000c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000028e3b9d6d00] [swscaler @ 0000028e3be36e00] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000028e3b9d6d00] [swscaler @ 0000028e3be7ae80] deprecated pixel format used, make sure you did set range correctly
[amv @ 0000028e3abded40] AMV files only support 2 streams
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Conversion failed!
在此之前,这行代码没有任何警告和错误。当ffmpeg提示我未选择任何视频流时,我修改了代码为:
ffmpeg -i C:\Users\26591\Videos\WebADB-Demo.mp4 -s 160x120 -ac 1 -ar 22050 -vstrict -1 -r 25 -block_size 882 -map 0:0 -c:v amv -c:a adpcm_ima_amv -pix_fmt yuvj420p C:\Users\26591\Videos\WebADB-Demo.amv
但是错误一直没有改变,不知道为什么AMV只支持两个流。为什么这个问题在之前的git版本ffmpeg中没有出现?有谁能帮我解决这个问题?(这是我的转换文件https://drive.google.com/file/d/14-2O38Sq04QyJXREJ7rLAAcfTPx4Lp8H/view?usp=sharing
:)
2022.09.01---根据pieru和ROTEM的评论,我又改了一个文件,这个视频文件是WebM格式的,但是这个视频有视频流和音频流,我尝试用修改后的命令转换,结果错误一点都没变:
C:\Users\26591\Documents>ffmpeg -i C:\Users\26591\Pictures\0801f452a88bdf167b0f308c4cd6e7d9.webm -s 160x120 -ac 1 -ar 22050 -vstrict -1 -r 25 -block_size 882 -map 0:0 -c:v amv -c:a adpcm_ima_amv -pix_fmt yuvj420p C:\Users\26591\Videos\0801f452a88bdf167b0f308c4cd6e7d9.amv
ffmpeg version 2022-08-29-git-f99d15cca0-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
libavutil 57. 34.100 / 57. 34.100
libavcodec 59. 42.103 / 59. 42.103
libavformat 59. 30.100 / 59. 30.100
libavdevice 59. 8.101 / 59. 8.101
libavfilter 8. 46.103 / 8. 46.103
libswscale 6. 8.104 / 6. 8.104
libswresample 4. 9.100 / 4. 9.100
libpostproc 56. 7.100 / 56. 7.100
Input #0, matroska,webm, from 'C:\Users\26591\Pictures\0801f452a88bdf167b0f308c4cd6e7d9.webm':
Metadata:
title : アニメ_途中, ayaka
URL : http://ginziro.blog45.fc2.com/blog-entry-1102.html
MAJOR_BRAND : isom
MINOR_VERSION : 512
COMPATIBLE_BRANDS: isomiso2avc1mp41
ENCODER : Lavf58.27.103
Duration: 00:00:24.26, start: -0.007000, bitrate: 1730 kb/s
Stream #0:0: Video: vp9 (Profile 0), yuv420p(tv), 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn (default)
Metadata:
HANDLER_NAME : VideoHandler
ENCODER : Lavc58.52.101 libvpx-vp9
DURATION : 00:00:24.207000000
Stream #0:1: Audio: opus, 48000 Hz, stereo, fltp (default)
Metadata:
HANDLER_NAME : SoundHandler
ENCODER : Lavc58.52.101 libopus
DURATION : 00:00:24.257000000
Codec AVOption block_size (set the block size) specified for output file #0 (C:\Users\26591\Videos\0801f452a88bdf167b0f308c4cd6e7d9.amv) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Stream mapping:
Stream #0:0 -> #0:0 (vp9 (native) -> amv (native))
Press [q] to stop, [?] for help
[swscaler @ 000001c2d0810000] [swscaler @ 000001c2d081cfc0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000001c2d0810000] [swscaler @ 000001c2d083e840] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000001c2d0810000] [swscaler @ 000001c2d086c0c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000001c2d0831e40] [swscaler @ 000001c2d083ee40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000001c2d0831e40] [swscaler @ 000001c2d08600c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000001c2d0831e40] [swscaler @ 000001c2d0810000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000001c2d0831e40] [swscaler @ 000001c2d083ee40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000001c2d0831e40] [swscaler @ 000001c2d0810000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000001c2d0831e40] [swscaler @ 000001c2d08680c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000001c2d0831e40] [swscaler @ 000001c2d083ee40] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000001c2d0831e40] [swscaler @ 000001c2d08600c0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000001c2d0831e40] [swscaler @ 000001c2d0810000] deprecated pixel format used, make sure you did set range correctly
[amv @ 000001c2d06ac840] AMV files only support 2 streams
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Conversion failed!
我也尝试将 WebM 文件转换为 MPEG4 文件,但除了 swscaler 的警告变少之外,什么也没有任何变化(这是我的转换文件
https://drive.google.com/file/d/1C59-mA8glObl4eyvf8vD2jj8lqAhEQla/view?usp=sharing
https://drive.google.com/file/d/1SlM-eHv5RNZV8DtkI9lSG15IwbS3DQfr/view?usp=sharing
:)