0

Summary: I have an old movie that I downloaded from YouTube some years ago, saved as an flv. I want to extract a 13-minute clip from it. To do that, I used ffmpeg to convert it to mp4 so I could load it in DaVinci, where I extracted the clip. Then I used Handbrake to compress it. But when I did that, HandBrake reduced the frame size significantly, and the compressed clip is somewhat blurred compared to the original.

Why is HandBrake forcing that reduction in frame size, and how can I get it to output at the correct frame size?

Details:

The flv file is 268 MB, duration 107 minutes, frame size 318x240, frame rate 25:

enter image description here

The ffmpeg command I used to convert to mp4:

ffmpeg -i input.flv -c copy output.mp4

That took about a second. The result is 264 MB:

enter image description here

I loaded that in DaVinci, extracted the clip, then rendered as mp4, H.265, 318x240, 25 fps:

enter image description here

The result of that is 51.4 MB, 13:19 mm:ss. MediaInfo reports it is HEVC, which I understand means it is in H.265, as I requested:

enter image description here

The size-to-time ratio is a lot bigger than for the full movie:

  • Movie: 264 MB / 107 minutes = 2.5 MB/min.
  • Clip: 51.4 MB / 13.33 min. = 3.9 MB/min.

When I load the clip in HandBrake, it tells me the source is 318x240, 25 fps. Even though it's in H.265, HandBrake tells me it's in H.264. Then HandBrake also contradicts its source information by saying under "Tracks" that it is 30 fps and that the size is 234x174.

enter image description here

========================

In Handbrake's "Video" tab, the encoder comes up as H.264 and the frame rate as 30. The RF is 22:

enter image description here

========================

I changed that to 265 and 25:

enter image description here

========================

The "Dimensions" tab says again that the size is 318x240, but then says that:

The scaled size and the final storage size are 234x174. I tried clicking several things and cannot get it to change that output size.

enter image description here

========================

When I run that, the output is 22 MB, which is a nice reduction in file size:

  • Compressed clip: 22 MB / 13.33 min. = 1.7 MB/min.

But the frame size is 234x174:

enter image description here

The video is somewhat blurred compared to the original, which it seems could well be caused by the reduced frame size.

Original flv file: enter image description here

Mp4 converted by Ffmpeg: enter image description here

Clip rendered by DaVinci.

This might give a clue to the problem. The image occupies less than the full window of the player. Did DaVinci reduce the scale of the video?

enter image description here

Clip compressed by HandBrake: enter image description here

Why is HandBrake forcing that reduction in frame size, and how can I get it to output at the correct frame size?

NewSites
  • 862

3 Answers3

2

Edit from the questioner: I've accepted this answer because it gave me what I needed. But see further details in the additional answer that I've also given.



It may be helpful to remember that Handbrake is largely a skin for FFMPEG with some relatively user-friendly presets. Your process is currently going FFMPEG > DaVinci > FFMPEG, without any real reason we can see for the additional steps. So skip all of the intermediary steps and just use FFMPEG to clip the video. Here's another question that may cover the basics of your need: https://stackoverflow.com/questions/21420296/how-to-extract-time-accurate-video-segments-with-ffmpeg

Specify the clip start time with -ss 00:00:00 and the end with -to 00:00:00. Like this example from the question I've linked just above:

ffmpeg -y -i [INPUT.file] -ss 00:42:42 -to 00:84:84 -codec copy [OUTPUT.file]

Doing this you're removing all the possibility of issues caused by the multiple steps you're currently using.

NewSites
  • 862
music2myear
  • 49,799
1

I'm accepting the answer by "music2myear" because it gave me what I needed. But for some reason, it assumed I didn't care about the size of the output file. But I do care about that, which is the reason I was running HandBrake.

So I changed the codec parameter in that answer. Here is a summary of my results:

  • Clip from DaVinci in H.265: 51.4 MB

  • DaVinci clip then HandBrake: 22.0 MB (blurry)

  • Clip from FFmpeg with -codec copy: 29.5 MB

  • Clip from FFmpeg with -codec:v hevc -codec:a copy: 15.2 MB

Both FFmpeg results appear to have good quality. The one with codec copy took about a second, the one with hevc, about a minute.

The result from mFFmpeg with codec hevc gave a very nice reduction in file size:

  • Movie: 264 MB / 107 minutes = 2.5 MB/min.
  • Clip from DaVinci: 51.4 MB / 13.33 min. = 3.9 MB/min.
  • Clip from FFMpeg with codec hevc: 15.2 MB / 13.33 min = 1.1 MB/min.

So, I don't have an answer to why HandBrake (or the combination of DaVinci and HandBrake) was reducing the frame size. But I do have answer for how to get good quality output with the right frame size (and an efficient file size), which is to use FFmpeg directly.

NewSites
  • 862
0

This is a work-around, rather than an exact answer: do the whole process in a single step using a GUI that gives complete control of how the output is saved.

Two free, open source, video editors, Shotcut and OpenShot (both available in Linux, and Mac, as well as Windows versions, and both Windows app run under wine, too, on this Ubuntu machine), for example, can open FLV video files, edit them, and save the edited output in various formats and with adjustable resolution and quality. There are many alternative video editors, too.

OpenShot Export Video Dialog

The screenshot above is from the OpenShot Export Video dialog, and ShotCut offers even more granular control of output. One selects the segments to edit, applies filters such as Sharpen, if desired, and exports with color gamut (e.g., Broadcast, MPEG or JPEG), resolution, frame rate, compression, etc. under user control, all with a single tool. Neither program is intimidating to use, since reasonable defaults are preset.