FFmpeg错误:ratecontrol_init:无法打开stats文件

时间:2015-12-17 23:08:05

标签: video ffmpeg

我已经设置了一个运行Ubuntu 14.04的AWS EC2实例并安装了FFmpeg,以便我可以压缩和转码视频。

我正在尝试使用以下代码进行双向转换:

ffmpeg -i input-file.avi -codec:v libx264 -profile:v high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=702:-1 -threads 0 -pass 1 -an -f mp4 ~/encoded/null

和第二遍:

ffmpeg -i input-file.avi -codec:v libx264 -profile:v high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=702:-1 -threads 0 -pass 2 -codec:a libfdk_aac -b:a 128k -f mp4 output-file.mp4

但是我收到以下错误:

ffmpeg version N-77283-g91c2a33 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
  configuration: --prefix=/home/ubuntu/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/ubuntu/ffmpeg_build/include --extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --bindir=/home/ubuntu/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree
  libavutil      55. 11.100 / 55. 11.100
  libavcodec     57. 17.100 / 57. 17.100
  libavformat    57. 20.100 / 57. 20.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 21.100 /  6. 21.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, avi, from 'input-file.avi':
  Duration: 01:18:05.29, start: 0.000000, bitrate: 2025 kb/s
    Stream #0:0: Video: mpeg4 (Simple Profile) (XVID / 0x44495658), yuv420p, 720x480 [SAR 1:1 DAR 3:2], 1789 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 224 kb/s
[libx264 @ 0x1e04240] using SAR=1/1
[libx264 @ 0x1e04240] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x1e04240] ratecontrol_init: can't open stats file
Output #0, mp4, to '/home/ubuntu/encoded/null':
    Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, SAR 1:1 DAR 0:0, 29.97 fps
    Metadata:
      encoder         : Lavc57.17.100 libx264
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

上面编写的命令在我的本地计算机上运行(运行OSX)。有人会对如何解决这个问题有任何建议吗?

3 个答案:

答案 0 :(得分:5)

猜测:

传递1添加:

 -vcodec libx264 -strict -2 -passlogfile /tmp/mydummy

传递2添加:

 -vcodec libx264 -strict -2 -passlogfile /tmp/mydummy

答案 1 :(得分:0)

有人在尝试某事时留下了建议,然后立即将其删除。我不知道为什么,但幸运的是,我的建议解决了这个问题。

我在每次传递中的视频编解码器规范之后添加了-strict -2 -passlogfile ~/encoded/log

我成功运行的命令是:

ffmpeg -i input-file.avi -codec:v libx264 -strict -2 -passlogfile ~/encoded/log -profile:v high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=702:-1 -threads 0 -pass 1 -an -f mp4 ~/encoded/null && ffmpeg -i input-file.avi -codec:v libx264 -strict -2 -passlogfile ~/encoded/log -profile:v high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=702:-1 -threads 0 -pass 2 -codec:a libfdk_aac -b:a 128k -f mp4 ~/encoded/output-file.mp4

我不确定是谁留下了这个建议然后将其删除了,但谢谢!

答案 2 :(得分:0)

易于操作的脚本。 通过调整一些参数来完成90%的工作......

#!/bin/bash
# 0
# 4x3  based on 704x576 -->  766x576
# 4x3  based on 720x576 -->  780x576
# 16x9 based on 720x576 --> 1024x576
# 16x9 based on 720x480 -->  854x480     56 marge on 2.21:9 480 --> 368
# 854x480  (60 60 nmarge)
# 1
# rescale values of original as projected on scaled version   1280->1024  means 0,8 of the original value in source is new target
# or, conversely, put the scale before the delogo....?
# 2
# https://trac.ffmpeg.org/wiki/How%20to%20use%20-map%20option  MAP streams...
# 3
# reminder of DVD input DVDIN='concat:./VIDEO_TS/VTS_01_1.VOB|./VIDEO_TS/VTS_01_2.VOB|./VIDEO_TS/VTS_01_3.VOB'

# program to be used, in this case, newer statically linked version
# ffmpeg version 2.3.3-   http://johnvansickle.com/ffmpeg/    Copyright (c) 2000-2014 the FFmpeg developers

# ffmpeg=/opt/ffmpeg/ffmpeg
ffmpeg=ffmpeg

DEINT="yadif=0:0:0,"
#CROP="crop=iw-0-0:ih-140-140:0:140,"
#SHARP=",unsharp=4:4:1.2:4:4:0.2"
DELOGO=",delogo=x=1100:y=680:w=120:h=120"
#VOLUME="-vol 128 -af volume=8dB "
#COLOR=" -vf eq=gamma=1.6:saturation=1.6 "
STRICT=" -strict -2 " 

SCALE="scale=1280:720"
FRATE="25.0"
VFRATE="25.00"
BRATE="7500"
COMAND=" -crf $FRATE -b:v "$BRATE"k -qmin 0 -qmax 54 -vcodec libx264 -c:v libx264 -r $VFRATE -i_qfactor 0.71  -vf $DEINT$CROP$SCALE$SHARP$DELOGO $COLOR $VOLUME -ar 48000 -b:a 192k -ac 2 -codec:a libfdk_aac "
#COMAND=" -crf $FRATE -b:v "$BRATE"k -qmin 0 -qmax 54 -vcodec libx264 -c:v libx264 -r $VFRATE -i_qfactor 0.71  -vf $DEINT$CROP$SCALE$COLOR$SHARP$DELOGO $VOLUME -ar 48000 -b:a 192k -ac 2 -acodec ac3 -codec:a:1 ac3 "


# filename can be links. No spaces allowed.
numshows=( "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" )
shows=( "imran.mkv" )


# HERE, Replace show[1] with $2 if commandline is to override the given array

total=${#shows[*]}
#shows[0]=$DVDIN

for (( i=0; i<=$(( $total -1 )); i++ ))
do
  SHOW="${shows[$i]}"
  NUMSHOW="${numshows[$i]}"
  echo ">>>>>>"$NUMSHOW"-+-+-+-+-+->"$SHOW

  #INFILE=$1/$2
  INFILE=$SHOW
  SHOW="OUTFILE-"$NUMSHOW
  VIDOUT=CVT-$SHOW.mp4
  echo START CODING 
  echo $VIDOUT
  echo .
  echo .
  echo .
  echo .
  echo .
  echo .
  echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  echo $COMAND --- $VIDOUT
  echo .
  echo .
  echo   $ffmpeg -threads 20  -y -i $INFILE  $COMAND $STRICT -passlogfile "/home/fnaaijkens/Videos/_TMP"$SHOW".log" -pass 1  "/home/fnaaijkens/Videos/_TMP-$VIDOUT"
  $ffmpeg -threads 16  -y -i $INFILE  $COMAND -passlogfile "/home/fnaaijkens/Videos/_TMP"$SHOW".log" -pass 1  "/home/fnaaijkens/Videos/_TMP-$VIDOUT"
  echo ------------------------------------------------------------------------------------------------------------------------------------------------------------
  echo ------------------------------------------------------------------------------------------------------------------------------------------------------------
  $ffmpeg -threads 16  -y -i $INFILE  $COMAND $STRICT -passlogfile "/home/fnaaijkens/Videos/_TMP"$SHOW".log" -pass 2  "/home/fnaaijkens/Videos/$VIDOUT"
  rm /home/fnaaijkens/Videos/_TMP*
#   mkvmerge -o $VIDOUT $SHOW -s 0 --language 0:nl *S03E$NUMSHOW*.srt --title $SHOW
done