ffmpeg h264 problem: "File for preset ... not found" on XP
i have xp and since i'm not familiar with compiling开发者_JS百科 i downloaded win32-static version of ffmpeg, svn-r26251. i want to resize an mp4 (1280x720 originally) video to get a smaller file size with approximately same quality. My command is:
ffmpeg -i ma.mp4 -vcodec libx264 -vpre hq -s 640x360 ma2.mp4
however it says "file for preset 'hq' not found". i tried -fpre, made no difference. without libx264, the resulting file, ma2.mp4, won't play in jwplayer, you just hear audio. (the reason is that it is not "mpeg4(h264)", it is just "mpeg4"). what should i do?
For x264 preset, instead of using "-vpre", the new builds will work with "-preset", as this will call the x264 preset directly.
This problem seems to be related to XP, it works on Win2K. I checked with filemon and it shows that it's looking in X:\usr\local\share\ffmpeg for files libx264-veryslow.ffpreset or veryslow.ffpreset - where X is the drive you are running ffmpeg from. I created the path on the drive, copied all presets in and now it works!
ffmpeg says that it cannot find your preset file, hq.ffpreset
in your case. more info in ffmpeg docs
[EDIT] presets are just for convenience. if you have hq.ffpreset
file so just take everything from it and put in command line directly
ffmpeg project has been renamed to avconv and so the directory names have changed to reflect this. The documentation states:
First ffmpeg searches for a file named arg.ffpreset in the directories ‘$FFMPEG_DATADIR’ (if set), and ‘$HOME/.ffmpeg’, and in the datadir defined at configuration time (usually ‘PREFIX/share/ffmpeg’) or in a ‘ffpresets’ folder along the executable on win32, in that order. For example, if the argument is libx264-max, it will search for the file ‘libx264-max.ffpreset’.
This means it will now look into $HOME/.avconv
and also PREFIX/share/avconv
which is normally /usr/share/avconv
.
Presented here are two solutions for Windows users to help FFmpeg find its x264 presets folder. Accompanying each solution is a batch file to automate the solution in its entirety.
Use only one of these solutions.
The first solution is easiest, but you will have to repeat it across every drive you wish to use FFmpeg on. If you do not wish to do that, use the second solution. It is a bit more complicated, but the batch file makes the process painless.
Again, do not use both solutions. I strongly favour Solution 2.
SOLUTION 1
FFmpeg looks for x264 presets in C:\usr\local\share\ffmpeg
, a directory which needs to be created in Windows:
- Create a folder
C:\usr\local\share\ffmpeg
- Copy all of your preset files from
~ffmpeg\presets
into the new folder.
Or run the following as a batch file:
::BEGIN SOLUTION 1 BATCH FILE
md C:\usr\local\share\ffmpeg
copy "C:\Program Files (x86)\ffmpeg\presets" C:\usr\local\share\ffmpeg
::END SOLUTION 1 BATCH FILE
Before you run this batch file be sure to change C:\Program Files (x86)\ffmpeg\presets
to the current location of your ~\ffmpeg\presets
folder.
SOLUTION 2
FFmpeg looks for x264 presets in %HOME%\.ffmpeg
, an environment which needs to be created in Windows:
First, create two folders:
- Create the folder
HOME
(in this example, I will locate it atC:\Users\your_user_name\HOME
}; - Within the folder
HOME
create another new folder named.ffmpeg
(note the period at the beginning of the filename); - Copy all of the preset files from the folder
~\ffmpeg\presets
into the new folderC:\Users\your_user_name\HOME\.ffmpeg
- Remember to change
your_user_name
to your actual username
Then establish the folder HOME
as an environment variable %HOME%
:
- Open an explorer window;
- Navigate to
Control Panel\System and Security\System
; - Select
Advanced system settings
(left side of window); - Select
Environment Variables
(button near bottom); - Select
New...
(under System Variables to make presets available to all users); - In
Variable name:
enterHOME
- In
Variable value:
enterC:\Users\your_user_name\HOME
- Remember to change
your_user_name
to your actual username
Or run the following as a batch file:
::BEGIN SOLUTION 2 BATCH FILE
md %userprofile%\HOME
md %userprofile%\HOME\.ffmpeg
copy "C:\Program Files (x86)\ffmpeg\presets" %userprofile%\HOME\.ffmpeg
setx HOME %userprofile%\HOME\ /m
::END SOLUTION 2 BATCH FILE
Before you run this batch file be sure to change C:\Program Files (x86)\ffmpeg\presets
to the current location of your ~\ffmpeg\presets
folder.
Since you are running windows, unless you change your %HOME% variable, you will need to type the full path to "hq.ffpreset". It may be named "libx264-hq.ffpreset" instead. Also, this may or may not apply, but make sure that your build was made with libx264 support. If I knew if I was allowed to, I would link to my personal ffmpeg 1.2 shared build for win32. I can confirm that this command works with this version.
If you do not have the HQ preset file at all, I found a link to a version of it here: https://raw.github.com/joeyblake/FFmpeg-Presets/master/libx264-hq.ffpreset
Put this wherever you want (somewhere on %PATH% might work well).
精彩评论