我刚刚按照以下说明在[debian wheezy]上安装了ffmpeg
-http://trac.ffmpeg.org/wiki/UbuntuCompilationGuide。现在,我想对视频进行编码以在iPod classic上播放。该视频具有以下信息:
$ mediainfo in.mp4
General
Complete name : in.mp4
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42
File size : 1.21 GiB
Duration : 55mn 10s
Overall bit rate mode : Variable
Overall bit rate : 3 130 Kbps
Encoded date : UTC 2010-08-25 23:38:59
Tagged date : UTC 2010-08-25 23:38:59
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings, CABAC : Yes
Format settings, ReFrames : 2 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 55mn 10s
Bit rate mode : Variable
Bit rate : 3 000 Kbps
Maximum bit rate : 5 000 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Standard : NTSC
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.109
Stream size : 1.16 GiB (96%)
Language : English
Encoded date : UTC 2010-07-21 13:28:49
Tagged date : UTC 2010-07-21 13:28:49
Color primaries : BT.709-5, BT.1361, IEC 61966-2-4, SMPTE RP177
Transfer characteristics : BT.709-5, BT.1361
Matrix coefficients : BT.709-5, BT.1361, IEC 61966-2-4 709, SMPTE RP177
Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 55mn 10s
Bit rate mode : Variable
Bit rate : 125 Kbps
Maximum bit rate : 270 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 44.1 KHz
Compression mode : Lossy
Stream size : 49.4 MiB (4%)
Language : English
Encoded date : UTC 2010-07-21 13:28:49
Tagged date : UTC 2010-07-21 13:28:49
mdhd_Duration : 3310353
我已经尝试过使用banshee
将视频复制到iPod,但是视频仅显示黑屏。在iPod上播放视频的最佳格式是什么?我应该使用什么ffmpeg参数?我想最大化分辨率,同时最小化文件大小。
您可能需要重新编码,因为根据您提供的specs,iPod Classic可以处理高达640x480的视频,但是您的视频为1280x720。视频可以是H.264,基准配置文件,3.0级:
ffmpeg -i in.mp4 -vcodec libx264 -crf 23 -preset fast -profile:v baseline \
-level 3 -refs 6 -vf "scale=640:-1,pad=iw:480:0:(oh-ih)/2,format=yuv420p" \
-acodec copy output.mp4
-crf
的控制质量和-preset
的编码速度。有关这些选项的更多信息,请参见FFmpeg and x264 Encoding Guide。
-level
当前未为此编码器设置-refs
,因此请手动进行设置。有一个待解决的补丁程序可以解决此问题,因此应尽快修复。
scale
video filter在这种情况下会将输出缩放为640x360。 scale
值在高度尺寸上保持原始的16:9长宽比,而-1
值设置新的宽度。
640
指定新的视频最大宽度和高度,以及像素的边距和顶部距。要将原始的16:9视频放到iPod classic所需的4:3高宽比中,这很有必要。如果不这样做,则iPod将扩展视频以适合屏幕高度,并在播放过程中裁切掉视频的侧面。要为此参数计算必要的值,请考虑:
pad
video filter
pad
将确保输出使用兼容的色度二次采样方案。 1280*x = 640 # x is the resize factor in the width dimension
x = 640/1280 = 0.5 # now we know x
720*x + 2*p = 480 # scaling the original video height by x, then adding
# equal padding p above and below the video must give the new desired
# video height of 480. solve for p
360 + 2*p = 480
p = 60
在尝试使用libx264时默认情况下会尝试避免或最小化色度二次采样,但是基于非FFmpeg的播放器和设备不支持yuv420p以外的任何其他功能,因此包括在内将确保兼容性。这与在其他示例中看到的使用format
video filter相同,但是使用format
可以让您具体说明将其应用于其他过滤器的情况(在这种情况下,它并不是很重要) )。
由于音频可能很好,可以将其ffmpeg
(重新混合)而不是重新编码。
ffmpeg.exe -i“ in.mp4” -vcodec libx264 -crf 23-预设快速-profile:v基线-级别3 -refs 6 -vf“ subtitles ='in.srt:force_style = Fontsize = 24,PrimaryColour = &Hffffff&'“,scale = 720:576,pad = 720:576:0:0,format = yuv420p -acodec aac -ac 2 -ar 44.1k -b:a 256k” out-PAL.mp4“