|Things I learned about ffmpeg
||[Jul. 30th, 2013|02:55 pm]
This isn't an entry so much as a brain dump. There I things I've learned about ffmpeg and learned them more than once. That's not very smart.|
One thing is that on ubuntu (and debian) what you get when you type ffmpeg in a shell is actually avconv and a message saying that ffmpeg is deprecated. Actually ffmpeg is alive and well and still called ffmpeg - the ffmpeg codebase was forked over a spat and the two have since gone their own ways but what works for one mostly works for the other and vice versa for now.
So, for the sake of clarity, what I'm using is avconv pretending to be ffmpeg and if what I type now doesn't work for you (me) at some point in time - it's just that things may have changed or the forks could have diverged or you might be using real ffmpeg whereas I'm not.So I have a JVC Everio video camera which claims to be HD and produces AVCHD files with the extension .MTS
The claimed HD is 1080 but importing it to edit quickly revealed heavy interlacing artifacts because the actual video is not progressive but 1080i (interlaced). The other thing that became apparent was that the frame rate reported by ffmpeg when I query a video "ffmpeg -i video.MTS" is 59.96 fps but this is actually the field rate.
The pixel dimensions are 1440 x 1080 instead of 1920 x 1080 so if you just use ffmpeg to dump raw ppm (the funnest stuff to dump) then the aspect ratio is all pooched when you put it back together.
Since I wanted to do some playing about with the frame data I thought the easiest way to do it would be to pipe my video into a little filter (written in C because that seemed easiest) and then rebuilt into a modified movie. The basic methodology (and first try) was more or less:
ffmpeg ppm data to pipe -> read ppm data and output modified ppm -> from pipe ffmpeg ppm to movie which is spelled-
ffmpeg -i in.MTS -f image2pipe -vcodec ppm - | ./myfilter | ffmpeg -f image2pipe -vcodec ppm -i - out.mpg
-i in.MTS (the input file is in.MTS)
-f image2pipe (the output will be image data to a pipe)
-vcodec ppm (the format of the piped data will be a series of ppm images)
- (the output is to stdout)
| ./myfiler | (this pipes stdout to my filter and then the stdout of my filter to the stdin of the next command after the pipe '|')
-f image2pipe (the input is image data from a pipe)
-vcodec (the input is in ppm format)
-i - (the input is the stdin stream)
out.mpg (the output movie file is out.mpg)
And the result of this is twofold. The aspect ratio of the output file is squished horizontally, and the new file plays twice as long and half as fast as the input (actually a little slower than half as fast).
What happens is that the input stream is decoded to 60 frames per second and the output file is built at 25 frames per second. But, worse than that, the input file is decoded as doublets of the combined interlaced fields so that frame 1 and 2 are the same as each other, frames 3 and 4 are the same, etc. In effect 60 frames are output per second but only 30 frames are unique. Each pair of even and odd frames contains the even and odd interlaced scan lines and that looks crap.
In my filter I tried to stomp out the alternating scan lines to remove the comb effect and separate out the fields but it wasn't completely successful.. Even though the scan lines on the wheels of the little robot look like they alternate in a well behaved way, the red traffic cones have a different pattern with pairs of lines from each field being adjacent, i.e. 1&2, 3&4, 5&6, 7&8
I have no idea if this is an artifact introduced by ffmpeg or whether this is an artifact created in camera but it's very annoying.
A little googling lead me to a filter parameter which can be used to remove interlacing quite well - yadiff. In fact, and even better, if you give yadiff=1 for the filter you get de-interlaced data for each field (which means that your 60 field per second video can be converted to a 60 frame per second video with progressive scan.
So adding -vf yadif=1 to the output of the first ffmpeg 60 de-interlaced unique frames per second - good for my purposes.
|Quiet 'round here
||[Jul. 29th, 2013|05:27 pm]
I'm not much of a blogger, it seems.|
Oh, I type copious verbiage and I'm sufficiently opinionated, but I just don't do it 'round here ... (hears Counting Crows in head)
Nope. I do most of my ranting at whyzzat.com
Guess I need the stimulus of other voices to get me worked up.
||[Oct. 31st, 2012|12:25 am]
in response to a friend who forwarded me this link: http://www.theglobeandmail.com/news/politics/michael-ignatieffs-timely-warning-on-the-politics-of-fascism/article4753299/|
so I gave the article a read and I still think he's a smart and decent guy but that is why he got raped. They are noble words but they come across, to me, as sad as the words of a gentleman who walks into a pub brawl and thinks that Marquees of Queensbury rules were handed down by God, inviolable and sacrosanct and after receiving a brutal headbutt to the nose and a broken bottle in the family jewels ends up sprawled in his own blood mumbling "jolly unsporting old chap".
He approached politics as having something to do with governance and compromise but found himself in the pen with some thugs and dirty scrappers who didn't care about the rules. He recognizes how the system is but he can only advocate "ought" and there is precious little practical plan to bring about ought but to appeal to everyone to "do the right thing". I am reminded of a joke in which Genghis Khan comes across some peasants and decides to take the opportunity to exercise his sword arm. He has all the peasants kneel in a line and starts going down the row chopping heads off one by one. One of the peasants says to one next to him - "we should defend ourselves, we must fight back" to which his neighbour responds - "shhhh. You will make him angry".
The fact is that a small well armed band of radicals can make the majority kowtow. But a weak opposition is effectively a servile opposition. If one side is at war then the other side cannot stand about trying to be reasonable. The fact is that we don't have the system that Iggy thinks we ought to have, we have the system that we DO have and the opposition that we elect has to make war with those that war against them. There is a perceived danger that once the good guys have won they won't dial back on the war but war is expensive and it tends to end as soon as the need passes. Europe tried appeasing Hitler (mostly because England was in no position to start any wars at that time) but eventually Hitler was only pushed back when his war was answered by war.
Now that covers only Parliament (and the Provincial Legislators). The elected opposition in those places need to fight hard and look like they are fighting hard. But theirs is a very difficult position because they often feel like they don't have a mandate to fight that hard and they are many small pockets of resistance fighting against a unified enemy. The radicals in the House of Commons and the radicals in the Provincial legislatures are coordinated by the same people who coordinate the tone of the news and who fund the right wing think tanks that produce the arguments and "data" that support the kinds of legislation that the monied interests write and hand to the various governments to pass. The largest umbrella group that I know of doing that is ALEC.
I realize that Iggy was pointing a finger southward but all that is happening down there has been field tested in South America, Maggie's England, and in state and provincial legislatures in North America and even at Vancouver City Hall under Mayor Gordon Muir Campbell, who started his rightward lurch with cessation of open town-hall meetings. The first thing power does when it's about to turn on the people is go quiet - operate in secrecy - practice press discipline.
It may be that Parliament is a lost cause. It may be that the nature of politics means that politicians cannot speak truth to power. Those who speak their conscience are quickly hounded out of the system or are compromised (aren't they, Iggy?). It may just be that the rest of us, the people of North America need to start viewing our government as the enemy and not allow them to hold on to even a loin cloth of legitimacy. Now I'm not proposing that we engage in a shooting war because those sort of things can usually only be done with outside help and arms - plus they tend to be a cure worse than the problem and exactly the wrong kinds of people rise to the top in those environments. No, we need something more Gandhi in style. It will mean people being willing to get beaten by the enforcers and spend time in holding pens and court rooms and jails and it will require distribution and political working groups and alliances and new paradigms and models - something like the Occupy movement - or maybe exactly the Occupy movement. It will take more people making more decisions and agreements about the kinds of neighbourhoods and cities and provinces and countries we want to live in and once enough dedicated and talented and social minded people have been schooled in that sort of work then we can start cleaning all the legislative houses positively and peacefully.
Of course, power never cedes easily.
in Friendship, Love and Truth,
|I just wrote another email to a politician
||[Oct. 4th, 2012|10:09 am]
With header and footer stripped - here it is:
It has been a while since I wrote on the matter of Syria and I hate having to do it because I always feel that I will be construed as an Assad apologist and I truly have no love for the man but still the situation of the people in Syria becomes worse because we (France and the US principally but also Canada others) continue to push for war. Some call me cynical for saying that and yet every action we and our allies take move us closer to that eventuality. It is like watching a bully instigate a bar fight by a thousand provocations and each time blaming the victim if they respond - or don't.
Human Rights Watch rightly criticizes the Assad regime and we pay attention but when Human Rights Watch tells us that the rebels torture and execute Syrian civilians we are deaf to it. When a Syrian bomb falls in a civilian area we are properly appalled but when a rebel truck bomb wrecks a hospital or a suicide bomber kills a crowd of people in a market we shake our heads and say "stuff happens in a war". If rebels in Canada were behaving as these rebels are behaving we would correctly know them as terrorists. The terrorism has been of such a scale that even the media has been unable to ignore it though they fail to call it that.
We have failed to call for the rebels to stop striking civilian targets and we have failed to blame the rebels for fighting in civilian areas - something that, had they not been western sanctioned terrorists we would have castigated them for saying that they hide behind "human shields".
We have failed to act as honest brokers. We continue to encourage the armed factions who, German Intelligence seem to have recently admitted, are composed largely of foreign fighters and Al Qaeda affiliates (as was the case also in Libya).
Now Turkey has been given the opportunity to escalate the situation which they have gleefully taken and seem keen to leverage further and we have said we will back them on that. Though it is clearly insane for Assad to deliberately involve Turkey by deliberately targeting Turkish civilians this is precisely the narrative we choose to pursue. Whether it was a deliberate calculated attack by Assad forces or an attack instigated by a defecting general or an attack by rebels with captured weapons the whole episode deserves to be approached with caution until we understand it and then brought to an international body for adjudication and resolution.
At least Baird recognizes this in public statements: "We obviously recognize that every country has a right to defend itself. I think we do have to appeal for calm, to not let this situation escalate out of control," - though I note that he does not extend the right to self defence to the government of Syria with respect to our proxy fighters within its borders.
I believe that Turkey would love to see this escalate out of control as they believe they can count on NATO to step in if they can provoke further attacks - I believe that NATO is eager to step in to help Turkey if they can provoke a Syrian response and I believe that Canada will happily supply pilots and other of our resources to help in destroying the wealth, history and people of yet another strategically important bit of land.
I am truly sick of these games that kill. If we wanted to change the world for the better we would push for slow peaceful changes and grow a better, safer world organically but we are ruled by impatient greedy people who use the organs of state (including the elected representatives, I am sorry to say, albeit without their knowledge) to benefit their business interests.
I know from talking to colleagues about world realpolitik that it takes more than a few desperate emails to change a person's mind - why would someone want to believe that the world was the way it is when nice moral fairy tales of good vs evil are so much more comforting? Why would a sane person wish to acknowledge their own part in a system which is so obviously at odds with their own morals?
Wars, in retrospect, when looked at with a dispassionate eye, make much more sense as struggles for territory and resources (whether that is oil, sugar cane, rubber, or human workers) than as morality fables. The older the war the plainer we see it. We can be more honest about history because all of the people involved are now dead but history isn't dead. We continue to make history today, even this moment, but we can't see it yet. All the forces of history are still acting today and the causes of our conflicts remain the same as do our methods for starting and escalating them.
Yours, with increasing disquiet,
|Speaking of Twenty Years ago
||[Jul. 17th, 2012|05:56 pm]
I finally got around to plugging my video encoder into my VHS player and played some old tapes through there.|
These two gems are from that aforementioned time - back twenty years ago. It's not such a long time ago but it's a very different time. Back then Jian Ghomeshi wasn't doing Q, he was singing about the Gulf War (the first one, with the first Bush) and about Green Eggs and Ham - and I? I was doing stuff like this:
|So I'm just sitting here when twenty years go by
||[Jun. 1st, 2012|11:14 am]
I'm taking some time off work - because I have to. I also should but I'm doing mostly because the company has decreed that we can't all just sit around building up our holiday time. So I have a week to catch up on all of those things I've been putting aside and so far I have not managed to catch up at all. I have, however, started several new things that will eat up time. I'm quickly finding out how busy I was when I was unemployed. Even without the giant sinkhole of "work" there isn't enough time to do all of the things I want to do.|
So what am I doing right now? Just sitting in Continental Coffee on the Drive, typing words that only I will read - me and google and the NSA, but other than that, only me - when all of a sudden this old guy walks past the window and I know his name is Brian. In a moment he has passed by but he's old and that means that I must be too because we're about the same age. How strange.
And now I am looking out of the window and I see, in a car that has just pulled up outside the coffee shop, a woman who I had coffee next to yesterday on the other side of town. Is there a coffee shop circuit that I'm unwittingly a part of? I'd ponder upon it but I have to go in a moment to meet someone down the street.
|I'm hardly a conscientious blogger
||[Oct. 8th, 2011|05:24 pm]
I hardly write a thing. Maybe because no-one reads anything here and though I intended to put more here I end up writing it on paper and in notebooks more - or I hang out at a forum called whyzzat.com that is populated by netizens I've mostly known for over a decade.|
Oh, and there's my youtube channel, of course, which takes up far too much time - and life in general which is also somehow never able to render up an idle hour. If I had an idle hour it would be full already and hence not idle - because even if I can't manage any of the other billion things on my list there is always more reading to be done, stacks of material to catch up on.
I wish sometimes that I would be able to take a break and just tell myself I know enough already and I should just try to take some time to do something with all that knowledge - but I have so much more ignorance than knowledge and ignorance seems to grow at an exponential rate.
That reminds me, there are a couple of things I need to go look up so I'm just going to go do that now.
||[Jul. 17th, 2011|07:43 am]
Excuse my excitement but ... Rebekah Brooks has been arrested!!|
Who knows what will happen next - maybe nothing - but at least some light is being shone on some nasty people - if the gangrene has progressed far enough then perhaps the whole rotten body will burst open and spill its guts.
|Murdoch takes a hit
||[Jul. 11th, 2011|05:36 pm]
Oh boy, dammit, yes - it looks like Murdoch's engine is on fire and he's going down - spiralling to the ground and I just hope his canopy sticks.|
Telegraph's live blog
Including such gems as:
15.56 Extraordinary new allegations from The Guardian's Nick Davies on the Gordon Brown hacking. Among the details, not only were Mr Brown's Abbey National bank details accessed - a "blagger" posed as Brown six times, according to the bank - but his lawyers, Allen & Overy, were tricked into handing over details from his file. And, perhaps most shockingly, details of the medical history of their son James Fraser, who suffers from cystic fibrosis, were obtained.
In another, huge, twist, it was not the News of the World who was behind these alleged intrusions. The bank details and the legal file were apparently obtained by The Sunday Times, while it seems thatJames's medical records were obtained by The Sun, who then published a story about his condition.
Yes, that says Gordon Brown's bank info and the medical records of his son were hacked. And yes, it says it was by other Murdoch papers than News of the World. It's his whole dirty business - half propaganda machine, half spy agency. The strings lead right from the politicians to the puppeteer.
11.23 Ed Miliband has added his voice to that of Nick Clegg for Rupert Murdoch to drop his BSkyB bid, calling it "completely untenable", and said that Rebekah Brooks should "take responsibility" and resign, and Mr Murdoch should accept it. "And of course he should apologise", he adds.
I'd love to see this TV deal evaporate and even have Murdoch sued in the US and lose licenses there too. Doubtless he will fight, he is ruthless and headstrong but he may have received a mortal wound and at his age he may just not have it in him.