Как я могу конвертировать видео для Sony Xperia U на моем компьютере с Linux?

1089
Konstantin

Я хотел бы отправить несколько видео для моей подруги, но я бы позаботился о том, чтобы их можно было воспроизводить на ее мобильном телефоне. Я хочу выполнить задачи по кодированию на моем компьютере с Linux, потому что мой компьютер является низкоуровневым. Я могу использовать только ffmpeg или mencoder или другой инструмент CLI. Она может воспроизводить видео на YouTube, но я не хочу загружать такие видео на YouTube. Есть ли предустановки для конкретных мобильных телефонов? И когда она просто нажимает прямую ссылку на видео, она будет воспроизводиться непосредственно на мобильном телефоне или я должен встроить ее в html5 / flash-плеер, как на youtube?

1

1 ответ на вопрос

2
LordNeckbeard

What the device supports

According to the Xperia U White Paper this device can decode H.264 video, High profile, level 3.2 in MP4 container with AAC audio.

Example ffmpeg command

ffmpeg -i input -codec:v libx264 -crf 23 -preset medium -profile high -level 3.2 \ -pix_fmt yuv420p -movflags +faststart -codec:a aac -strict experimental out.mp4 

What these options do

  • -codec:v libx264 – Choose video encoder libx264 to encode H.264 video.

  • -crf 23 – Output video quality level. 23 is the default and a lower value is a higher quality.

  • -preset medium – Encoding speed vs compression efficiency tradeoff. Default is medium.

  • -profile high – Sets H.264 video profile to High.

  • -level 3.2 – Sets H.264 video level to 3.2.

  • -pix_fmt yuv420pffmpeg attempts to minimize or avoid chroma subsampling (depending on input, encoder, ffmpeg version, etc). This is technically a good thing, but can result in an output that non-FFmpeg based players can't handle. This ensures a compatible chroma subsampling scheme.

  • -movflags +faststart – Relocates the "moov atom" to the beginning of the file so playback may begin before the file is completely downloaded in the case of progressive download (such as watching via a browser).

  • -codec:a aac -strict experimental – Encode AAC audio using the experimental native FFmpeg AAC encoder. It's not the worst AAC encoder, but if it sounds shitty use a higher bitrate with -b:a (default is 128k).

Additional notes

  • Use a recent version of ffmpeg. Old versions do not enforce the correct number of reference frames when using -level (fixed bug #3307), but since you're using Arch Linux you don't need to worry about that.

  • The ffmpeg package from the Arch Linux Extra repository only supports the native FFmpeg AAC encoder. Recompile from ABS with --enable-libfdk-aac --enable-nonfree (with libfdk-aac package as a depends) or use the ffmpeg-git package in AUR to gain support for encoding with libfdk_aac which is the best AAC encoder supported by FFmpeg. Using the ABS package is recommended over the AUR package if you want to try this.

  • If the input video and/or audio is already compatible then you can simply stream copy it instead of re-encoding, such as with -codec:a copy.

  • The mobile device may have additional restrictions that I am unaware of, so you will have to experiment. I'm also unsure if the device will work with a plain link to the video, but that would be easy to test.

  • See the FFmpeg H.264 Encoding Guide and FFmpeg AAC Encoding Guide for additional info.

@Konstantin Этот пример сработал для вас? LordNeckbeard 9 лет назад 0