April 8, 2011

DVD Creation in Linux

I recently had cause to create a DVD of some camera footage in Linux. Thankfully things have moved on from he situation a few years ago where the only tools available were command line only (albeit very powerful).

The first task I had was to add some titles to my videos (which were in .MOV format 720p@60Hz) and do some basic editing, such as adding a musical soundtrack. For this I initially tried Cinelerra, but found it too awkward, cumbersome and difficult to use. Next I tried Kino, which suited my needs much better, although its features are not as advanced as Cinelerra’s.

Kino works only in .dv format, so all video clips are automatically transcoded when imported. This left me with a problem, which was that the .dv clips were jerky and appeared to drop frames. To get around this I converted the videos to .dv format myself using Winff - a frontend to the excellent ffmpeg tools.

This pre-encoding gave me much better results in Kino. I then set about adding my titles using Kino’s “FX” tools “Titler” function. I also added a musical soundtrack. One note here: Kino will just truncate the track if it is longer than the video clip it’s associated with. To get around this I used Audacity to fade my music out nicely.

Next came exporting the finished video into a format suitable for a DVD. Fortunately, Kino’s Export section has an “Other” tab that allows me to select Dual Pass DVD export to VOB, which is ideal for passing into the next tool in the chain: DVDStyler.

Initially I tried using Bombono for DVD creation, but it seemed to struggle with my 16:9 aspect ratio video. After some research I came across DVDStyler which coped much better. Using DVDStyler I was able to add a root menu which linked to both my video and a submenu. The submenu was used to access chapters of my video which could be easily specified by using the start time of each chapter, for example if I wanted three chapters 10 minutes apart I could specify:

0,10:00,20:00

as the chapters.

One of the advantages of exporting to VOB from Kino was that the videos needed no further transcoding in DVDStyler, which could have resulted in a loss of quality.

DVDStyler also allowed me to preview the video in Xine before being burnt to DVD, which is very convenient for seeing if all the menus link up correctly and that the aspect ratio is correct before potentially creating a coaster from the DVD!

Finally, I burnt the DVD and was very pleased with the result.

This is not the only, or even the best, way to create a DVD in Linux, it was just the toolchain that worked best for me. All the tools used, apart from cinelerra, were available in both the Linux Mint and Ubuntu repositories.


August 20, 2010

Decoding Base64 in SQL

Yesterday (or was it the day before?) I posted a function to encode base64 in SQL. Today I’m posting the function to do the reverse – to turn base64 back into ASCII.

Essentially it works in reverse of the other function. Take four characters, find their ordinal position in the @map variable (e.g. ‘T’ becomes 20) and turn those 24 bits back into 3 characters.

CREATE FUNCTION DecodeBase64(@in varchar(512))
returns varchar(256)
as
begin
declare @map varchar(64)
set @map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'

declare @out varchar(256)
declare @i int
declare @rem int
declare @one int, @two int, @three int, @four int

set @out = ''
set @i = 1

while @i < len(@in)
begin
 set @one = CHARINDEX(SUBSTRING(@in, @i, 1) COLLATE Latin1_General_CS_AS, @map, 0)-1
 set @i = @i + 1
 set @two = CHARINDEX(SUBSTRING(@in, @i, 1) COLLATE Latin1_General_CS_AS, @map, 0)-1
 set @i = @i + 1

 if SUBSTRING(@in, @i, 1) = '='
 set @three = 0 else
 set @three = CHARINDEX(SUBSTRING(@in, @i, 1) COLLATE Latin1_General_CS_AS, @map, 0)-1
 set @i = @i + 1

 if SUBSTRING(@in, @i, 1) = '='
 set @four = 0
 set @four = CHARINDEX(SUBSTRING(@in, @i, 1) COLLATE Latin1_General_CS_AS, @map, 0)-1
 set @i = @i + 1

 -- @one, @two, @three and @four contain characters from input
 -- now convert them back to 3, 8 bit values
 declare @none int
 declare @none_1 int
 declare @none_2 int
 set @none_1 = @one * 4 -- shl 2
 set @none_2 = ((@two & 48) / 16)
 set @none = @none_1 + @none_2

 declare @ntwo int -- four bits at end of @two
 declare @ntwo_1 int
 declare @ntwo_2 int
 set @ntwo_1 = (@two & 15) * 16
 set @ntwo_2 = ((@three & 60) / 4)
 set @ntwo = @ntwo_1 + @ntwo_2

 declare @nthree int
 declare @nthree_1 int
 declare @nthree_2 int
 set @nthree_1 = (@three & 3) * 64
 set @nthree_2 = @four
 set @nthree = @nthree_1 + @nthree_2

 if @nthree > 0
 set @out = @out + CHAR(@none) + CHAR(@ntwo) + CHAR(@nthree)
 else if @ntwo > 0
 set @out = @out + CHAR(@none) + CHAR(@ntwo)
 else
 set @out = @out + CHAR(@none)

 --print substring(@map, @none, 1)
 -- add on first two bits from second 0x3F
end

return @out

end
Filed under: Uncategorized
Tags: , , , ,
komakino @ 2:41 pm

Older Posts »
x