Sid*_*Sid 18 ruby iphone ffmpeg ruby-on-rails iphone-sdk-3.0
浏览网上的大量文档后,iPhone似乎总是以480x360的宽高比拍摄视频,并在视频轨道上应用变换矩阵.(480x360可能会改变,但对于给定的设备,它总是相同的)
这是一种修改iOS项目中的ffmpeg源并访问矩阵的方法http://www.seqoy.com/correct-orientation-for-iphone-recorded-movies-with-ffmpeg/
以下是在iOS-4中查找转换矩阵的更简洁方法 如果以纵向或横向方式记录视频文件,如何检测(iPhone SDK).
如何在以下任一选项中提取视频的方向
- iOS 3.2
- ffmpeg(通过命令行服务器端)
- ruby
任何帮助将不胜感激.
kri*_*ard 11
由于大多数相机将它们的旋转/方向存储在exif元数据中,我建议使用exifttool并且mini_exiftool主动维护一个称为ruby的包装宝石.
安装exiftool:
apt-get exiftool || brew install exiftool || port install exiftool
或使用包管理器可用的东西
安装mini_exiftool:
gem install mini_exiftool
试试吧:
irb>
require 'mini_exiftool'
movie = MiniExiftool.new('test_movie.mov')
movie.orientation #=> 90
Run Code Online (Sandbox Code Playgroud)
干杯
eno*_*rev 10
从我迄今为止发现的情况来看,ffmpeg无法检测iPhone的方向.但是,开源库,mediainfo可以.命令行示例:
$ mediainfo test.mp4 | grep Rotation
Rotation : 90°
Run Code Online (Sandbox Code Playgroud)
来自同一iphone视频的更多示例输出:
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Baseline@L3.0
Format settings, CABAC : No
Format settings, ReFrames : 1 frame
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 7s 941ms
Bit rate mode : Variable
Bit rate : 724 Kbps
Width : 480 pixels
Height : 360 pixels
Display aspect ratio : 4:3
Rotation : 90°
Frame rate mode : Variable
Frame rate : 29.970 fps
Minimum frame rate : 28.571 fps
Maximum frame rate : 31.579 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.140
Stream size : 702 KiB (91%)
Title : Core Media Video
Encoded date : UTC 2011-06-22 15:58:25
Tagged date : UTC 2011-06-22 15:58:34
Color primaries : BT.601-6 525, BT.1358 525, BT.1700 NTSC, SMPTE 170M
Transfer characteristics : BT.709-5, BT.1361
Matrix coefficients : BT.601-6 525, BT.1358 525, BT.1700 NTSC, SMPTE 170M
Run Code Online (Sandbox Code Playgroud)
你可以用ffprobe.不需要grep任何其他任何其他进程或任何正则表达式操作来解析输出,如其他答案所示.
命令:
ffprobe -loglevel error -select_streams v:0 -show_entries stream_tags=rotate -of default=nw=1:nk=1 input.mp4
Run Code Online (Sandbox Code Playgroud)
示例输出:
90
Run Code Online (Sandbox Code Playgroud)
命令:
ffprobe -loglevel error -select_streams v:0 -show_entries side_data=rotation -of default=nw=1:nk=1 input.mp4
Run Code Online (Sandbox Code Playgroud)
示例输出:
-90
Run Code Online (Sandbox Code Playgroud)
命令:
ffprobe -loglevel error -select_streams v:0 -show_entries side_data=displaymatrix -of default=nw=1:nk=1 input.mp4
Run Code Online (Sandbox Code Playgroud)
示例输出:
00000000: 0 65536 0
00000001: -65536 0 0
00000002: 15728640 0 1073741824
Run Code Online (Sandbox Code Playgroud)
-loglevel error 从输出中省略标题和其他信息.
-select_streams v:0仅处理第一个视频流并忽略其他所有内容.如果您的输入包含多个视频流并且您只想要一个信息,则非常有用.
-show_entries stream_tags=rotate选择rotate从视频流输出标签.
-of default=nw=1:nk=1使用默认输出格式,但省略包括节头/页脚包装和每个字段键.
ffprobe可以通过多种方式格式化输出.例如,JSON:
ffprobe -loglevel error -show_entries stream_tags=rotate -of json input.mp4
{
"streams": [
{
"tags": {
"rotate": "90"
},
"side_data_list": [
{
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16006 次 |
| 最近记录: |