1

我使用 FFMPEG 将 JPG 文件转换为 MP4 文件。它们是我可以用来进一步减小此 MP4 文件大小的任何压缩技术/标志/设置/开关吗?我曾使用 gZIP 压缩此文件的字节,但它实际上生成了一个更大的文件。

我正在使用 C#

谢谢

4

2 回答 2

2

MP4 is a container format. Depending on your ffmpeg configuration ffmpeg will either use the encoder mpeg4 for MPEG-4 Part 2 video or libx264 for H.264 video.


mpeg4

Rate control methods include -qscale:v and -b:v. These are mutually exclusive so you should use one or the other.

-qscale:v

Sets a constant quantizer, but general users can just think "constant quality". Effective range is 2-31 where 2 is highest quality.

ffmpeg -i input -codec:v mpeg4 -codec:a libmp3lame -qscale:v 4 -qscale:a 5 out.mp4

-b:v

Allows a video bitrate to be applied. Can be used to target a specific output file size (filesize = duration x bitrate).

ffmpeg -i input -codec:v mpeg4 -codec:a libmp3lame -b:v 512k -b:a 128k out.mp4

Also see:


libx264

Rate control methods include -crf, -b:v, and -qp, but for the vast majority of users -qp can be ignored.

-crf

Constant Rate Factor. Think of it as a "smart" version of -qscale:v. Range is logarithmic 0-51. 0 is lossless (big files), ~18 is roughly visually lossless, 23 is default, and 51 is worst quality.

ffmpeg -i input -codec:v libx264 -crf 23 -preset medium -codec:a libfdk_aac -vbr 5 output.mp4

-b:v

Allows a video bitrate to be applied. Can be used to target a specific output file size (filesize = duration x bitrate). Two-pass example:

ffmpeg -y -i input -pass 1 -codec:v libx264 -preset medium -b:v 800k -an -f mp4 /dev/null
ffmpeg -y -i input -pass 2 -codec:v libx264 -preset medium -b:v 800k -codec:a libfdk_aac -b:a 128k output.mp4

Also see:

于 2013-08-27T17:39:21.000 回答
-1

压缩一个已经压缩的文件通常不会有太大的区别(而且它可能会导致一个更大的文件)。

所以如果你想要一个更小的文件,我建议你改变mp4文件的压缩质量(无论你使用什么技术,我认为你都有这个选项)。

如果您使用的是命令行工具,则可以播放视频比特率以减小文件大小:

ffmpeg -f your_image_files*.jpg -vcodec mpeg4 -b 1200kb your_video.mp4

只需1200kb用较低的值替换,您的文件大小就会更小

如果你想在 C# 中完成这一切,并查看编码进度,你可以使用这个 .Net 包装器用于 ffmpeg: http ://www.ffmpeg-csharp.com/

于 2013-08-27T14:38:55.783 回答