ruby-av / av Goto Github PK
View Code? Open in Web Editor NEWProgrammable Ruby interface for FFMPEG/Libav
License: MIT License
Programmable Ruby interface for FFMPEG/Libav
License: MIT License
Hi,
I use paperclip and got errors when upload specific video files,
ArgumentError:
invalid byte sequence in UTF-8
# /Users/emn178/.rvm/gems/ruby-2.2.2/gems/av-0.9.0/lib/av/commands/base.rb:98:in `split'
# /Users/emn178/.rvm/gems/ruby-2.2.2/gems/av-0.9.0/lib/av/commands/base.rb:98:in `identify'
# /Users/emn178/.rvm/gems/ruby-2.2.2/gems/av-0.9.0/lib/av/cli.rb:19:in `method_missing'
# /Users/emn178/.rvm/gems/ruby-2.2.2/gems/paperclip-av-transcoder-0.6.4/lib/paperclip/paperclip_processors/transcoder.rb:15:in `initialize'
...
The command it ran is:
[AV] Running command: ffmpeg -i "/var/folders/9f/sv32jzv53451kysr4v8l6jf40000gn/T/d35f70211135de265bc7c66df4dd360520150905-36894-k4jbwc.mp4" 2>&1
I ran command in terminal manually and got something liket this:
...
Duration: 01:25:18.69, start: 0.000000, bitrate: 236 kb/s
Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 32000 Hz, mono, fltp, 31 kb/s (default)
Metadata:
creation_time : 2015-04-20 22:42:29
handler_name : Apple Ánµ´CÅé³B²z¾¹
...
There are something encoding issues and cause uploading failed.
Please help to fixed this problem.
Thank and best regards.
Avconv video
Av.cli.identify('video.mov')
[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", "ffmpeg"], using: Avconv
[AV] Running command: avconv -i "video.mov" 2>&1
=> {:size=>"1920x1080", :aspect=>1.7777777777777777}
FFmpeg video
Av.cli.identify('video.mov')
[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 ["ffmpeg"], using: Ffmpeg
[AV] Running command: ffmpeg -i "video.mov" 2>&1
=> {:length=>"0:00:26.73", :fps=>60, :size=>"1920x1080", :aspect=>1.7777777777777777}
Avconv audio
Av.cli.identify('audio.mp3')
[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", "ffmpeg"], using: Avconv
[AV] Running command: avconv -i "audio.mp3" 2>&1
=> {:audio_encode=>"mp3", :audio_bitrate=>"44100 Hz", :audio_channels=>"1 channels"}
FFmpeg audio
Av.cli.identify('audio.mp3')
[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 ["ffmpeg"], using: Ffmpeg
[AV] Running command: ffmpeg -i "audio.mp3" 2>&1
=> {:length=>"0:00:02.66", :audio_encode=>"mp3", :audio_bitrate=>"44100 Hz", :audio_channels=>"mono"}
Avconv version
avconv version 11.2, Copyright (c) 2000-2014 the Libav developers
built on Jan 26 2015 11:47:25 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Hyper fast Audio and Video encoder
Hi. I am using ruby-av and paperclip-av-transcoder to process user uploaded video files.
And I was trying to identify size of this video http://www.dvdloc8.com/clip.php?movieid=12167&clipid=3 with
::Av.cli.identify('/home/arman/Downloads/simpsons_movie_1080p_hddvd_trailer/The Simpsons Movie - 1080p Trailer.mp4')
and it returned size as 101x150. Note: I have ffmpeg installed
{
:length => "0:02:17.25",
:duration => 137.25,
:fps => 23,
:size => "101x150",
:width => 101,
:height => 150,
:aspect => 0.6733333333333333,
:audio_encode => "aac (LC) (mp4a / 0x6134706D)",
:audio_bitrate => "44100 Hz",
:audio_channels => "5.1"
}
But the actual size of video is 1920x800. Then i checked video metadata with ffmpeg
ffmpeg -i "/home/arman/Downloads/simpsons_movie_1080p_hddvd_trailer/The Simpsons Movie - 1080p Trailer.mp4" 2>&1
And it returned
ffmpeg version N-83192-gf1214ad Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1)
configuration: --prefix=/home/arman/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/arman/ffmpeg_build/include --extra-ldflags=-L/home/arman/ffmpeg_build/lib --bindir=/home/arman/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
libavutil 55. 44.100 / 55. 44.100
libavcodec 57. 75.100 / 57. 75.100
libavformat 57. 63.100 / 57. 63.100
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 69.100 / 6. 69.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x2e90ec0] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/arman/Downloads/simpsons_movie_1080p_hddvd_trailer/The Simpsons Movie - 1080p Trailer.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
creation_time : 2007-07-17T09:18:37.000000Z
genre : Trailer
artist : Fox
title : The Simpsons Movie
date : 2007
Duration: 00:02:17.25, start: 0.000000, bitrate: 8591 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x800, 8486 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2007-07-17T09:18:37.000000Z
handler_name : GPAC ISO Video Handler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, 5.1, fltp, 107 kb/s (default)
Metadata:
creation_time : 2007-07-17T09:18:45.000000Z
handler_name : GPAC ISO Audio Handler
Stream #0:2: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 101x150 [SAR 72:72 DAR 101:150], 90k tbr, 90k tbn, 90k tbc
So there are two lines which have video size information.
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x800, 8486 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Stream #0:2: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 101x150 [SAR 72:72 DAR 101:150], 90k tbr, 90k tbn, 90k tbc
Now my question is in that case how I will know the actual video size? Should i consider only the first one? Because ::Av.cli.identify is considering the last one as it loops through each lines and first size information gets overwrite by last line
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.