How can I generate multiple versions of the same video file at different bitrates that are properly key-frame aligned? Is it posible with ffmpeg?
Here is an article with example http://www.wowza.com/forums/content.php?192-Encoding-Suggestions-for-Video-on-Demand
The article says that "Multi-birate encoding has not worked using ffmpeg". Is it right?
use two-pass encoding, process first pass with the lowest resolution and then encode again each resolution with pass=2 which will use stats generated with first pass. this will guarantee keyframes to be in excactly the same places.
You should use no-scenecut, keyint and min-keyint options. Set the keyint and min-keyint options to the same values.
For example:
keyint=70:min-keyint=70:no-scenecut
Related
I try to add a thumbnail to a JPEG picture using libexif.
For now I'm borrowing the code from exif (the command line tool that is shipped by the libexif team).
However I noticed the XMP tags get deleted from the metadata. There is an old bugreport here.
I tried to see how to achieve this anyway with libexif but I don't really understand how to get the XMP from input file and put it in the output file. I just want to copy all XMP data, I don't need to extract anything of it.
I saw there is a TAG EXIF_TAG_XML_PACKET in exif_tag.h but couldn't figure out how to read/write this tag.
A related solution is in this SO answer but it looks complicated. I'm not familiar coding in C.
Is it actually possible to keep all XMP when using only libexif API? Have things changed in recent years on that? How would you write this in code?
Thanks
I believe it should be somewhat straightforward. XMP fields are described in the ISO/Adobe standard. Regular Kotlin/Java/Android file I/O and some string manipulation should be all that is required.
I would start out by becoming intimately familiar with ISO 16684-1:2019. Then, write a method for your jpeg file class that grabs all the XMP fields. Store those fields in a temp file (to prevent difficult to recover data loss in the event of your code or libexif crashing). Hand the file off to libexif. Generate the thumbnail. Finally, when that's done you can restore the XMP fields. If the thumbnail is stored in an XMP field as well (and it sounds like it is), it may be easier to concatenate that field with the other ones which were already grabbed, updating the temp file so that it contains EVERY XMP field, before adding all of the XMP fields back to the jpeg.
Unfortunately, I do not currently have the time to read a 50 page ISO standard, synthesize the information, and then write the code to implement the solution. Here's a link to the standard at least, to get you started.
https://www.iso.org/obp/ui/#iso:std:iso:16684:-1:ed-2:v1:en
In MATLAB I used to go:
info = imfinfo('image.jpg');
iso = info.DigitalCamera.ISOSpeedRatings;
And that's it. Octave has an imfinfo function that reads many parameters from the image header, but apparently not the ISO speed. That looks strange to me (why would it read dozens of params and let out ISO speed?).
Is there something I am missing?
Example image is here, shot with a DSLR (as you can see with imfinfo). With MATLAB, I can clearly see that imfinfo('image.jpg').DigitalCamera.ISOSpeedRatings is 200.
tl;dr
The value you want is under the field PhotographicSensitivity. Use:
iso = imfinfo ("image.jpg").DigitalCamera.PhotographicSensitivity;
See Octave bug #47706.
Octave only considers tags that follow Exif version 2.3.
Workaround
Old versions of the Octave image package had a function readexif (the function was deprecated in image package version 2.2.0 and removed in version 2.4.0) which may be able to read them. The last version to include that function was 2.2.2
Discussion
The details you are accessing are the EXIF values on your image file. Basically, there's a table on your file that maps tags, such as ExposureTime or FNumber, to their actual values. However, the tag names are not encoded in the file. Instead, each tag has an integer value e.g., ExposureTime or FNumber will appear as 33437 and 33434 respectively. It's the job of a program/library to map those integer values to the tag name.
The tag you are looking for, ISOSpeedRatings is not a valid EXIF tag per the EXIF specs version 2.3 (the latest specs, released in 2010). It was renamed to PhotographicSensitivity. If you read the specs under that tag, you will find this note:
Note that this tag was referred to as “ISOSpeedRatings” in versions of this standard up to Version 2.21.
If you read even more of the specs, you will find the following explanation on Annex G:
[...] the PhotographicSensitivity tag whose ID was 34855 was previously referred to as ISOSpeedRating, which, in reality, led to confused interpretations of sensitivity that resulted in many recordings that differed from ISO speed as defined under the ISO 12232 standard.
And if you read even more of the specs, you will notice that the meaning of the value with the tag 34855 was slightly changed when its name changed. This means that it's not only a tag name issue, its meaning is different if your camera follows a different version of the EXIF specs (assuming that your camera recorded it correctly, remember that the reason for the change was that cameras were recording the wrong thing).
I'm not sure what is the right technical answer. I'm guessing a program should check the recorded ExifVersion (which is the EXIF tag 36864) and change the tag names according to that.
Edit
Octave uses GraphicsMagick to read images, including its metadata. GraphicsMagick does not accept the EXIF tag numbers, programs need to query using the tag names. Octave then has a hardcoded list of tag names but only includes the tags for Exif specs 2.3. It seems that GraphicsMagick recognizes your file is an older version of Exif and names the tag old way which Octave does not ask for.
I did the following and can now use readexif from 2.2.2 in image 2.6.1:
Download Image 2.2.2 as suggested earlier in this thread
Add the readexif.m from Image 2.2.2 among image 2.6.1
Reload package pkg load image
Now you can call readexif. To get ISOSpeedRating:
readexif(JPGPath).Exif_IFD_Pointer.ISOSpeedRatings
This might be a question that may not be answered due to the nature of the external tool I am using (lack of documentation).
Basically, I am using a tool that pushes and pulls messages from the queue, more precisely - it pushes and pulls files. It worked perfectly for text files but when I tried pushing and then pulling a binary file - the pulled one was corrupted, it's size increased in comparsion with the original file (1.33 ratio).
For example moving a zip file wouldn't work...
I suppose it has something to do with the tools configuration, the only settings that can be changed regarding the problem are CCSID and encoding (UTF-8, Base16, etc.), I tried playing with both, unfortunately without success.
Tried using the following CCSIDs: 65535, 1208, 819
and encodings : UTF-8, Base16, Base64
In every case the binary file was corrupted after pulling it from the queue, I'm not entirely sure how the tool acomplishes that, it's written in Java, also I'm new to MQ so I tried searching for the correct options in IBM's docs but I haven't found anything that makes more sense than 65535 and Base16, yet it still doesn't work, could anyone with more experience with MQ tell if playing with these options makes sense at all in this case and if so - suggest what CCSID and encoding can I try to accomplish what Ive described above?
More information is really needed, but my suspicion is you are putting the message on the queue as a text message and playing around with encodings and ccsid's to try to get it right. You really need to know how the 'Java' app achieves this - is it using JMS (eg JMSBytesMessage) or base Java (something like setMessageData).
At a high level, there is a header on a message (The MD) which 'describes' the data - the MD format field. If you say the data is a string then MQ can convert between codepages should the getter request it etc. Put a tiny binary file into a message onto a queue, and browse the queue with amqsbcg or the GUI - what are the MD fields for format? What headers are on the payload - anything like RFH2's?
Put the same code in to give us a clue, or at least the amqsbcg output
I am using Brett's Mr. PHP thumb caching script along with phpThumb to create my thumbs. It works extremely well, except for one thing... I cannot get it to set and process the UnSharpMask filter. The relevant part of the script looks like this:
// generate the thumbnail
require('../phpthumb/phpthumb.class.php');
$phpThumb = new phpThumb();
$phpThumb->setSourceFilename($image);
$phpThumb->setParameter('w',$width);
$phpThumb->setParameter('h',$height);
$phpThumb->setParameter('q','95'); // set the quality to 95%
$phpThumb->setParameter('fltr[]','usm|80|0.5|3'); // <--- THIS SHOULD SET THE USM FILTER
$phpThumb->setParameter('f',substr($thumb,-3,3)); // set the output file format
if (!$phpThumb->GenerateThumbnail()) {
error('cannot generate thumbnail');
}
I'm guessing there's a problem with my syntax, since the fltr[] parameter requires brackets. I have tried escaping the brackets like so: 'fltr[]' but that didn't work either.
I've used several other possible parameters with good success (zoom cropping, max height, max width, etc...) Everything seems to work except the filters (including usm - UnSharpMask).
I don't get any errors. It spits out thumbs all day long. They're just not sharpened.
For reference, here's the official phpThumb readme file that discusses all the possible settings and filters.
Thanks for looking.
Well after much trial, error, and aggravation, I finally discovered the solution buried in one of the demo files that come with phpThumb.
It's a matter of removing the brackets all together. Basically changing this line:
$phpThumb->setParameter('fltr[]','usm|80|0.5|3');
to this:
$phpThumb->setParameter('fltr','usm|80|0.5|3');
After that, it's only a matter of tweaking the settings to get the desired amount of sharpness.
I have a Perl script I wrote for my own personal use that fetches image files from a website periodically. It then saves these images to a folder. These image files are quite often the same from fetch to fetch, and I'd like to not save duplicates if I can get around it.
My question: What would be the best way to compare/check if they are the same?
My only real thought so far is to open a file handle to existing one, md5 it, md5 the $response->content from the fetch and then compare them. Would that work?
Is there a better way?
EDIT:
Wow, already tons of great suggestions. Does it help if I tell you that this script runs daily via cron? I.e. it is guaranteed to always run at the exact same time everyday? Also: I'm looking at the last-modified headers on some of these, and they don't look 100% accurate, i.e. there are some that have a last-modified of over a week ago when I know the image is more recent than that. I'm assuming that's because the image file itself hasn't been modified on the server since then... which doesn't help me much...
Don't open and hash the stored image each time - stash the hash alongside the image when you store it. Compare sizes as well.
Don't issue a GET request straight away, do a HEAD first and compare the size, last modification date and any Etags to what you got last time.
There are a number of HTTP headers you can use for this -- if you save the time that you last retrieved the file, you can do a conditional get with
If-Modified-Since: <date>
Or, if the server returns an Etag header with the response, you can store that with the image, (or a collection of all of the etags you have seen for that image), and do:
If-None-Match: <all of your etags here>
If the server supports conditional gets, then you will get a "304 Not Modified" response, with no body.
Yep that sounsd right.
Depending on how you're getting the file and how frequently you might also be able to check for HTTP 304 Not Modified and save yourself the download.
md5 would work, but you'd still have to pull the file. Are there any useful metadata in the HTTP headers, content-length, cache-control directives, ETags, etc. ?
There's also a nice fdupes tool for the purpose. Don't know what system you're using and what systems the tool can be built for.