Crop and transpose filters combined produces large output
Hello, I have been experimenting with using the video crop and transpose filters with ffmpeg (version 2.5.2 on Windows) to convert 4K video into 1080p video without scaling. When I combine these filters in a 1 pass operation, I get an output (File4.mp4) that is about 4X larger than it should be. But, when I split the same operation into 2 passes, I get an output (File3.mp4) that seems to be the correct size. The details are: Crop and transpose in 1 pass: ffmpeg -i File1.mp4 -vf crop=1080:1920:0:0 -vf transpose=2 File4.mp4 File sizes in bytes: File1.mp4 79,889,077 (Input 4K Video) File4.mp4 25,918,758 (Excessive Size) Crop and transpose in 2 passes: ffmpeg -i File1.mp4 -vf crop=1080:1920:0:0 File2.mp4 ffmpeg -i File2.mp4 -vf transpose=2 File3.mp4 File sizes in bytes: File1.mp4 79,889,077 (Same Input 4K Video) File2.mp4 6,994,548 File3.mp4 5,777,801 (Correct Size) All of these files can be played with ffplay, but I use other video players and they have trouble playing File4.mp4. It is not a big problem to use 2 passes, but I'm curious if this is a known issue or am I missing something? Thanks, Clay
On Thu, Jun 29, 2017 at 9:19 PM, Clay D. Montgomery <clay@montgomery1.com> wrote:
Crop and transpose in 1 pass: ffmpeg -i File1.mp4 -vf crop=1080:1920:0:0 -vf transpose=2 File4.mp4
There's no cropping taking place, as the video filter argument has been replaced. Syntax is -vf "crop=1080:1920:0:0,transpose=2"
On Thu, Jun 29, 2017 at 21:32:23 +0530, Gyan wrote:
There's no cropping taking place, as the video filter argument has been replaced.
Ah, d'uh, I missed that. That's what he meant with size. Clay, why did you write "wrong size" and then quote the file size next to it, if you meant the dimensions (i.e. 1080x1920)???? Confusing indeed. Moritz
On 6/29/2017 11:15 AM, Moritz Barsnick wrote:
On Thu, Jun 29, 2017 at 21:32:23 +0530, Gyan wrote:
There's no cropping taking place, as the video filter argument has been replaced. Ah, d'uh, I missed that. That's what he meant with size.
Clay, why did you write "wrong size" and then quote the file size next to it, if you meant the dimensions (i.e. 1080x1920)???? Confusing indeed.
Moritz _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe". Gyan, Moritz,
Yes, I did have the syntax wrong for combining the filters. It is working for me now like this: ffmpeg -i File1.mp4 -vf crop=1080:1920:0:0,transpose=2 File3.mp4 File1.mp4 79,717,759 File3.mp4 6,816,685 Thanks again for all your help. I really appreciate it. You guys Rock! Regards, Clay
On Thu, Jun 29, 2017 at 10:49:23 -0500, Clay D. Montgomery wrote:
should be. But, when I split the same operation into 2 passes, I get an output (File3.mp4) that seems to be the correct size. The details are:
Define "correct". The file size (or bitrate) is defined by various factors: Mainly by the quality (the more quality, the more bits you need), and by the amount of effort you put into the encoding, i.e. how much CPU (to encode more bit-efficiently) and which encoding methods (which may require more calculation power. Since you haven't provided ffmpeg console output (full, uncut), I can only assume that you're encoding to H.264 using libx264. In ffmpeg, this codec defaults to CRF=23, with a preset of "medium", i.e. medium effort in terms of CPU, and of H.264 profile/version. You can do two things to reduce the size of the output: - put more CPU effort in, e.g. by adding "-preset veryslow"; - reduce the quality, e.g with "-crf 26"; - you can also just provide the target video bitrate, with "-b:v 1M".
File4.mp4 25,918,758 (Excessive Size)
Why is this considered excessive?
File3.mp4 5,777,801 (Correct Size)
There's probably nothing "correct" or "incorrect" about that size. It's just "more like what you desire".
Crop and transpose in 2 passes: ffmpeg -i File1.mp4 -vf crop=1080:1920:0:0 File2.mp4 ffmpeg -i File2.mp4 -vf transpose=2 File3.mp4
I can tell you why this gives a smaller size: Each encoding implies a loss in quality. In the second case, the encoder already gets less input detail, and that results in requiring less bits for the output. So the smaller size is a horrible side effect of your double lossy encoding. You get a better encoding result (i.e. quality for size) by tuning the parameters I mentioned above. And now to a different issue:
All of these files can be played with ffplay, but I use other video players and they have trouble playing File4.mp4.
Is that ffmpeg's problem? ;-) No, honestly: - Please define "trouble" more precisely. - Please provide your ffmpeg command line, along with the complete, uncut console output. (The usual guess is: Your player doesn't support the pixel format ffmpeg encodes to. But I hate guessing, do give us some info.) Cheers, Moritz
participants (3)
-
Clay D. Montgomery -
Gyan -
Moritz Barsnick