I'm using ffmpeg version 1.2.4 in my local Rails app to convert video files. Everything works as expected when I run the app locally. When I deployed to heroku, I added a buildpack for ffmpeg:
https://github.com/shunjikonishi/heroku-buildpack-ffmpeg
This installs ffmpeg version git-2013-06-02-5711e4f. When I try to transcode a video to mp4, I get the following error:
Unrecognized option 'preset'. Error splitting the argument list: Option not found
Here is the complete log:
2013-11-17T19:45:05.255059+00:00 app[web.1]: Running transcoding...
2013-11-17T19:45:05.255059+00:00 app[web.1]: ffmpeg -y -i /app/public/uploads/tmp/1384717504-2-9158/Untitled.mov -vcodec libx264 -acodec libfaac -s 640x360 -qscale 0 -preset slow -g 30 -aspect 1.7777777777777777 /app/public/uploads/tmp/1384717504-2-9158/tmpfile.mp4
2013-11-17T19:45:05.255059+00:00 app[web.1]:
2013-11-17T19:45:05.317895+00:00 app[web.1]: Failed encoding...
2013-11-17T19:45:05.317895+00:00 app[web.1]: ffmpeg -y -i /app/public/uploads/tmp/1384717504-2-9158/Untitled.mov -vcodec libx264 -acodec libfaac -s 640x360 -qscale 0 -preset slow -g 30 -aspect 1.7777777777777777 /app/public/uploads/tmp/1384717504-2-9158/tmpfile.mp4
2013-11-17T19:45:05.317895+00:00 app[web.1]:
2013-11-17T19:45:05.317895+00:00 app[web.1]: ffmpeg version git-2013-06-02-5711e4f Copyright (c) 2000-2013 the FFmpeg developers
2013-11-17T19:45:05.317895+00:00 app[web.1]: built on Jun 2 2013 07:38:40 with gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
2013-11-17T19:45:05.317895+00:00 app[web.1]: configuration: --enable-shared --disable-asm --prefix=/app/vendor/ffmpeg
2013-11-17T19:45:05.317895+00:00 app[web.1]: libavutil 52. 34.100 / 52. 34.100
2013-11-17T19:45:05.317895+00:00 app[web.1]: libavcodec 55. 13.100 / 55. 13.100
2013-11-17T19:45:05.317895+00:00 app[web.1]: libavformat 55. 8.102 / 55. 8.102
2013-11-17T19:45:05.317895+00:00 app[web.1]: libavdevice 55. 2.100 / 55. 2.100
2013-11-17T19:45:05.318137+00:00 app[web.1]: libavfilter 3. 74.101 / 3. 74.101
2013-11-17T19:45:05.318137+00:00 app[web.1]: libswscale 2. 3.100 / 2. 3.100
2013-11-17T19:45:05.318137+00:00 app[web.1]: libswresample 0. 17.102 / 0. 17.102
2013-11-17T19:45:05.318137+00:00 app[web.1]: Unrecognized option 'preset'.
2013-11-17T19:45:05.318137+00:00 app[web.1]: Error splitting the argument list: Option not found
2013-11-17T19:45:05.318137+00:00 app[web.1]:
2013-11-17T19:45:05.318137+00:00 app[web.1]: Errors: no output file created.
I think that the error may be a result of differences in the version of ffmpeg that I'm using locally and on Heroku. Does anyone have suggestions for how to resolve this issue?
You're trying to use the encoders libfaac and libx264, but your ffmpeg was not compiled to support these encoders. libfaac requires ffmpeg configure options --enable-nonfree --enable-libfaac
and libx264 requires --enable-gpl --enable-libx264
. Using --disable-asm
is not recommended and can significantly affect encoding time.
If you need help compiling see How to Compile FFmpeg on Ubuntu. Compilation is recommended because the so-called "ffmpeg" package in the repository is a fake, old, buggy, and outdated version from a fork and it does not supply a good AAC encoder.
As for the ffmpeg command options:
-qscale
is ambiguous. You should tell ffmpeg if it should apply to the audio (-qscale:a
or -q:a
) or the video (-qscale:v
or -q:v
) but note that libx264 ignores -qscale
and you should use the default settings or -crf
as shown in the FFmpeg and x264 Encoding Guide.
No need to add -g 30 -aspect 1.7777777777777777
. The default setting for -g
should suffice and I don't see why you want to force a seemingly arbitrary aspect ratio.
Consider using -vf scale=640:-1
instead of explicitly forcing a hard size since this can change the aspect ratio and cause a squished or stretched look. The -1
tells ffmpeg to automatically calculate the value while preserving the aspect ratio.
If you compile ffmpeg, then use -codec:a libfdk_aac
instead of libfaac
. It will provide better quality per bitrate. See the FFmpeg and AAC Encoding Guide for more info.
I'm guessing you are making videos for display on the web. If yes, then add -movflags +faststart
as an output option to allow the client to begin playback before the file is completely downloaded. This is only available with real ffmpeg and not the fake junk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With