使用FFMPEG转换WebM文件格式


Conversion for WebM file format using FFMPEG

我正在使用以下命令将视频转换为webm格式的

ffmpeg -i video/ds2.mp4 -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b:a 345k -s 640x360 video/ds2.webm

我收到以下错误:

1) 编解码器"libvorbis"的不兼容样本格式"s16"

2) strptime()在此系统上不可用,无法转换数据字符串

你知道为什么我不能转换吗,测试转换为FLV,它运行得很好

控制台输出

C:'inetpub'wwwroot>ffmpeg -i video/testavi.avi video/ds2.webm
ffmpeg version N-35709-g7d531e8, Copyright (c) 2000-2011 the FFmpeg developers
  built on Dec 12 2011 13:56:52 with gcc 4.6.2
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libope
ncore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger -
-enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwben
c --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
  libavutil    51. 32. 0 / 51. 32. 0
  libavcodec   53. 43. 0 / 53. 43. 0
  libavformat  53. 24. 0 / 53. 24. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 53. 0 /  2. 53. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, avi, from 'video/testavi.avi':
  Metadata:
    encoder         : Lavf51.12.1
  Duration: 00:00:13.03, start: 0.000000, bitrate: 36427 kb/s
    Stream #0:0: Video: msmpeg4 (MP43 / 0x3334504D), yuv420p, 1920x1080, 30 tbr,
 30 tbn, 30 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16, 192 kb
/s
File 'video/ds2.webm' already exists. Overwrite ? [y/N] y
w:1920 h:1080 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param:
[libvpx @ 0000000001CA9BB0] v0.9.7-p1
Output #0, webm, to 'video/ds2.webm':
  Metadata:
    encoder         : Lavf53.24.0
    Stream #0:0: Video: vp8, yuv420p, 1920x1080, q=-1--1, 200 kb/s, 1k tbn, 30 t
bc
    Stream #0:1: Audio: vorbis, 44100 Hz, stereo, s16, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (msmpeg4 -> libvpx)
  Stream #0:1 -> #0:1 (mp3 -> libvorbis)
Press [q] to stop, [?] for help

Problem signature:
  Problem Event Name:   APPCRASH
  Application Name: ffmpeg.exe
  Application Version:  0.0.0.0
  Application Timestamp:    4ee64f02
  Fault Module Name:    ffmpeg.exe
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp:   4ee64f02
  Exception Code:   c0000005
  Exception Offset: 000000000091e090
  OS Version:   6.1.7601.2.1.0.272.7
  Locale ID:    1033
  Additional Information 1: ab8f
  Additional Information 2: ab8f35a907f8f11a8d2e787a8e40efbd
  Additional Information 3: f4d5
  Additional Information 4: f4d524f8bf76a4b71cc6a7afa6412ca9
Read our privacy statement online:
  http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
If the online privacy statement is not available, please read our privacy statement offline:
  C:'Windows'system32'en-US'erofflps.txt

和控制台未切割输出

C:'inetpub'wwwroot>ffmpeg.exe -i "video/testavi.avi" -acodec libvorbis -b:a 96k
-ac 2 -vcodec libvpx -b:v 400k -f webm -s 384x216 "video/testavi.webm"
ffmpeg version N-35709-g7d531e8, Copyright (c) 2000-2011 the FFmpeg developers
  built on Dec 12 2011 13:56:52 with gcc 4.6.2
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libope
ncore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger -
-enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwben
c --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
  libavutil    51. 32. 0 / 51. 32. 0
  libavcodec   53. 43. 0 / 53. 43. 0
  libavformat  53. 24. 0 / 53. 24. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 53. 0 /  2. 53. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, avi, from 'video/testavi.avi':
  Metadata:
    encoder         : Lavf51.12.1
  Duration: 00:00:13.03, start: 0.000000, bitrate: 36427 kb/s
    Stream #0:0: Video: msmpeg4 (MP43 / 0x3334504D), yuv420p, 1920x1080, 30 tbr,
 30 tbn, 30 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16, 192 kb
/s
[buffer @ 0000000001D7FF60] w:1920 h:1080 pixfmt:yuv420p tb:1/1000000 sar:0/1 sw
s_param:
[scale @ 0000000001D7E9E0] w:1920 h:1080 fmt:yuv420p -> w:384 h:216 fmt:yuv420p
flags:0x4
[libvpx @ 0000000001BF7C10] v0.9.7-p1
Output #0, webm, to 'video/testavi.webm':
  Metadata:
    encoder         : Lavf53.24.0
    Stream #0:0: Video: vp8, yuv420p, 384x216, q=-1--1, 400 kb/s, 1k tbn, 30 tbc
    Stream #0:1: Audio: vorbis, 44100 Hz, 2 channels, s16, 96 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (msmpeg4 -> libvpx)
  Stream #0:1 -> #0:1 (mp3 -> libvorbis)
Press [q] to stop, [?] for help

您发布的命令有效。你发布的两条消息是警告,而不是致命错误。

顺便说一句,我用这个命令来创建WebM视频:

ffmpeg.exe -i "blank.mp4" -acodec libvorbis -b:a 96k -ac 2 -vcodec libvpx -b:v 400k -f webm -s 384x216 "blank.webm"

如果您对其他web格式感兴趣,这可能会很有用。我的ffmpegVideoWebify脚本的精简版本

echo '| ./ffmpegVideoWebify <input> <output> <webroot>' ;
I=$1 ;
dir=$2 ;
id=${dir##*/} ; #https://www.baeldung.com/linux/last-directory-file-from-webPath=$3
#https://www.webmproject.org/docs/encoder-parameters/
webmCRF=10 # THis is a recomended value lower is larger and better quality
mp4CRF=16 # 16 is approximately the same as webm 10 i heard 23 recommended be perfer a bit better quality
mkdir -p $dir ;
mkdir $dir/seek
$outMP4="-c:v libx264 -c:a aac -b:a 160k -crf $mp4CRF -movflags faststart "
$outWEBM="-c:v libvpx -crf $webmCRF -b:v 1M -c:a libvorbis"
$outMPEG1="-vcodec mpeg1video -acodec mp2"
$outOGG="-codec:video libtheora -acodec libvorbis"
$outAVI="-c:v mpeg4 -vtag xvid" #mpeg4
# Look a wall of ffmpeg
# But wait its not so bad its just
# something a loop could of done
# but this is simple an you can copy paste it
# If is wasent for this pesky comment ;)
time ffmpeg -i "$I" $outMP4 "$dir/orig.mp4"'
 $outMP4 -vf scale=-2:720 "$dir/720.mp4"'
 $outMP4 -vf scale=-2:480 "$dir/360.mp4"'
 $outMP4 -vf scale=-2:480 "$dir/480.ogg"'
 $outWEBM "$dir/orig.webm"'
 $outWEBM -vf scale=-2:720 "$dir/720.webm"'
 $outWEBM -vf scale=-2:480 "$dir/480.webm"'
 $outWEBM -vf scale=-2:240 "$dir/240.webm"
# make thumbnails i recommend thumb720.jpg
ffmpeg "$I" -frames:v 1 $dir/thumb.png ;
ffmpeg "$I" -frames:v 1 $dir/thumb.jpg ;
ffmpeg "$I" -frames:v 1 -vf scale=-2:720 $dir/thumb720.jpg ;
ffmpeg "$I" -frames:v 1 -vf scale=-2:480 $dir/thumb480.jpg ;
#make seek res
time ffmpeg -i "$dir/240.webm" -vf fps=1 $dir/seek/sec_%d.jpg ;# use %04d for leading 0s
# $outMPEG1 -vf scale=-2:360 "$dir/360.mpeg"