Results 1 to 8 of 8

Thread: Looking for method to resize large video down to certain file size.

  1. #1
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Question Looking for method to resize large video down to certain file size.

    Hi.

    Is it possible to resize a video of e.g. 1.3GB to about 900MB via a terminal command or GUI way?

    For example, I'd like the command to figure out the proper aspect ration and bit quality in order to reduce the video size down to 900MB.

    Thanks.
    Last edited by Rytron; June 20th, 2015 at 08:16 PM.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  2. #2
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: Looking for method to resize large video down to certain file size.

    You can do it with ffmpeg, but it takes some work: https://trac.ffmpeg.org/wiki/Encode/H.264
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  3. #3
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Post Re: Looking for method to resize large video down to certain file size.

    Quote Originally Posted by SeijiSensei View Post
    You can do it with ffmpeg, but it takes some work: https://trac.ffmpeg.org/wiki/Encode/H.264
    Hi SeijiSensei.

    Those command in your link look very tricky.

    I may just stick with commands such as these:
    • ffmpeg -i input.mp4 -vf scale=720:576 output.mp4
    • ffmpeg -i input.mkv -vf scale=576:-1 output_576.mkv
    • ffmpeg -i input.mkv -vf scale=-1:720 output_720.mkv
    • ffmpeg -i input.mp4 -vf scale=iw/2:-1 output.mp4
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  4. #4
    Join Date
    Sep 2006
    Beans
    3,713

    Re: Looking for method to resize large video down to certain file size.

    See the Two-pass example in the link provided by SeijiSensei:

    https://trac.ffmpeg.org/wiki/Encode/H.264#twopass

    Using two-pass method can allow you to achieve a desired output file size. (In the vast majority of all other cases, and if file size is not a priority, I recommend just using single pass with -crf).

    If you don't feel like doing the math you can use a simple bitrate calculator. You just need to tell it the duration and the desired output file size.

    Example if your input is 1 hour long and you want an output of approximately 900 megabytes:

    Code:
    ffmpeg -y -i input -c:v libx264 -preset slow -b:v 1918k -pass 1 -an -f mp4 /dev/null && \
    ffmpeg -y -i input -c:v libx264 -preset slow -b:v 1918k -pass 2 -c:a libfdk_aac -b:a 128k -movflags +faststart output.mp4
    I'm not sure why someone added audio encoding to the first pass example in the wiki, but I've never needed to do that, so I omitted it.

  5. #5
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Question Re: Looking for method to resize large video down to certain file size.

    Quote Originally Posted by FakeOutdoorsman View Post
    See the Two-pass example in the link provided by SeijiSensei:

    https://trac.ffmpeg.org/wiki/Encode/H.264#twopass

    Using two-pass method can allow you to achieve a desired output file size. (In the vast majority of all other cases, and if file size is not a priority, I recommend just using single pass with -crf).

    If you don't feel like doing the math you can use a simple bitrate calculator. You just need to tell it the duration and the desired output file size.

    Example if your input is 1 hour long and you want an output of approximately 900 megabytes:

    Code:
    ffmpeg -y -i input -c:v libx264 -preset slow -b:v 1918k -pass 1 -an -f mp4 /dev/null && \
    ffmpeg -y -i input -c:v libx264 -preset slow -b:v 1918k -pass 2 -c:a libfdk_aac -b:a 128k -movflags +faststart output.mp4
    I'm not sure why someone added audio encoding to the first pass example in the wiki, but I've never needed to do that, so I omitted it.
    Hi FakeOutdoorsman.

    So I will try a video of about 2h50m. I want it reduced to 900 MB from 1.6 GB. Do I run 2 lines or 1?
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  6. #6
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Question Re: Looking for method to resize large video down to certain file size.

    Are the values in my commands for kiloBytes or kiloBits?
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

  7. #7
    Join Date
    Sep 2006
    Beans
    3,713

    Re: Looking for method to resize large video down to certain file size.

    Quote Originally Posted by Rytron View Post
    So I will try a video of about 2h50m. I want it reduced to 900 MB from 1.6 GB. Do I run 2 lines or 1?
    You run two commands with two-pass encoding. Your commands may look something like this:

    Code:
    ffmpeg -y -i input -c:v libx264 -preset slow -b:v 592k -pass 1 -an -f mp4 /dev/null
    ffmpeg    -i input -c:v libx264 -preset slow -b:v 592k -pass 2 -c:a libfdk_aac -b:a 128k -movflags +faststart output.mp4
    Quote Originally Posted by Rytron View Post
    Are the values in my commands for kiloBytes or kiloBits?
    The -b option takes a value in bits, so you have to add a "k" to make it kilobits (as shown in the example above).

  8. #8
    Join Date
    Feb 2008
    Location
    Munster, Ireland
    Beans
    2,467
    Distro
    Ubuntu Mate

    Thumbs up Re: Looking for method to resize large video down to certain file size.

    @FakeOutdoorsman I went with Handbrake in the end. But I will keep your info for future reference. Cheers.
    1st Distro used (live CD): Knoppix in early 2007 ¦ 1st Distro Installed: Ubuntu 7.10 in Feb 2008
    GNU/Linux User #470660 – Ubuntu User #28226
    Isaac Asimov: "I do not fear computers. I fear the lack of them."

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •