x264: Optimal settings to have i-frames coincide with shot boundaries? - h.264

I would like to encode a video using x264 in such a way, that the keyframes (a.k.a. i-frames) are coinciding with shot boundaries (a.k.a. cuts).
for testing, I used the following encoder settings (reference: http://www.chaneru.com/Roku/HLS/X264_Settings.htm):
keyint=500:min-keyint=10:scenecut:40
but from the looks of it scene changes are ignored entirely, and keyframes simply inserted every 500 frames.
scenecut:40 being the default value, is my result expected behavior? or is it an indication, that something is not quite right?
thanks a lot in advance
edit:
the complete encoder settings look like this (in handbrake):
TL;DR:
it was a typo :|

From your settings screenshot it looks like it result in disabling of scenecut (scenecut=0 in x264 Unparse) because you used : as separtor of parameter name and value for scenecut instead of =.
So either change your additional params to:
keyint=500:min-keyint=10:scenecut=40
or remove scenecut from it at all i.e.:
keyint=500:min-keyint=10

Related

Problem with multiple Audio Clips in Instagram

So I got a conditional statement to switch between two audio clips (.m4a, mono, 44.1kHz, acc) as inputs for the audio player.
In SparkAR everything works as intended, but in Instagram I can only hear the song which should be played when the condition is false. Like the "default".
Here is my setup:
Unfortunately I can't send you the project or a preview of the filter as it's confidential work for an upcoming release of a musician.
I also tried using two speakers and changing their volume according to the conditional statement. But that doesn't work either.
I'm guessing it has something to do with using the wrong type for output in the condition? But there is no audioclip type and it works for one song, so I'm not sure.
Has anybody ever had a similiar problem and knows how to fix it?
Thanks a lot!
I have solved a similar problem utilizing multiple speakers, one for each audio clip:
On Instagram, check whether the condition passed to IF patch changes to TRUE or not.
I hope you have set the Patch Type of IF patch to "Text".

Can't Get DirectShow MPEG-2 Decoder to Output YV12/NV12 Progressive

I am attempting to get the MPEG-2 Decoder (aka DTV-DVD Video Decoder) to give me progressive YV12 or NV12 frames that can be uploaded to OpenGL for rendering. But what I'm seeing rendered looks like some form of uncompressed adaptive motion interlacing or else just B or P frames that don't give the full image. (The code that renders the YV12/NV12 in OpenGL works well with other sources, so that's not the problem.)
One important clue: I see one perfectly rendered frame when the movie starts and whenver it loops back to the beginning. This tells me that's the only time I'm getting a full frame of valid YV12/NV12 data.
Shortest description possible:
1) Created a custom Sample Grabber (based on CTransInPlaceFilter) so that I could get samples that have a VIDEOINFOHEADER2. This works as expected, and the sample sizes match expectations for YV12/NV12 at resolution I'm playing. (Helpful example of rolling your own Sample Graabber here.)
2) To ensure I only get progressive frames, the CheckInputType() method of my Sample Grabber to return E_FAIL if the dwInterlaceFlags field of the VIDEOINFOHEADER2 has the AMINTERLACE_IsInterlaced flag set.
3) I am setting the eAVDecVideoSoftwareDeinterlaceMode_ProgressiveDeinterlacing flag on the decoder using the ICodecAPI interface with CODECAPI_AVDecVideoSoftwareDeinterlaceMode. (If I don't do this, the decoder won't connect to my Sample Grabber because it doesn't accept interlaced frames.)
4) To debug this, I'm using the IMediaSample2 interface to get the properties of the incoming media samples in the Sample Grabber. The dwTypeSpecificFlags member of the AM_SAMPLE2_PROPERTIES struct tells me that the frames are AM_VIDEO_FLAG_INTERLEAVED_FRAME, which I believe indicates I'm getting a full frame instead of a single field. The AM_VIDEO_FLAG_I_SAMPLE bit is also set, for all frames, indicating that I'm getting full "I" frames and not "B" or "P" frames.
5) Given that all frames are "I" frames, I'd expect to see my image instead of gobbledygook as shown above. As mentioned above, the only time I see a valid image when the movie loops back around to the first frame.
6) Last thing: I do see that my samples have the AM_VIDEO_FLAG_WEAVE set. Is this "weaving" of the image the problem?
Thanks,
Mark

How to display/manipulate an indexed image Octave

Situation: Trying to output and also manipulate an indexed image.
Problem: When using ind2rgb(image, colormap(x)), we received an error saying that the indexed image contains colors outside of colormap, where x is the colormap option.
Question: How to work around this?
Additional information: I used imshow(image, colormap(x)), where I used every colormap available on Octave in substitution of x.
I believe this happens because you have more indexes than colors in colormap. Just make a bigger colormap. You can do that with the sysntax colormap(x(size_of_cmap))
ind2rgb(image, colormap(viridis(max(image(:))))
Alternatively, create the colormap and interpolate it. Caution: this can create artifacts in the color due to HSVs circular behavior.
m=max(image(:));
cm=colormap(x);
hsv=rgb2hsv(cm);
cm=interp1(linspace(0,1,size(cm,1)),hsv,linspace(0,1,m));
cm=hsv2rgb(cm);
ind2rgb(image,cm);
I suggest using the first solution if possible.

ITK difference betweeen SetInitialTransform and SetMovingInitialTransform

I am now using ITK library to image registration. I wonder, when setting initial parameters for ImageRegistrationMethodv4 type registration, shall I use SetMovingInitialTransform and SetFixedInitialTransform like in the tutorial, or just SetInitialTransform??
The "transform" in SetInitialTransform means transform for moving image or for fixed image? Thank you:)
(Please read this with caution--I do not have the library with me to test this answer; it's based on memory only.)
I believe SetInitialTransform() refers to the transform which is actually optimized by the registration method. In other words, it is a collection of transform parameters that specify an "initial guess" for the optimization process; these parameters will then start moving around at each iteration. (They are therefore applied to the moving image.)
I think SetMovingInitialTransform() and SetFixedInitialTransform() refer to static initial transforms which do no change at all during the registration process. They merely "set up" the moving and fixed images to desired starting locations, if you are not satisfied with their default positions in space.
If you have some simple 2D images, try testing this answer out with simple initial transformations, like a 5-unit translation transformation or something.
You could try reading the ImageRegistrationMethov4 documentation for a little more info.

The right way to print a QCView

I have put much time and effort into drawing certain 3d plots and surfaces using a Quartz Composition. Everything looks wonderful in my (Cocoa) application's QCView. However, in order to print, I am taking a snapshot of the QCView to generate an NSImage, and putting that in an NSView for my print options screen. However, lines and colors in the snapshot look horrendously aliased. Is there some other way to either directly print from my QCView, or to bypass/override taking a snapshot so that the NSImage looks as good as what's in my QCView? QCView inherits from NSView, but the built-in print method doesn't seem to work.
Thanks!
The obliteration of antialiasing might have something to do with alpha-transparency. As the lowest layer in your Composition, do you have a Clear patch set to opaque black? (It defaults to transparent black, which might be causing the problem here.)
Thanks smokris, but I found that the way to do this is to take a CGImage snapshot. I thought I'd be able to put this snapshot in an IKImageView, which preserves anti-aliasing, but IKImageView suffers from the same issue QCView, in that when print is called you get nothing in your print window.
So, the method that finally worked is to create pdf data from the CGImage snapshot using a CGPDFContext, load up an NSImageView with an NSImage generated from this pdf data, and when this goes to a print window all anti-aliasing is preserved! Very roundabout, but works like charm!