Open usmanarif opened 9 years ago
can you please take your mp4
file and run command from your command line (terminal) directly
ffmpeg -i your_mp4.path.mp4 -s 640x480 -y out.flv
and write down output
@attenzione I also too had this issue. So given your instructions above I tried your above instructions:
Prerequisite: I executed this command in the same directory as where the video was located.
ffmpeg version 2.6.3 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libass --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1_1/include/openjpeg-1.5 ' --enable-nonfree --enable-vda
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20141019_175323.mp4':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: isom3gp4
creation_time : 2014-10-19 22:53:51
Duration: 00:00:10.35, start: 0.000000, bitrate: 898 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 320x240, 769 kb/s, 30.03 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2014-10-19 22:53:51
handler_name : VideoHandle
encoder :
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 123 kb/s (default)
Metadata:
creation_time : 2014-10-19 22:53:51
handler_name : SoundHandle
[flv @ 0x7f9f6b83f000] FLV does not support sample rate 48000, choose from (44100, 22050, 11025)
[flv @ 0x7f9f6b83f000] Audio codec mp3 not compatible with flv
Output #0, flv, to 'exmaple.flv':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: isom3gp4
encoder : Lavf56.25.101
Stream #0:0(eng): Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 640x480, q=2-31, 200 kb/s, 30 fps, 1k tbn, 30 tbc (default)
Metadata:
creation_time : 2014-10-19 22:53:51
handler_name : VideoHandle
encoder : Lavc56.26.100 flv
Stream #0:1(eng): Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 48000 Hz, stereo, fltp (default)
Metadata:
creation_time : 2014-10-19 22:53:51
handler_name : SoundHandle
encoder : Lavc56.26.100 libmp3lame
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> flv1 (flv))
Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Could not write header for output file #0 (incorrect codec parameters ?): Function not implemented
@attenzione Interestingly though I was able to overcome the above error by commenting out in my model: :medium => { :geometry => "150x85#", :format => 'flv' }
. For some particular reason having that line included in the model a per the readme causes an error. FYI this is the version of the gems that I have in my Gemfile.lock
av (0.9.0)
cocaine (~> 0.5.3)
paperclip-av-transcoder (0.6.4)
av (~> 0.9.0)
paperclip (>= 2.5.2)
Although as mentioned once I try to upload another video I encounter:
error while running command if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi: Command 'PATH=/usr/bin:$PATH if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi' returned 2. Expected 0
Here is the command output
The above error touches base with #16 also. I too am running Paperclip 4.2.1
@davidpatters0n seems, ffmpeg flv1 library is broken?
@attenzione I see and there is no way around this issue?
Try to reinstall, recompile ffmpeg or try to use avconv
@attenzione I uninstalled the av
gem and reinstalled it. what do you mean by recompile ffmmpeg? And what do you mean by try and use avconv? Just need clarity. Thanks
this gem uses external application - ffmpeg or avconv, you need to reinstall it, not gem
On Fri, Jun 26, 2015, 20:55 David Patterson notifications@github.com wrote:
@attenzione https://github.com/attenzione I uninstalled the av gem and reinstalled it. what do you mean by recompile ffmmpeg? And what do you mean by try and use avconv? Just need clarity. Thanks
— Reply to this email directly or view it on GitHub https://github.com/ruby-av/paperclip-av-transcoder/issues/14#issuecomment-115813169 .
@attenzione so I decided to uinstall ffmpeg and install avconv. Having installed avconv i was able to run the avconv command via my terminal: avconv -i some_file.mp4 output.mp4
and this seemed to work. So I know for a fact that aconv is working. However now that installed avconv and try to use paperclip-av-transcoder
with the following setup in my model:
has_attached_file :video, :styles => {
#:medium => { :geometry => "150x85#", :format => 'flv' },
:thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }
}, :processors => [:transcoder]
Interestingly when i submit my form the first time it uploads the video fine. If i attempt to upload the video again it fails.
Stacktrace:
First Attempt (Success)
User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1
[AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Found ["avconv"], using: Avconv
[AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Found ["avconv"], using: Avconv
[AV] Running command: avconv -i "/var/folders/t3/4rh89rh53255d2bhjbndqxbw0000gn/T/8a945976d160f21f23e41d6e69deb98b20150626-40568-s1t09i.mp4" 2>&1
[paperclip] [transcoder] Transocding supported file /var/folders/t3/4rh89rh53255d2bhjbndqxbw0000gn/T/8a945976d160f21f23e41d6e69deb98b20150626-40568-s1t09i.mp4
[AV] Adding output parameter ["f", "image2"]
[AV] Adding output parameter ["vframes", "1"]
[AV] Adding input parameter [:ss, 10]
[AV] Adding output parameter [:s, "100x100"]
[AV] Running command: avconv -loglevel quiet -ss 10 -i "/var/folders/t3/4rh89rh53255d2bhjbndqxbw0000gn/T/8a945976d160f21f23e41d6e69deb98b20150626-40568-s1t09i.mp4" -f image2 -vframes 1 -s 100x100 -y "/var/folders/t3/4rh89rh53255d2bhjbndqxbw0000gn/T/8a945976d160f21f23e41d6e69deb98b20150626-40568-s1t09i20150626-40568-1t68ctj.jpg"
[paperclip] [transcoder] Successfully transcoded 8a945976d160f21f23e41d6e69deb98b20150626-40568-s1t09i to #<File:0x007ff0d19c3cd0>
Command :: PATH=/usr/bin:$PATH file -b --mime '/var/folders/t3/4rh89rh53255d2bhjbndqxbw0000gn/T/8a945976d160f21f23e41d6e69deb98b20150626-40568-s1t09i20150626-40568-1t68ctj.jpg'
(0.2ms) BEGIN
Challenge Exists (0.3ms) SEL
Second Attempt (Fails)
[AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
sh: -c: line 0: syntax error near unexpected token `then'
sh: -c: line 0: `PATH=/usr/bin:$PATH if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi'
Completed 500 Internal Server Error in 41ms
Av::CommandError - error while running command if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi: Command 'PATH=/usr/bin:$PATH if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi' returned 2. Expected 0
Here is the command output:
:
av (0.9.0) lib/av.rb:32:in `rescue in run'
av (0.9.0) lib/av.rb:29:in `run'
av (0.9.0) lib/av/cli.rb:24:in `detect_command'
av (0.9.0) lib/av/cli.rb:7:in `initialize'
av (0.9.0) lib/av.rb:24:in `cli'
Fyi my error now is similar to #16
I now have this working https://github.com/ruby-av/paperclip-av-transcoder/issues/10#issuecomment-115842644 hopefully it helps others and closes this issue along with #16
I am getting following error while saving the video error while running command ffmpeg -i "/tmp/ed48c144522ed8beaba94863c34b0f9d20150423-3314-3r52bx.mp4" -s 640x480 -y "/tmp/ed48c144522ed8beaba94863c34b0f9d20150423-3314-3r52bx20150423-3314-1ok2yh8.flv": Command 'ffmpeg -i "/tmp/ed48c144522ed8beaba94863c34b0f9d20150423-3314-3r52bx.mp4" -s 640x480 -y "/tmp/ed48c144522ed8beaba94863c34b0f9d20150423-3314-3r52bx20150423-3314-1ok2yh8.flv"' returned 1. Expected 0
Error is in this line while updating: if @worker.update(worker_params)
Following is my code:
Gemfile gem 'paperclip-av-transcoder'
worker.rb has_attached_file :video, :styles => {:medium => { :geometry => "640x480", :format => 'flv' },:thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 } }, :processors => [:transcoder]
workers_controller.rb def update respond_to do |format| if @worker.update(worker_params) format.html { redirect_to @worker, notice: 'Worker was successfully updated.' } format.json { render :show, status: :ok, location: @worker } else format.html { render :edit } format.json { render json: @worker.errors, status: :unprocessable_entity } end end end def worker_params params.require(:worker).permit(:video, :user_id, :profile_photo, :worker_spoken_languages_attributes => [:id, :worker_id, :spoken_language, :_destroy]) end
show.haml %p %strong Video: = video_tag @worker.video.url %p
Please tell if I am missing anything