为ipod classic编码视频

mul*_*sen 4 video ffmpeg ipod

我刚刚ffmpeg使用这些说明完成了对debian wheezy的安装- 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                           : High@L3.2
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
Run Code Online (Sandbox Code Playgroud)

我已经尝试过将视频复制到iPod上,banshee但视频只显示黑屏.在Ipod上播放视频的最佳格式是哪种?我应该使用哪些ffmpeg参数?我想在最小化文件大小的同时最大化分辨率.

llo*_*gan 6

您可能需要重新编码,因为根据您提供的规格,iPod Classic可以处理高达640x480 ,但您的视频为1280x720.视频可以是H.264,Baseline Profile,Level 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
Run Code Online (Sandbox Code Playgroud)
  • 控制质量-crf和编码速度-preset.有关这些选项的详细信息,请参阅FFmpeg和x264编码指南.

  • -level目前没有-refs为此编码器设置,因此请手动设置.有一个待解决的补丁来解决这个问题,所以应尽快解决.

  • 在这种情况下,scale视频滤镜会将输出缩放到640x360.该-1值在高度维度中保持原始的16:9宽高比,而640值设置新宽度.

  • pad视频滤波器指定以像素为单位的新的最大宽度和视频的高度,再加上侧填充和顶部填充.这对于将原始16:9视频信箱装入iPod classic所需的4:3宽高比是必要的.如果没有这样做,那么iPod将扩展视频以适应屏幕高度,并在播放期间裁剪掉视频的两侧.要计算此参数的必要值,请考虑:

    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
    
    Run Code Online (Sandbox Code Playgroud)
  • format视频滤波器将确保输出使用兼容的色度抽样方案.ffmpeg在使用libx264时,默认情况下会尝试避免或最小化色度子采样,但非基于FFmpeg的播放器和设备不支持除yuv420p以外的任何其他内容,因此包括这将确保兼容性.这与-pix_fmt yuv420p您在其他示例中看到的使用相同,但使用format允许您具体说明与其他过滤器相关的应用位置(在这种情况下,它实际上并不重要).

  • 由于音频可能很好,因为它可以被流复制(重新复用)而不是重新编码.