1

Is there any way how to reduce the size of video?

In php I use this:

$result = exec("avconv -i $file1 -vcodec libx264 -acodec aac -strict experimental $file2");

Unfortynately, all produced videos have the same size as originals or are more bigger.

1) First of all I want to reduce dimensions of all videos: width: 750px, height: auto. Is it possible?

2) Is there some way how to reduce the quality a little bit? Of course, I don't want blurry videos but in some websites I see that a good quality 15 minutes videofile have a size something like 50 MB. My videos of 1 minute have the same size.

llogan
  • 121,796
  • 28
  • 232
  • 243
Verode
  • 145
  • 2
  • 9

1 Answers1

1

You can use several options to reduce the size (and resolution) of the video file. Keep in mind that the quality of the output video file will obviously be lower than the input video file.

I have used the following options and have had good results.

  1. Frames per second
  2. Audio bitrate
  3. Size / Resolution of the video frames

For my videos, I typically set them to:

  1. 24 Frames per second
  2. Audio bitrate of 128 Kbps
  3. Size / Resolution of 1024x576 or 512x288 - This is because I like my videos to have an aspect ratio of 16:9.

Also, I first scale the video frames to the required resolution and then crop them to the required size.

You can of course play with these options to find what works best for you in terms of file size vs. video quality.

The commands are:

  • For output videos in MP4 format

    avconv -i <input_filename> -c:v libx264 -c:a mp3 -b:a 128k -r 24 -vf "scale=512:-1,crop=512:288:0:0" <output_filename.mp4>

  • For output videos in WEBM format

    avconv -i <input_filename> -c:v libvpx -c:a libvorbis -b:a 128k -r 24 -vf "scale=512:-1,crop=512:288:0:0" <output_filename.webm>

Give this a try. Hope it helps.

buzz
  • 326
  • 3
  • 7