Computer Graphics, Linux and Everything…

Author Archive

Encoding H.264/AVC videos for PS3 using ffmpeg

by flord on Oct.26, 2009, under Everything

OK, I’m tired of loading up my script just to see what’s the command line to encode AVC videos for the PS3 so I’m posting it here. This way It’ll be quicker for me to come see it here.

The PS3 doesn’t play Quicktime files. It much prefers mp4, which is an open standard (not to be confused with open source). The best and fastest way I’ve found to encode mp4 files is with ffmpeg. Yes, it’s command line but it’s easy enough to remember the basic syntax rapidly.

The syntax has several blocks, depending on what you need, all blocks may not be required.

ffmpeg
-r 23.98
-i FrameSequence.%04d.jpg
-i Sound.wav
-vcodec libx264 -acodec libfaac
-b 35M -ab 224k
-mbd rd -flags 4mv,trell,aic,qprd,mv0,loop -cmp 2 -subcmp 2 -flags2 dct8x8+skiprd -level 41 -bf 3 -qmin 10
-threads 0
OutputFile.mp4

Let’s look at this in details.
It begins with the executable (duh)
ffmpeg

Then you must set the frame rate only if you’re loading a sequence of frames. BTW, it only reads jpeg and png files, and it must begin at 0 or 1.
-r 23.98

The input files, several if your audio is separated from the video.
-i FrameSequence.%04d.jpg
-i Sound.wav

The formats, determined by the codecs. AVC for Video and AAC for audio.
-vcodec libx264 -acodec libfaac

The bit rates. I use 35Mbit/s for 1080p, 15 for 720p and 5 for SD.
-b 35M -ab 224k

This line must be entered as is. It set the encoding parameters the PS3 requires.
-mbd rd -flags 4mv,trell,aic,qprd,mv0,loop -cmp 2 -subcmp 2 -flags2 dct8x8+skiprd -level 41 -bf 3 -qmin 10

This will force ffmpeg to use all the cores on your machines, potentially speeding up the conversion considerably.
-threads 0

And the output file, with the mp4 extention.
OutputFile.mp4

This command works for ffmpeg 0.5 and probably later. You can find ffmpeg for Windows here.
Thanks to this site for providing the original syntax. I added the -qmin 10 part because libx264 was acting weird without it.

It is important to know that if you’re encoding a video you have made using computer softwares, your video might look a bit too contrasted. Blacks might be too black and whites too white. This is because pixel values on your computer range from 0 to 255, and on your TV they range from 16 to 235. Any pixel that has a value below 16 in your movie will appear as black on your TV. To correct this, you must compress the colors of all the frames in your movie to make sure the darkest thing is set above 16 and the brightest thing is below 235. Then it will show up correctly on your TV when played with the PS3. There is a setting in the PS3 to avoid this, but your TV must be compatible, and not all TVs are compatible, far from it.

Leave a Comment :, , more...

First Attempt at Shooting Stars Timelapse

by flord on Aug.15, 2009, under Photography

I finally got a chance to shoot a timelapse of the stars at my father’s country house this week. And to make things even better, it was August 12th… the shooting stars night. I learned a few things this night.

  1. To make a starfield timelapse, it must be dark, very dark. The tinyest light pollution from a nearby village will be amplified by the long exposures and be visible in the shot.
  2. To make a starfield timelapse, it must be dry. On the banks of the St-Lawrence river, in August, the moisture condenses on the lens and you are lucky to get 50 frames before it happens.
  3. To make a starfield timelapse, you must use a camera that has as little dead pixels as possible. Mine is getting old (Canon Rebel XT) and I discovered it has many, many dead pixels.
  4. To make a starfield timelapse, 1 minutes exposure per frame is good, but not enough to see the Milky Way.
  5. To make a starfield timelapse, it is preferable to see something in the shot like a mountain or a house. Otherwise, all you see is a few stars rotating. Those objects in the shot would also recieve light from the moon when it rises possibly creating a cool effect.

I used my new shiny timelapse machine for this one since it allows for longer exposure times than what the camera supports. It proved to be useful and is perhaps the only thing that worked as expected that night.

So here is the result. I made the mistake of shooting in RAW. I should have shot in jpeg and used the noise reduction function of the camera. When I saw the result, I didn’t bother to process it too much and remove the dead pixels and color-correct it. I just set the black point to clip the light pollution and the noise and trimmed the bad frames.

1 minute exposure per frame, 8 seconds between frames, ISO 200, 12mm, F4.

I consider it to be a failure. The stars you see that don’t move are dead pixels (or dust on your screen). Near the end of the movie, you see the stars dim a little. That’s where the humidity started condensing on the lens. In the hi-res version, we can see one or two shooting stars, but they’re not very apparent. I didn’t bother posting the hi-res version.

I wanted to leave the camera outside all night but when I saw the amount of condensation there was on the lens after only an hour, I stopped the whole thing. The next morning when I saw all the water condensed on my car, I was glad I didn’t leave my camera outside.

2 Comments : more...

Dropbox on Mandriva 2009.1

by flord on Jul.11, 2009, under Mandriva

After downloading Dropbox on Mandriva 2009.1, I got en error message when starting the daemon.

Traceback (most recent call last):
File "__main__dropbox__.py", line 3, in <module>
File "arch/__init__.py", line 20, in <module>
File "arch/linux/startup.py", line 11, in <module>
File "ui/wx_core.py", line 7, in <module>
File "wx/__init__.py", line 45, in <module>
File "wx/_core.py", line 4, in <module>
File "wx/_core_.py", line 14, in <module>
ImportError: /usr/lib/libgdk-x11-2.0.so.0: undefined symbol: XRRGetScreenResourcesCurrent

This can be fixed by downloading an experimental build from here
http://forums.getdropbox.com/topic.php?id=7220

Just download, unpack to $HOME/.dropbox-dist
Then run $HOME/.dropbox-dist/dropboxd

EDIT: Even better: download and run this script https://dl.getdropbox.com/u/43645/dbcli.py

Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Related Links

Related blogs I follow, or sites I like.