简体   繁体   English

在PHPmotion中使用ffmpeg&mp4box将视频从任何视频转换为mp4时,如何减小文件大小?

[英]How to reduce the file size during conversion of video from any video to mp4 using ffmpeg &mp4box in PHPmotion?

I am using ffmpeg & mp4box in my PHPmotion site to convert videos to mp4 format. 我在PHPmotion网站中使用ffmpeg和mp4box将视频转换为mp4格式。 When I convert a 50MB video to mp4, the file size remain same. 当我将50MB视频转换为mp4时,文件大小保持不变。 So Its affecting the video streaming in my site. 因此,它影响了我网站中的视频流。 So I want to reduce the file size of the video in conversion. 因此,我想减小转换视频的文件大小。 This is my code example, that I've used the site for converting m4v videos in PHPmotion. 这是我的代码示例,我已使用该站点在PHPmotion中转换m4v视频。

$ffmpeg_cmd2_2 = "$config[path_to_ffmpeg] -i $raw_video_path -vcodec libx264 -vpre veryfast -crf 15 -b 5120000 -threads 0 -acodec libfaac -ac 2 -ab 128k -ar 44100 -f mp4 $new_flv_1";
$mp4box_cmd = "$mp4box_path -add $new_flv_1 $new_flv_2" 

When I use this command,it converts the m4v file to mp4 format, but the filesize doesn't change. 当我使用此命令时,它将m4v文件转换为mp4格式,但文件大小没有变化。 What command I should use in this to reduce the filesize during video conversion in PHPmotion? 我应该在其中使用什么命令来减小PHPmotion在视频转换期间的文件大小? Can anyone write a ffmpeg command to reduce the filesize during conversion ? 任何人都可以编写ffmpeg命令来减少转换期间的文件大小吗?

There are two main factors involve in reducing the size of mp4 video 减少mp4视频的大小有两个主要因素

i: width and height of video, greater their widths, greater will be size and slower will be streaming e,g 360p, 480p, 720p, 1080p i:视频的宽度和高度,宽度越大,流的尺寸越大,流式传输的速度越慢,例如360p,480p,720p,1080p

ii: video bitrate, greater will be their bitrate, higher will be quality, size and slower will be their streaming. ii:视频比特率,其比特率越高,其质量,大小越高,其流越慢。

For faster streaming i recommend using 为了更快的流媒体,我建议使用

i: 480x360 or lower width and height of video ii: -b value 360k or lower. i:480x360或更低的视频宽度和高度ii:-b值360k或更低。 iii: -ab value 64k (optional) iii:-ab值64k(可选)

Hope this will help you. 希望这会帮助你。

Apart from using smaller video frame size, you need to use higher crf value to achieve bitrate reduction while maintaining good video quality. 除了使用较小的视频帧大小外,还需要使用较高的crf值来实现比特率降低,同时保持良好的视频质量。

Replace this 取代这个

-crf 15 -b 5120000

with

-crf 22

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM