I want to compress video in Android and upload it. before compressing I want to show the deferent width and height and estimated Size then user chooses one.
for example:
240 estimated Size =~20 MB
480 estimated Size =~40 MB
640 estimated Size =~90 MB
720 estimated Size =~130 MB
1080 estimated Size =~180 MB
now I look for a formula for calculating estimated size.
I get width and height and bitrate from MediaMetadataRetriever in Android
retriever = new MediaMetadataRetriever();
retriever.setDataSource(path, new HashMap<String, String>());
width = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
height = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
rotation = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);
I found it.
for calculating file size from Bit rate and duration we can use:
(bitrate() / 8 * duration() / 1000/1000)
for example
file size=((17305731/8)*(4655000/1000/1000))=10,069,772= 9.6 MB
Related
there are 160 units per inch.
2.If I created an Photoshop file that are 72 dpi then there will be 72 points per inch.
3.If the element is 88px height in Photoshop then what I have to set it in xamarin?
If the phone is 360dpi then the height in xamarin should be :88 / 72 * 160 / 2?
but it is not right.
I know the units in each platfform and I only want to know how to get units from pixels
You could use Xamarin.Essentials to get the Screen density as follows:
// Get Metrics
var mainDisplayInfo = DeviceDisplay.MainDisplayInfo;
// Screen density
var density = mainDisplayInfo.Density;
If the density is 3 in iOS device and pixels is 88 , then there are 88/3 units in iOS.
If the phone is 360dpi
That means it shoule be a Android device, and screen density also can be calculated by 360/160 = 2.25. Then there are 88/2.25 units to set for HeightRequest.
================================Update==============================
If there is a BoxView in Xaml as follows:
<BoxView x:Name="MyBoxView" BackgroundColor="CadetBlue" HorizontalOptions="Fill"/>
And the effect:
Now I will print the MyBoxView.Width. the result is:
Console.WriteLine("++++MyBoxView++++" + MyBoxView.Width);
++++MyBoxView++++411.428571428571
If you use var density = mainDisplayInfo.Density; to get density, you will get Screen Density::2.625. (My device is Piexl_2_pie_9_0 api 28 emulator)
You know the size of screen width is 1080 pixels, however the width is 411.428571428571. That should means units of WidthRequest.
And if you put 411.428571428571 * 2.625 , you will get 1080 pixels.
I'm writing a GNU Makefile to do some processing on images.
One task is to scale the image (.ppm format) by a SIZE parameter using the pnmscale command. The image should be scaled by the longer side without loosing the ratio and should be saved under .scaled .
I've read the man page of pnmscale but couldn't seem to find the right option.
I've tried the following:
pnmscale -pixels 100 example.ppm > example.scaled
When example.ppm has the size 200 x 100 pixels and I run the pnmscale command with the size of 100 pixels, example.scaled should have the size of 100 x 50 pixels. With my solution the image gets very small.
As the manpage of pnmscale states, the option pixels
specifies a maximum total number of output pixels. pnmscale scales the image down to that number of pixels. If the input image is already no more than that many pixels, pnmscale just copies it as output; pnmscale does not scale up with -pixels.
In other words, by specifying -pixels 100, you're actually scaling down your image to a maximum number of 100 pixels. What you're trying to achieve is to scale down your input image to a size of 100 x 50 pixels = 5000 pixels.
Looking again at the manpage of pnmscale yields the following:
pnmscale [{-xsize=cols | -width=cols | -xscale=factor}] [{-ysize=rows | -height=rows | -yscale=factor}] [pnmfile]
[...]
If you specify one dimension as a pixel size and don't specify the other dimension, pnmscale scales the unspecified dimension to preserve the aspect ratio.
In your case, using
pnmscale -xsize 100 example.ppm > example.scaled
should shrink your input image to a width of 100 pixels.
How can you control the size of the printed node?
Ex. I have a Rectangle width = 10 * DPI and height = 5 * DPI.
I want to print this node to be Exactly 10 x 5 inches.
can anyone tell me how to do it programatically?
you can read out the dpi of the current screen with the following code:
double dotsPerInch = Screen.getPrimary().getDpi();
be aware that this is the dpi value when the screen is set to its native resolution!
Does ImageResizer.Net for asp.net have any method by which we can know the resolution of any uploaded Image. I know one method:
ImageResizer.ImageBuilder.LoadImageInfo (object source, IEnumerable< string > requestedInfo )
that gives me Height, Width, Mimetype & extension of image file, but I have a requirement where I need to validate the resolution of an uploaded image.
As far as I know dpi is something what connected to devices where images will be rendered.
So, if it is Desktop dpi can be or 72 (MAC) or 96 (Windows), but if you will print it dpi can be 150 or 300.
So to check if image will be correctly printed (with good quality) on paper with size 200x200 milimeters you can calculate min size if image you need in pixels.
So, we have the following input:
- dpi of printing is 150
- size of paper is 200x200 milimeters
200 mm is 7.9 inch
=> min resolution of image should be 7.9*150 = 1185 pixels
So only images with height and width equal or more than 1185 will be printed with good quality.
So question for you - what for you need resolution(dpi) check?
As far as you have Height and Width you can calculate DPI using this formula:
dp = sqrt(width^2 + height^2) (Pythagorean theorem)
then, you should know size of the screen in inches (di). Simply:
dpi = dp / di
I am have set an add_image_size function that is often larger in only one dimension than the uploaded image. This results in an image that has one dimension cropped and one dimension that remains un-cropped resulting in an image that loses it's proportions. As a result I have a set of images that are not equally proportioned.
The desired outcome is that if the image is cropped in one dimension then it is proportionally cropped in the other dimension, meaning that I can upscale it if required with CSS.
For example, my image size is 1200 x 900. If I upload an image that is 1100 x 1467. The output is an image that is 1100 x 900. However, what I require is an image that is 1100 x 825 (the same proportion as the 1200 x 900 image size I set, but smaller as the image wasn't large enough to fulfill this size).
Here is the function with the arguments:
add_image_size( 'landscape-huge', 1200, 600, true);
I can't seem to find a way of doing this though - is this possible?
Because it's wordpress default feature but u can change, go to wp-include folder then media.php and find these lines
$s_x = floor( ($orig_w - $crop_w) / 2 );
$s_y = floor( ($orig_h - $crop_h) / 2 );
and change to
$s_x = 0;
$s_y = 0;
it will work for you.