I am seeing this error on Heroku in a ruby on rails 6.0.2
app.
JSON::ParserError: 767: unexpected token at '' (Most recent call first)
which is occuring at line 9 of app/bin/rake
.
4 rescue LoadError => e
5 raise unless e.message.include?('spring')
6 end
7 require_relative '../config/boot'
8 require 'rake'
9 Rake.application.run
The traceback shows it is happening in the active_storage
video_analyzer.rb file:
/app/vendor/ruby-2.6.5/lib/ruby/2.6.0/json/common.rb line 156 in parse
File /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/json/common.rb line 156 in parse
File /app/vendor/bundle/ruby/2.6.0/gems/activestorage-6.0.2/lib/active_storage/analyzer/video_analyzer.rb line 107 in block in probe_from
And the video_analyzer is being called ultimately by delayed_job
. The app is uploading videos, but I am seeing no problems in either the upload or viewing of the videos. So what is causing this exception? I only started seeing the problem after upgrading from rails 5
to rails 6
.
Although I had included the ffmpeg
gem, on heroku I still needed to install the ffmpeg
binaries on heroku. I tried this buildpack with the following commands:
heroku buildpacks:add --index 1 https://github.com/laddhadhiraj/heroku-buildpack-ffmpeg
heroku config:set FFMPEG_BIN_URL="http://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz"
However, the FFMPEG_BIN_URL
was out of date. Nevertheless, the buildpack installs ffmpeg
and ffprobe
. It can be seen from the error message, that the problem is caused by the lack of ffprobe
, so this seems to have fixed the error message. It not clear that activestorage functionality is working completely with ffmpeg
as the following methods have not been installed, ffserver, ffmpeg-10bit, qt-faststart
If anyone knows of a more up-to-date buildpack, please post an answer or comment.