Is it possible to get the frame width & height of an .mp4 file using ASP.NET?
I know how I can get the width & height of an image (by using a Bitmap object), but I'm not sure whether this is possible with video formats.
I'm using JWPlayer to display uploaded videos through the web application, and I want to set the width/height as a proportion of the actual video width/height.
As I like to do things the hard way I would go for reading the file meta data to try and find the information I needed.
I think this has some info about the structure of MP4 files but not had chance to read through it: http://xhelmboyx.tripod.com/formats/mp4-layout.txt
If you are happy to use a 3rd party library then this one seems to provide the data you need and looks to work with many other file formats too: http://mediainfo.sourceforge.net/en
Hope that get you somewhere ;)
Related
I am interested in adding a landsacpe footer on my website but the image size is 115KB and will load on every page... Is there any effective way to load an huge image such as this one:
http://gyazo.com/5b1b7312ec4370873368df0181e41b13.png
Here's a few things that may help you:
EDIT: I tried the second tip in the list below (tinypng.com) and it reduced the size of your image with 71% to 39.1 KB. So that's a big win.
Make sure to set the cache headers on your webserver so that the browser can cache the file. Also use the same URL for all other times you use the image. Doing these two simple things will make sure that the image will only get downloaded the first time the browser requests it. All other times it will be loaded from the browser's cache.
Make sure to check if the image is as small as it can be. If you use a PNG then use tools like https://tinypng.com/ to squash all metadata out of the image. If you use a JPEG then maybe lower its quality. If you use Photoshop make sure to "save the image for web". This will also reduce the size. For photographs you are mostly better of using JPEGs, for text or other images that need to be lossless use PNG or GIF.
Loading images will not really slow down your page that much. Not like JavaScript anyway. Loading Javascript will block the rendering of the page until the JS file is downloaded unless you use special loading techniques. That is not the case for images: the page will continue being rendered and the user can start using the page.
If the image is placed using an IMG tag the make sure to set the width and the height of the image in the CSS (or using the img width and height attributes). That will make sure that the browser does not need to reflow the page when the image is downloaded. It will know what size it needs to be even before the image is downloaded.
There is a maximum number of parallel requests per domain that the browser will do. If the image has a very low priority you could postpone its loading and wait for the onLoad event. This will make sure the other resources (with a a higher prio) will be downloaded first. This will require some JavaScript, but not that much (Use an image lazy loader, there are many).
As I said in the previous item the are a maximum number of requests PER DOMAIN. This is why you could also create a new (sub)domain and load some content from there. It will increase the total number of resources that will be downloaded in parallel. using a CDN will also help here because they also have a separate domain (and they are optimised as well).
If you want to read some REALLY GOOD books about this kind of optimising, read these:
http://www.amazon.com/High-Performance-Web-Sites-Essential/dp/0596529309
http://www.amazon.com/Even-Faster-Web-Sites-Performance/dp/0596522304
Sites like facebook,google plus have there whole images in one picture how many bytes of memory
can be saved using this method
You are not saving any memory. You are saving bandwidth because you are making fewer HTTP requests to the server.
As pointed out by #iccthedral in the comments section you are actually saving bytes because you now have a single image => the total amount of saved bytes = numberOfPictures * sizeof(pngHeader).
This is called CSS Image Spriting through this we can save our HTTP Requests to server.
If we will use this method so our one HTTP request will go to server and call all the required images through CSS Image Spriting.
So now most of us are using this method :
read more about the CSS Image Spriting
Those images are called CSS image sprites.
They are used to minimise server requests, rather to save memory.
Also You might consider using SVG icons, which weight slightly more, but can efficiently used to save space if You need the same icon in different sizes. Here is a good material to read : Resolution Independence With SVG
its not the question how much memory gets saved, its how many http requests your "not doing" by having your images in to a sprite. Site will load faster
The amount of kb on images will +- stay the same, individual or sprited
I want a header image in my HTML to be random. I have accomplished this by using this php file, however I would like to do something different. I want to have the random images be a part of one sprite. That way the images can all load at the same time and they user won't have to see the images load when navigating to different pages. I would also like to choose the random factor, i.e. show this picture 50% the others 10% of the time (if there are 6 pictures). Is this even possible and where would an amateur start? Is this the best way to implement my scenario so that the user sees as little image load as possible?
You could have the sprited header style declared in CSS as you normally would, and then simply adjust the xpos/ypos of the sprite in-html. You would be able to recycle some of the logic you already have and manipulate individual header probability.
I'd stick with individual assets though, especially if they are the size of a google doodle. Easier to extend that way and, assuming the rest of your static content has already been cached, any overhead of downloading a new image would be negligible.
I have pre-existing PDF files which I would like to send to a PrintJob in Flex 3. I can load the files fine with UrlRequest, but I need to somehow get the data into a Sprite to be included into a PrintJob.
Is there a way to do this, or should I go another route? (I've seen the hidden iFrame example, but I was hoping for a way to do this without JavaScript.)
Thanks
If you're using Aodbe AIR, then you'll be able to load the PDF into an HTML View.
Flex (and The Flash Player) does not have any native support for displaying (or creatging) PDFs, though.
Most people will just pass the generated PDF to the browser and let it handle it. You can do this w/ navigateToURL. The iFrame trick can work, although the actual display of the PDF may depend upon browser settings.
Here is another StackOverflow Post on a similar topic. It links to this site http://www.devaldi.com/?p=212 which provides one alternative.
I need to display a small (15x15 pixel) animation in a Flex app. I have it FLV format, but it could be converted to somthing else. I'd prefer to have the file embedded in the app (it's only 8k in size). I've seen posts about displaying animated GIFs using third-party code which would be OK, but is there a way to do this with the native Flex libs. I also realize that FLVs can be displayed in Video objects but only if they are external files.
It is a lot easier converting it into a SWF and displaying it in an Image control. SWFTools can convert animated GIF into SWF file, small enough to be embedded in your app.
Or alternatively you could convert it into a good old animated GIF file and use this package to embed and play it back:
http://www.bytearray.org/?p=95
I guess you have a blank frame in SWF either in the beginning or the end.