Shallow Thoughts : tags : video

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Tue, 08 Aug 2023

Triaging Videos Using VLC's Python Bindings

[Screenshot of video triage program] A few days ago I wrote about finding a way to triage videos by adding captions to mplayer. Better than nothing, but I really wanted something like pho or MetaPho where I could add the tags in the program itself, rather than keeping notes on a piece of paper.

Turns out it wasn't that hard using VLC's Python bindings.

Read more ...

Tags: ,
[ 13:18 Aug 08, 2023    More linux | permalink to this entry | ]

Fri, 04 Aug 2023

Triaging Videos by Adding Captions to Mplayer

I've recently hit a wall that I'd been avoiding: how to triage a bunch of new videos and decide which ones are worth keeping.

For still photos, I do that with my Pho program if I just want to make yes or no decisions, or maybe mark two or three categories. When the time comes for real tagging — which images have sunsets, which have bicycles, which have coyotes and so on — I use my MetaPho. I take a lot of photos, so efficient triaging and tagging is important to me.

But what about videos?

Read more ...

Tags: ,
[ 20:23 Aug 04, 2023    More linux | permalink to this entry | ]

Tue, 15 Nov 2022

Action Camera Comparison Videos for Mountain Biking

I've long been wanting an "action camera" to shoot mountain biking, and maybe R/C plane, videos.

[Akaso V50x on handlebars] Last week I ordered an Akaso V50x. Everybody seems to agree that Akaso offers the best bang-for-the-buck, but choosing among Akaso's large and varied collection of models isn't easy, especially since there aren't many comparisons between the V50 line and the Brave line. The V50x was well-liked by most reviewers, and gets high praise for its digital stabilization ("6-axis", which apparently means three axes of translation plus three gyro-driven rotation axes).

I worried, though, that all the sample V50X videos I found on YouTube were severely underexposed, and I had written it off my list until I stumbled upon a review that listed all the V50x Settings options and I learned it offers exposure compensation (which it calls "Exposure value").

In the few days I've had the Akaso I've been fairly impressed. The stabilization is indeed very good — if anything, it's almost too good,

Read more ...

Tags: , ,
[ 17:46 Nov 15, 2022    More photo | permalink to this entry | ]

Fri, 14 Aug 2020

V is for Video Editing with Shotcut

I have a new camera, a Sony a6100. Frustrated with the bugs and limitations of my ancient Rebel XSi, I decided to jump into the world of mirrorless cameras.

So far I'm pleased with it (though sometimes frustrated by its Byzantine menu hierarchy). One of its nice features, which the Rebel didn't have at all, is movies, and I've been shooting a lot of short movies of radio controlled airplanes when we fly at Overlook Park.

That's the problem: a lot of short movies. I'd like to make them available on YouTube so that my fellow pilots can see them; but uploading a movie to YouTube is a low and elaborate process, and uploading eight or so short clips of less than a minute each is just too much work. It would be so much easier if I could edit them together and upload just one movie.

Time to learn some basic video editing.

Read more ...

Tags: ,
[ 16:02 Aug 14, 2020    More linux | permalink to this entry | ]

Mon, 20 Jul 2020

R is for Recording Zoom (or other video conferencing) Talks

Giving talks has certainly changed a lot since last year. All those skills we practice in Toastmasters -- using the space, expressive gestures, projecting your voice, making eye contact with all sections of the audience? Meaningless now. In an age of quarantine and video conferencing meetings, speakers need to learn new skills.

Fortunately, there's Toastmasters for a painless, fun way to practice.

I was scheduled to give a talk on browser privacy. My local LWV has a Privacy Study Group that I'm co-chairing, and we had a meeting coming up on privacy while browsing the web. I knew I wanted to show a series of demos in multiple browsers, including additional windows like the Developer Tools window. I also wanted to record the talk so I could upload it later.

In Zoom, the process of canceling a shared window and then starting another share is slow, fumbly and error-prone. I knew this was something I needed to practice before the talk, to find a way to smooth the transitions..

Read more ...

Tags: , , ,
[ 16:35 Jul 20, 2020    More speaking | permalink to this entry | ]

Fri, 11 May 2018

Making Videos (that work in Firefox) from a Series of Images

I was working on a weather project to make animated maps of the jet stream. Getting and plotting wind data is a much longer article (coming soon), but once I had all the images plotted, I wanted to combine them all into a time-lapse video showing how the jet stream moves.

Like most projects, it's simple once you find the right recipe. If your images are named outdir/filename00.png, outdir/filename01.png, outdir/filename02.png and so on, you can turn them into an MPEG4 video with ffmpeg:

ffmpeg -i outdir/filename%2d.png -filter:v "setpts=6.0*PTS" -pix_fmt yuv420p jetstream.mp4

%02d, for non-programmers, just means a 2-digit decimal integer with leading zeros, If the filenames just use 1, 2, 3, ... 10, 11 without leading zeros, use %2d instead; if they have three digits, use %03d or %3d, and so on.

Update: If your first photo isn't numbered 00, you can set a -start_number — but it must come before the -i and filename template. For instance:

ffmpeg -start_number 17 --i outdir/filename%2d.png -filter:v "setpts=6.0*PTS" -pix_fmt yuv420p jetstream.mp4

That "setpts=6.0*PTS" controls the speed of the playback, by adding or removing frames. PTS stands for "Presentation TimeStamps", which apparently is a measure of how far along a frame is in the file; setpts=6.0*PTS means for each frame, figure out how far it would have been in the file (PTS) and multiply that by 6. So if a frame would normally have been at timestamp 10 seconds, now it will be at 60 seconds, and the video will be six times longer and six times slower. And yes, you can also use values less than one to speed a video up. You can also change a video's playback speed by changing the frame rate, either with the -r option, e.g. -r 30, or with the fps filter, filter:v fps=30. The default frame rate is 25.

You can examine values like the frame rate, number of frames and duration of a video file with: ffprobe -select_streams v -show_streams filename or with the mediainfo program (not part of ffmpeg).

The -pix_fmt yuv420p turned out to be the tricky part. The recipes I found online didn't include that part, but without it, Firefox claims "Video can't be played because the file is corrupt", even though most other browsers can play it just fine. If you open Firefox's web console and reload, it offers the additional information "Details: mozilla::SupportChecker::AddMediaFormatChecker(const mozilla::TrackInfo&)::<lambda()>: Decoder may not have the capability to handle the requested video format with YUV444 chroma subsampling.":

Adding -pix_fmt yuv420p cured the problem and made the video compatible with Firefox, though at first I had problems with ffmpeg complaining "height not divisible by 2 (1980x1113)" (even though the height of the images was in fact divisible by 2). I'm not sure what was wrong; later ffmpeg stopped giving me that error message and converted the video. It may depend on where in the ffmpeg command you put the pix_fmt flag or what other flags are present. ffmpeg arguments are a mystery to me.

Of course, if you're only making something to be uploaded to youtube, the Firefox limitation probably doesn't matter and you may not need the -pix_fmt yuv420p argument.

Animated GIFs

Making an animated GIF is easier. You can use ImageMagick's convert:

convert -delay 30 -loop 0 *.png jetstream.gif
The GIF will be a lot larger, though. For my initial test of thirty 1000 x 500 images, the MP4 was 760K while the GIF was 4.2M.

Tags: , , ,
[ 09:59 May 11, 2018    More linux | permalink to this entry | ]

Sun, 30 May 2010

Kdenlive part 2: adding transitions, sounds and titles to your movies

I've been so busy with Libre Graphics Meeting -- a whirlwind of GIMP caucuses, open source graphics, free art and sharing of ideas -- that I forgot to notice that part 2 of my kdenlive article was up on Linux Planet.

Making Movies in Linux with Kdenlive, part 2: Spice up Those Kdenlive Videos.

Tags: , ,
[ 03:45 May 30, 2010    More writing | permalink to this entry | ]

Thu, 13 May 2010

Kdenlive -- the easy way to make movies

A couple of weeks ago, I shot a lot of short video clips with my digital camera at an indoor fun fly (in the intervals when I wasn't crashing around with the other crazy pilots).

But then ... what to do with a bunch of disconnected video clips? I've uploaded short clips to youtube before, but never extracted the good parts and edited them together. And most video editing programs look pretty complex.

The answer turned out to be kdenlive, which was surprisingly easy to use -- once I got past one initial bug. So I wrote up the details. Part I, covering the basics of how to get started and combine clips, is on Linux Planet: Making Movies in Linux with Kdenlive.

Watch for part II in a couple of weeks, where I'll cover transition effects, music and titles.

Tags: , ,
[ 19:25 May 13, 2010    More writing | permalink to this entry | ]

Fri, 05 Mar 2010

Adding video to an OpenOffice Impress presentation

(and how to convert MPEG video to animated GIF)

I gave an Ignite talk this week at Ignite Silicon Valley. It was a great event! Lots of entertaining talks about all sorts of topics.

I'd always wanted to do an Ignite speech. I always suspected the kicker would be format: O'Reilly's guidelines specified PowerPoint format.

Of course, as a Linux user, my only option for creating PowerPoint slides is OpenOffice. Historically, OpenOffice and I haven't gotten along very well, and this slide show was no exception. Happily, Ignite needs only 20 slides ... how hard can that be, right? Most of my slides were very simple (a few words, or one picture), with one exception: I had one simulation I wanted to show as a video. (When I give this presentation on my own machine, I run the simulation live, but that's not an option on someone else's machine.

Impress woes

First I wrestled with Open Office to create the non-animated slides. It was harder than I'd expected. I just loved having to go back and un-capitalize words that OO kept helpfully re-capitalizing for me. And the way it wouldn't let me change text format on any word that triggered the spellchecker, because it needed to show me the spellcheck context menu instead. And the guessing game clicking around trying to find a place where OO would let me drag to move the text to somewhere where it was approximately centered.

And when I finally thought I had everything, I saved as .ppt, re-loaded and discovered that it had lost all my formatting, so instead of yellow 96 point centered text I had white 14-point left-aligned, and I had to go in and select the text on each slide and change three or four properties on each one.

And I couldn't use it for an actual presentation. In slideshow mode, it only showed the first slide about one time out of six. The other times, it showed a blank slide for the first 15 seconds before auto-advancing to the second one. The auto-advance timing was off anyway (see below). Fortunately, I didn't need use OpenOffice for this presentation; I only needed it to create the PPT file. I ended up making a separate version of the slides in HTML to practice with.

Inserting a movie

But I did eventually have all my static slides ready. It was time to insert my movie, which I had converted to MPEG1 on the theory that it works everywhere. With the mpeg added, I saved one copy to OpenOffice's native format of .odp, plus the .ppt copy I would need for the actual presentation.

Then I quit and opened the .ppt -- and the video slide was blank. A bit of searching revealed that this was a long-known issue, bug 90272, but there seems to be no interest in fixing it. So I was out of luck if I wanted to attach an MPEG, unless I could find someone with a real copy of PowerPoint.

Plan B: Animated GIF

Next idea: convert my 15-second video to an animated GIF. But how to do that? Google found me quite a few web pages that claimed to give the recipe, but they all led to the same error message: ERROR: gif only handles the rgb24 pixel format. Use -pix_fmt rgb24.

So what? Just add -pix_fmt rgb24 to the commandline, right? But the trick turns out to be where to add it, since ffmpeg turns out to be highly picky about its argument order. Here's the working formula to convert a movie to animated GIF:

$ ffmpeg -i foo.mpeg -pix_fmt rgb24 foo.gif

This produced a huge file, though, and it didn't really need to be 1024x768, so I scaled it down with ImageMagick:

convert -depth 8 -scale 800x600 flock-mpeg.gif flock-mpeg-800.gif
which brought the file size from 278M down to a much more reasonable 1.9M.

Happily, OpenOffice does seem to be able to import and save animated GIFs, even to .ppt format. It has trouble displaying them -- that's bug 90272 -- so you wouldn't want to use this format for a presentation you were actually going to give in OpenOffice. But as I mentioned, OpenOffice was already out for that.

If you do this, make sure all your static slides are finished first. Once I loaded the animated GIF, OpenOffice slowed to a crawl and it was hard to do anything at all. Moving text on a slide turned into an ordeal of "hover the mouse where you think a move cursor might show up, and wait 45 seconds ... cursor change? No? Okay, move a few pixels and wait again." Nothing happened in real time. A single mouse click wouldn't register for 30 seconds or more. And this was on my fast dual-core desktop with 4G RAM; I don't even want to think what it would be like on my laptop. I don't know if OOo is running the animations continuously, or what -- but be sure you have everything else finished before you load any animations.

The moment of truth

I never found out whether my presentation worked in real Microsoft Powerpoint. As it turned out, at the real event, the display machine was a Mac running Keynote. Keynote was able to import the .ppt from OpenOffice, and to display the animation. Whew!

One curiosity about the display: the 15 seconds per slide auto-advance failed on the animated slide. The slide showed for 30 seconds rather than 15. I had written this off as another OpenOffice bug, so I wasn't prepared when Keynote did the same thing in the live presentation, and I had to extemporize for 15 seconds.

My theory, thinking about it afterward, is that the presentation programs don't start the counter until the animation has finished playing. So for an Ignite presentation, you might need to set the animation to play for exactly 15 seconds, then set that slide to advance after 0 seconds. If that's even possible.

Or just use HTML. The great irony of this whole story is that some of the other presenters used their own laptops, so I probably could have used my HTML version (which had none of these problems) had I asked. I will definitely remember that for the next Ignite! Meanwhile, I suppose it's good for me to try OO Impress every few years and remind myself why I avoid it the rest of the time.

Tags: , , , ,
[ 16:36 Mar 05, 2010    More speaking | permalink to this entry | ]

Tue, 12 May 2009

Making desktop recordings with recordmydesktop

Apress asked me to make some short screencast videos illustrating GIMP tips, to help advertise the second edition of Beginning GIMP.

I've never made videos (except for putting a digital camera in video mode) so it's been an interesting learning experience, and I was surprised at how easy it was in the end.

My Apress contact suggested XVidCap and Wink as possible options. XVidCap looked quite interesting but didn't seem to work in its Ubuntu incarnation. Wink worked very nicely and produced flash videos that worked in a browser with no extra fiddling ... but unfortunately when I tried plugging in a microphone, Wink didn't seem able to read it. And it seemed to slow down all my cursor movements, rather than following my actions in real-time.

But while working with those two, I stumbled across recordmydesktop. It records mouse movements in real-time and it handles the microphone too. It has several front ends available (such as gtk-recordmydesktop) but I found the basic command-line version easiest to use.

To make a video in the upper left 1024x768 section of my screen:
recordmydesktop -width 1024 -height 768 -o layermask.ogv

Since I need to make sure all the action happens within that rectangle, I made a special desktop background that has a nice, not too distracting image in just that 1024x768 rectangle. Any other windows I'm using in that desktop (such the terminal window I'm using to control recordmydesktop) stay outside that area.

recordmydesktop starts recording right away. I run through my tutorial steps, narrating as I go, and when I'm done, I move the mouse back to the terminal window where I started the recording and hit Ctrl-C, and recordmydesktop stops recording and encodes the video (which takes a while).

It saves to ogg format, .ogv. Of course, most web surfers can't view that, and youtube doesn't accept it either (at least, ogg isn't on its list of allowed formats) so I needed to translate it into something else. Youtube suggests mpeg4, so that's what I used. Luckily, I already had a mencoder incantation that some helpful person gave me a long time ago:
mencoder movie.ogv -oac pcm -ovc lavc -lavcopts vcodec=mpeg4:vqmin=2:vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01:vhq -o movie.mp4

Only one problem: the audio came out very faint and difficult to hear. I'm sure that's a problem with the microphone I'm using, a cheap OEM model that came with some computer or other many years ago -- it's been sitting in a box since I normally have no use for a microphone. But it turns out mencoder can amplify the volume, with -af volume=X where X is decibels. A little experimentation with mplayer -af volume=X on the original ogg suggested a value around 15 or 20, so the final encoding was:
mencoder movie.ogv -af volume=19 -oac pcm -ovc lavc -lavcopts vcodec=mpeg4:vqmin=2:vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01:vhq -o movie.mp4

But Apress tells me that their Windows boxen had trouble with the mp4 and they had to run it through something called "Handbrake", so maybe some other format would have worked better. Here are two other mencoder incantations I know (without the sound amplification):
mencoder movie.ogv -oac pcm -ovc lavc -o movie.divx (divx -- Windows sometimes has trouble with this too)
mencoder movie.ogv -oac pcm -ovc lavc -lavcopts vcodec=mpeg1video -o movie.mpeg (mpeg1)

It's not great cinema, but the end result is up on the Apress page for the GIMP book.

Tags: , ,
[ 11:14 May 12, 2009    More linux | permalink to this entry | ]

Tue, 07 Dec 2004

Video Formats

Something to do while sick, when I couldn't stand lying in bed reading any more ...

A few of us got to talking about video formats and our confusion about which formats were which, which ones were open, and so forth. I've never found a web document that really explains that clearly, but since I wasn't up to going anywhere or doing anything hard, I spent some quality time with google and wrote up my findings: Digital Video Formats.

It's still very rough, but at least it tries to make clear what's a codec vs. what's a container, and how to identify the container and codec used in a particular file. And it's a good place to store a few references that I found useful.

Tags: ,
[ 23:05 Dec 07, 2004    More linux | permalink to this entry | ]