【问题标题】:Encode video for ipod classic为 ipod classic 编码视频
【发布时间】:2014-06-09 06:27:02
【问题描述】:

我刚刚使用这些说明在 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                           : 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

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

【问题讨论】:

  • 没有问题。随意把它移到那里。

标签: video ffmpeg ipod


【解决方案1】:

您可能需要重新编码,因为根据您提供的specs,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
  • -crf 控制质量,用-preset 控制编码速度。有关这些选项的更多信息,请参阅FFmpeg and x264 Encoding Guide

  • -level 目前没有为这个编码器设置-refs,所以手动设置。有一个待解决的补丁可以解决这个问题,所以应该很快就会修复。

  • 在这种情况下,scale video filter 会将输出缩放为 640x360。 -1 值在高度维度上保持原来的 16:9 纵横比,而 640 值设置新的宽度。

  • pad video filter 指定视频的新最大宽度和高度,以及以像素为单位的侧边距和顶边距。这是将原始 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
    
  • format video filter 将确保输出使用兼容的色度二次采样方案。 ffmpeg 尝试在使用 libx264 时默认避免或最小化色度二次采样,但基于非 FFmpeg 的播放器和设备不支持除 yuv420p 以外的任何内容,因此包含此内容将确保兼容性。这与使用 -pix_fmt yuv420p 相同,您可能会在其他示例中看到,但是使用 format 可以让您具体说明它将在与其他过滤器相关的位置上应用(在这种情况下,它并不是真的很重要) )。

  • 因为音频可能很好,因为它可以是stream copied(重新混合)而不是重新编码。

【讨论】:

    【解决方案2】:

    ffmpeg.exe -i "Video.mp4" -vcodec libx264 -preset fast -profile:v baseline -lossless 1 -vf "scale=720:540,setsar=1,pad=720:540:0:0" -acodec aac -ac 2 -ar 22050 -ab 48k "视频 (SD).mp4"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多