a little bit of everything

Category: Blender

Annotating video and sound with Blender

What is Blender

People who know me know I love Blender. Some people don’t know what is Blender though. It was conceived first as a 3D modelling and animation tool but you can do a lot of things with it, such as video editing (which includes sound).

Video editing
Animation
3D and 2D modelling

Blender runs in all OS, Linux, Mac, Windows. you can download it here.

Annotating

If you have video or sound to annotate, although Blender is a very powerful tool, it’s maybe overwhelming at first sight. So I will show you in few easy steps how to annotate and export annotations.

In case you didn’t know, video and sound have frequencies and speeds. Things like 24 frames per second or 24000Hz, think about this when you edit or annotate video.

First open blender and select video edition, either in File > new > video editing. Or in the splash screen

Once you see the main workflow window for video editing simply drag your video or your sound into Blender, or open it from the file explorer on the side. Video is the blue channel, sound is green.

Annotations can be added with text effect strips. You can modify the text in the right hand menu.

If for some reason the menu is not there, hover over the sequencer section and press "N".

If your sequencer view is too narrow, zoom in with the mouse wheel. You can drag the darker sides of the annotation or move it around to make it as long as you need.

Remember to save continuously with ctrl+s or in file > save.

Export annotations

Blender has a built in text editor and code console. It uses python and has a python API called BPY. You can open a console in any location within Blender. Let me tell you how.

Blender can have many sub windows in which you can customize your workflow, such as in the first images I showed you. You can create any number of such windows by dragging any top right corner of a subwindow.

Open a text window, create a new text and add this code:

import bpy

f = open('filetosave.txt', 'w')

fstarts=[]
texts=[]

for i in bpy.data.scenes["Scene"].sequence_editor.sequences_all:
    if type(i) is bpy.types.TextSequence:
        print(i.text)
        texts.append(i.text)
        fstarts.append(i.frame_start)

fstarts, texts = zip(*sorted(zip(fstarts, texts)))

for i in zip(fstarts,texts):
    print(i)
    f.write(f'{i[0]}:{i[1]}\n")
        
f.close()

And this way you can export to a txt, all your annotations and the frame in which they occur.

But the frame is not the time. so you can modify to code to print the time instead by dividing by the fps of your video. If your fps is 24, then 240 frames are 10 seconds.

You can see your fps here:

Blender API

You can see in the code the kind of things you can get from your text strips, see more here: https://docs.blender.org/api/current/bpy.types.Sequence.html#bpy.types.Sequence

In this case, everything, video, sound, image, effect, is a sequence.

Annotating with images

You can add anything you want in the sequencer, images, sound and more video. Just drag it in move it around, expand it to cover the area you like and voilà. Use the menus to the right to modify aspects about this image like size, shape rotation location within the video.

Recreate your city in 3D with Blender

In one of my personal projects I wanted to see Uppsala, the city I live in, in 3D. Those who know me know I am a Blenderhead, a Blender die hard fan for reasons I will discuss at some time. But now, how can yo do it by yourself with your own city?

Warning, I actually had to remodel the Cathedral

This was really hard to find, specially open, but I love open stuff and there is OpenStreetmap where you can export an OSM (openstreetmap) file which is some sort of XML file with a lot of information, including where trees and buildings are.

To export a place go to OpenStreetMap and explore, then click export and you will get the longitude and latitude borders of your area. If the area is to big you will have a very big file! obviously! so be careful.

After you get your OSM file you need to convert it to something to open on Blender.

Some german hero created a software called osm2world that can convert OSM to OBJ which is a format that Blender can open. I found it a tad difficult to use but it’s amazing that it has java executables for any operative system, mine is Linux (obviously).

I run it in a console using

java -Xmx2G -jar OSM2World.jar -i input.osm -o output.obj

And it’s as easy as that now you have an OBJ that you can open in Blender like this:

But of course it is not all puppies and rainbows, buildings might not be perfectly modeled and color can be lost, and there is a clutter of things that I didn’t want to see, I don’t care about little benches or traffic lights and many more things that were not correctly placed, not correctly modeled and don’t really add much since I won’t be visiting with that level of detail. I just wanted a panoramic view.

So how do you get rid of all these things? depending on how big of an area you exported, you might get different amount of things, maybe you don’t need to clean. But I did and I will show you how and if you want to do it too, I will give you my code.

What is OBJ

Wavefront .OBJ is a way to save meshes (vertices, edges, faces and color) in plain text, you can open it in a text editor and see what is inside. You can group vertices and edges and name these groups as something recognizable, that you could delete. But given the organization of the file you can’t just delete the text you have to rearrange all the vertices and edges and faces which was an absolute nightmare for me.

Wonderful people who believe in open source create software every now and then that can do things like this, but sometimes they are overkill for a small task, sometimes they don’t work as you intended and I am all up for programming my own things, be them complex or simple. So I made a script that finds all objects, removes all the undesired objects by name and then rearranges all the vertices again and produces a clean OBJ to import in Blender. Mind you, it’s not perfect and could be better but it worked for my purposes so that’s the end of it. You can find the code here.

So now can I see my city please? Yes sure, here it is, ugly buildings and all.

This is NOT what the Uppsala Cathedral looks like

Playing with Blender and architecture

I will not be teaching you Blender here but if you invite me a coffee I might tell you about it. How ever if you are not seeing all your city it might be that you need to expand your view in Blender if the city is too big you can do this in a menu that appears pressing N or by dragging a little cross in the upper right side of the viewport, here you can select to clip the view at a larger distance.

So to model the cathedral (which was a hard task) I wanted to find real blueprints of the building and it was tough because I had to do ti in swedish (which I do not yet master) but a friend helped me by giving me some tips. She works in digital humanities so she knows her stuff.

She told me to search in ALVIN which is a platform for digital collections and digitized cultural heritage. I searched in Alvin and in google for the words

Uppsala domkyrka, domkyrkoarkitekt, ritning, planritning

And eventually found some good examples:

References for modelling the Domkyrka

So my recommendation becomes to know where to search for blueprints and historical archives and speak the language of where you are searching history from.

Anyways, I played with the depth of field with the f-stop the focal length and placing the camera around and with a simple white material on everything I made these two things.

Powered by WordPress & Theme by Anders Norén