MLT, how to rotate a video 90 degrees and make the resulting height be the same as the original width? - video-processing

I shot a video with my phone in portrait orientation (vertically), which now I need to edit to make it fit properly in a landscape (horizontal) layout. When playing it on my computer and in any of the video editors available on linux, it looks like this.
So what I want to do now, first and foremost, is rotate it 90 degrees and make it look like this.
Basically, I want the result to be as tall as the width of the original video. Optionally, I want it to be as wide as the height of the original video.
However, what I get is a video which has the same dimensions as the original, without rotation, which therefore gets letter-boxed (black bands on its sides) and has the upper and lower parts cropped, like shown in this picture.
From what I understood, I should play with profiles, however I don't seem to get it right no matter what I do.
I'm fine with letter-box, but I don't want the video cropped, and I don't want to zoom out so that the image fits by losing vertical resolution.
Any help would be appreciated.

If you don't mind using ffmpeg, you can do:
ffplay input -vf 'rotate=angle=PI/2:out_w=ih:out_h=iw'
Replace "ffplay" with "ffmpeg" to encode to an output file.
Replace "PI/2" with "-PI/2" to rotate counter clockwise.

Shotcut, a MLT-based editor has a Rotate filter with pan and zoom controls that works good for this purpose. You do not need to make a custom MLT profile (Settings > Video Mode > Custom... in Shotcut) unless you do want a portrait/tall output video resolution (which you said you don't).

I know this is an old question, but thought I'd add to it by saying.. if you ARE going to use ffmpeg then perhaps a combination of the following would bring about the (..I'm presuming) desired result.
ffmpeg -i video.mp4 -vf transpose=1 rotated.mp4
that rotates the video by 90 degrees clockwise, then,
ffmpeg -i rotated.mp4 -c:v h264 -s 1024x768 -aspect 16:9 output.mp4
this then stretches it out to the original dimensions, of course you might have to adapt the above for the file type and resolution/aspect ratio you have used.
The result might look a bit "squashed" though.

Related

generate video containing scrolling image using MLT

I want to generate a video [let's say 1920x1020] from a 1920x10000 still image.
The image has to scroll, from top to bottom as if someone was actually scrolling a page.
Found answers how to make it with ffmpeg, but i need to scroll it in mlt as i have a lot of other tasks there.
melt -profile atsc_1080p_2997 1.jpg length=300 -filter affine transition.geometry="0=0,0:100%x100%;300=0,-500:100%x100%"
This scrolls, but image is centered and i need to calculate pixels...
Is there any way to make it like with ffmpeg? (generate video containing scrolling image) (just pass needed length)
MLT does not have a similar scroll filter. The method you used is the recommended/preferred way to scroll in MLT.
...i need to calculate pixels
You can use percent instead of pixels if that helps.
You can use the filter and filter service's name is affine.

how to scale an image with gimp and save the actual scale and all the white space

there are a ton of scaling instructions for GIMP but all of them tell you to scale and save easy peasy. I feel like I'm taking crazy pills.
This is what my save or export generates:
How can I simply export a selection? Shouldn't the GIMP instructions include this detail? Sorry for ranting.
In Gimp (and some other popular image editors) the image you work on is actually made of separate images (a.ka.a layers) held together on a "canvas". The "canvas" gives the size of the final image.
There are three different ways to scale things and you have to use the right one:
The Scale tool : scales the active layer by dragging corners. Doesn't change the size of the canvas. This is probably what you used.
Layer>Scale layer: scales the active layer by providing explicit dimensions. Doesn't change the size of the canvas.
Image>Scale image: scales the whole image contents and the canvas. This is probably what you should have used.
What happened to give you the image above is that you resized the layer using the Scale tool, so you got a tiny image in the corner of the canvas, which didn't change size. The uncovered part of the canvas was displayed as a checkerboard pattern. If you exported to a format that supports transparency such as PNG or GIF the image would have been transparent, but since you exported to JPG which doesn't support transparent images Gimp replaced the transparent part by the default background color.
Everything is well explained on their website. https://www.gimp.org/tutorials/GIMP_Quickies/

Premiere Pro black bars on export

I keep getting black bars on the sides and occasionally on the top and bottom as well. I've been troubleshooting the issue for at least 4 days to no avail. I tried, cropping on export pane, different settings/aspect ratios, new sequences with different settings and Scale to Fit/Fill.
The only settings that got rid of the black bars was changing the pixel ratio to 1.0 but that made my video very blurry.
My sequence settings are same FPS 1920/1080 with matching pixel ratio of 1.0 (to the imported clips). And original clips are all 1920/1080 I don't know what their pixel ratio is but when I import them to Premiere they are all 1.0
These are the export settings
https://i.gyazo.com/af4d2459228bfaad5d86864cb1263aa3.png
From the looks of your title I'm going to assume you're uploading to YouTube? If that's so, you might try using one of the 'Presets' other than custom. If you scroll all the way down, in the preset dropdown, I remember there being options to optimise for YouTube 240/480/720/1080 and so on. This might change what you need to change.
Alternatively, I've made the mistake before of aligning my clips to the 'focus lines' rather than to the edge of the screen. Your solution may be as simple as transforming your clips bigger.
I know this is pretty late to the party. I hope you found what you were looking for.

PostGIS clipping raster with the same color band as the orignal raster

I am trying to clip a raster so that the clipped raster would have the same minimum and maximum values for the color band as the original raster.
For example if i clip the raster with this command:
create table clipped AS SELECT
ST_Clip(rast,ST_MakePolygon(ST_GeomFromText ('LINESTRING(424920
7370964,
424920 7371476,425432 7371476,425432 7370964,424920 7370964) ')) ) FROM original;
I get the following result:
So the clipped raster has band minium value as 0 and maxium value as 20. Instead of that, i want it to be exactly same as the 'original' raster: from 0 to 33.
I am new for PostGIS, but i have tried to find an answer for a while to this question but i haven't found anything. I have tried the functions like ST_Reclass but with no success. What is the proper way to do this with PostGIS?
Why is that happening?
The reason that your range changes is because your maximum value (33 in your case) is not contained within the area you clipped. This is not a bad thing, its just a fact. It's not a PostGIS thing, its just a clipping thing.
Can we find a solution?
I'm guessing that the real problem you want solved is that the two rasters look very different in QGIS. That's really easy to fix! I'll show you how with some example data.
Exmaple Data
Here's what we're starting with:
Link to image because I don't have enough rep to embed an image yet, I guess...
Double click on the "clipped" layer to open up the "Layer Properties" window and select the Style tab from the list on the left side of the window
Locate the text window for "Max" and change it to 33 to match your original raster. This picture may help. It's worth noting that you may run into a case where your Minimum is different in the clipped raster as well like it is here. You can adjust that in the same fashion.
Apply your changes and watch them work!

Font smoothing using cairo

I am trying to smooth text rendering using anti-aliasing.
But it's not anti-aliased.
First line is a png image created using pango and cairo.
Second line is just an html <span> tag. It's in firefox, Ubuntu with Gnome DE.
The difference can be better understood if you compare "W" and "v"
between two lines.
The code responsible to draw text can be found on http://pastie.org/1073683
Font options are set on lines 17 and 20 like so:
// setting up antialiasing
cairo_font_options_set_antialias(cfo, CAIRO_ANTIALIAS_GRAY);
// set the font options to cairo
cairo_set_font_options(this->cro, cfo);
Could anyone please tell me how can I make those two lines look the same?
cairo_font_options_set_antialias(cfo, CAIRO_ANTIALIAS_GRAY);
You asked for it, you got it. To get a match you'd need CAIRO_ANTIALIAS_SUBPIXEL. This is however not appropriate when you draw text to an image that might be displayed on another machine. There's no guarantee that the monitor on that machine is an LCD panel with the RGB stripes in a predictable order. Or that it in landscape orientation. Or that it is displayed with the exact original size. When there's a mismatch, the text will look quite poor.

Resources