BlackBerry Forums Support Community               

Reply
 
LinkBack Thread Tools
Old 02-19-2007, 01:51 PM   #1 (permalink)
BlackBerry Extraordinaire
 
rivviepop's Avatar
 
Join Date: Dec 2006
Location: san francisco
Model: 8320
PIN: n/a
Carrier: t-mobile
Posts: 2,166
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default vid2bb.sh: using mencoder to create videos

Please Login to Remove!

Originally posted in the 8100 forum in the encoding thread; this is a little script I wrote based on the parameters they've worked out. It's worked great for me.

== snip ==

Getting the right params to mencoder to produce top quality video is always a chore, but using method 1 in the original post is working wonderfully for me -- I've converted all sorts of stuff (WMV/AVI/MPG/FLV/MOV) and so far only the FLV conversions have audio sync problems (nothing new). I'm even going to say that the videos look better (and run smoother!) on my Pearl than any S60 device I've used.

Stupid Bash Trick time -- here's a helper script, save it as "vid2bb.sh" somewhere in your $PATH on Linux/OSX. Make it executable then run with a simple "vid2bb.sh <FILE>" command, the output will be in the input directory.

Code:
#!/bin/bash

FILE=$1

## 8100, 240x260 res
## uncomment one of the below depending on your input format
#RES=240:135             # resolution, 16:9 ratio
RES=240:180             # resolution, 4:3 ratio

## 8800, 320x240 res
## uncomment one of the below depending on your input format
#RES=320:180             # resolution, 16:9 ratio
#RES=240:180             # resolution, 4:3 ratio

## generic
ABR=64                  # audio bitrate
VBR=230                 # video bitrate

mencoder "$FILE" \
        -o "${FILE%.*}_bb.avi" \
        -of avi \
        -ovc lavc \
        -oac lavc \
        -lavcopts vcodec=mpeg4:vbitrate=$VBR:acodec=mp3:abitrate=$ABR \
        -vf scale=$RES
Note that the above takes the input filename, chops off the extension and adds a "_bb.avi" to the end of the output file to help you know which files are your BB ready ones. A quick sort, drag&drop and they're on your device.

My setup is Fedora Core 6 with the FreshRPMS mplayer builds installed (which grabs all the latest libavcodec and so on), as well as the Essential codecs pack (from the MPlayer website) unxipped to /usr/lib/win32/ -- these codecs always seem to produce better quality.
__________________
[ Linux & BlackBerry ] http://www.blackberryforums.com/linux-users-corner/

Last edited by rivviepop : 03-31-2007 at 12:22 AM.
Offline   Reply With Quote
Old 02-23-2007, 06:33 PM   #2 (permalink)
BlackBerry God
 
LunkHead's Avatar
 
Join Date: Jan 2005
Location: Here
Model: 850
OS: 0.0.00001
PIN: kie swear
Carrier: USPS Priority
Posts: 11,014
Post Thanks: 174
Thanked 173 Times in 66 Posts
Default

And one last sticky request please
Offline   Reply With Quote
Old 02-25-2007, 11:07 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Dec 2006
Location: Cd. Juárez, Chihuahua, México
Model: 8100
PIN: 2053A30B
Carrier: Telcel
Posts: 70
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

man... I love Linux Philosophy

and thanks for the code rivviepop :D
__________________
[Blackberry & Linux]
Blackberry 8100
Offline   Reply With Quote
Old 02-25-2007, 03:56 PM   #4 (permalink)
BlackBerry Extraordinaire
 
rivviepop's Avatar
 
Join Date: Dec 2006
Location: san francisco
Model: 8320
PIN: n/a
Carrier: t-mobile
Posts: 2,166
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by indramilo
and thanks for the code rivviepop :D
my pleasure! I'll tell you a little secret - I own [ bash-fu ] My professional life over the years as a systems engineer has given me ample opportunity to become one with the bourne. I thank my workplace and boss (who rocks) for allowing me to get nerdy on company time.
__________________
[ Linux & BlackBerry ] http://www.blackberryforums.com/linux-users-corner/
Offline   Reply With Quote
Old 02-28-2007, 09:48 PM   #5 (permalink)
BlackBerry God
 
LunkHead's Avatar
 
Join Date: Jan 2005
Location: Here
Model: 850
OS: 0.0.00001
PIN: kie swear
Carrier: USPS Priority
Posts: 11,014
Post Thanks: 174
Thanked 173 Times in 66 Posts
Default

Well, no doubt you are the man rivvie... Love the info on you're site... It ROCKS!
Offline   Reply With Quote
Old 03-02-2007, 10:05 AM   #6 (permalink)
Knows Where the Search Button Is
 
erroneus's Avatar
 
Join Date: Feb 2007
Location: Texas
Model: 8100
Carrier: T-Mobile
Posts: 42
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I have used this scriptlet many times. Here's a problem though... and I hope it can be addressed quickly (as in today) because I'll be flying to Japan tomorrow and will be there for two weeks. I'd like to watch a couple of full-length movies on my BB8100!

Here's the problem. I encoded two movies down to BB size but these are formatted for wide-screen display. What do I need to change to make it look right on my BB display? Right now, they come out squished up horizontally.

Okay... right now, I'm re-coding it... don't have the original files available to me at the moment... hope the quality stays good. I set the target aspect ratio to be wider... I have no idea how the BB will play it though...

Okay, I recoded two movies. I just set the RES from 240:180 to 240:120 and it looks much better now... no notable decrease in size and so no decrease in quality is expected.... looks pretty good so far. I can still read the subtitles so I'm good.
__________________
Device: Blackberry 8100 v4.2.0.64
Carrier: T-Mobile USA
BES: 4.1.0.38
Desktop OS: Fedora 7 Linux, Windows XP (vmware)

Last edited by erroneus : 03-02-2007 at 02:06 PM.
Offline   Reply With Quote
Old 03-02-2007, 01:26 PM   #7 (permalink)
BlackBerry Extraordinaire
 
rivviepop's Avatar
 
Join Date: Dec 2006
Location: san francisco
Model: 8320
PIN: n/a
Carrier: t-mobile
Posts: 2,166
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by erroneus
because I'll be flying to Japan tomorrow
*jealous* Can I come? I'm super harajuku friendly.

Quote:
Here's the problem. I encoded two movies down to BB size but these are formatted for wide-screen display. What do I need to change to make it look right on my BB display? Right now, they come out squished up horizontally.
Ugh, never a fun problem; this is the dreaded 16:9 <=> 4:3 conversion problem (if I read/understand your post correctly). Help me out here -- are you saying the original movie is in 4:3 format and it's coming out 16:9, or the other way around? No, wait... ok this line:

RES=240:180

...is a 4:3 ratio. So, it sounds like you have a 16:9 movie -- what you want to do is adjust that ratio set to be 16:9, so maybe:

RES=240:135

...which is a 16:9 ratio exactly (well, exact as my little TI calculator can do ). I bet that'll get rid of your squishedness.
__________________
[ Linux & BlackBerry ] http://www.blackberryforums.com/linux-users-corner/
Offline   Reply With Quote
Old 03-02-2007, 02:07 PM   #8 (permalink)
Knows Where the Search Button Is
 
erroneus's Avatar
 
Join Date: Feb 2007
Location: Texas
Model: 8100
Carrier: T-Mobile
Posts: 42
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, I decided to actually read the script and the answer seemed obvious. I didn't use a calculator like you did, so I didn't come up with a figure as exact. The proportions look good enough though.
__________________
Device: Blackberry 8100 v4.2.0.64
Carrier: T-Mobile USA
BES: 4.1.0.38
Desktop OS: Fedora 7 Linux, Windows XP (vmware)
Offline   Reply With Quote
Old 03-02-2007, 03:26 PM   #9 (permalink)
BlackBerry Extraordinaire
 
rivviepop's Avatar
 
Join Date: Dec 2006
Location: san francisco
Model: 8320
PIN: n/a
Carrier: t-mobile
Posts: 2,166
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by erroneus
Yeah, I decided to actually read the script and the answer seemed obvious. I didn't use a calculator like you did, so I didn't come up with a figure as exact. The proportions look good enough though.
Cool cool, I just updated the scriptlet to clarify that, so maybe it'll help the next person who comes along.
__________________
[ Linux & BlackBerry ] http://www.blackberryforums.com/linux-users-corner/
Offline   Reply With Quote
Old 03-03-2007, 02:33 PM   #10 (permalink)
BlackBerry Extraordinaire
 
rivviepop's Avatar
 
Join Date: Dec 2006
Location: san francisco
Model: 8320
PIN: n/a
Carrier: t-mobile
Posts: 2,166
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just added hopefully the correct res sizes for the 8800 (320x240) devices, I'm about to go troll the 8800 forum for a guinea pig. If you have an 8800 try it out and report back.
__________________
[ Linux & BlackBerry ] http://www.blackberryforums.com/linux-users-corner/
Offline   Reply With Quote
Old 03-04-2007, 04:37 PM   #11 (permalink)
Knows Where the Search Button Is
 
erroneus's Avatar
 
Join Date: Feb 2007
Location: Texas
Model: 8100
Carrier: T-Mobile
Posts: 42
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I wonder if there's a way to add a command-line or two to determine the aspect ratio of the source video and simply either make a selection of aspect ratios or calculate the new, scaled down size for the target video file?

Well, I'm in Japan now and watching videos on the phone during the flight was pretty cool! Here's some tips! Disable the radio and bluetooth for impressive battery life. They want you to turn those things off during flight anyway, but there's a pretty good reason to comply right there. On the flight back, I'm going to re-code as many episodes of "Scrubs" as I can to fit on my 1GB mem card. (I wanted to get a 2GB card, but the price point wasn't attractive enough... the ratios are out of whack but then again, I saw a deal online recently where a 1GB card was like $15 or something like that...ridiculously cheap while 2GB remains at about $50....)

Yes, the 8800 being released within a day or two after I bought my 8100 gave me reason to pause. But then again, I might have gone with the 8100 anyway. The size is perfect. Going bigger doesn't appeal to me much at all.
__________________
Device: Blackberry 8100 v4.2.0.64
Carrier: T-Mobile USA
BES: 4.1.0.38
Desktop OS: Fedora 7 Linux, Windows XP (vmware)
Offline   Reply With Quote
Old 03-04-2007, 08:31 PM   #12 (permalink)
BlackBerry Extraordinaire
 
rivviepop's Avatar
 
Join Date: Dec 2006
Location: san francisco
Model: 8320
PIN: n/a
Carrier: t-mobile
Posts: 2,166
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by erroneus
I wonder if there's a way to add a command-line or two to determine the aspect ratio of the source video and simply either make a selection of aspect ratios or calculate the new, scaled down size for the target video file?
Yeah, it's on my list of things to do. If nothing else I want a commandline switch to choose a res, but it just hasn't been the highest priority item on my list of stuff. Maybe some day...but not today.
__________________
[ Linux & BlackBerry ] http://www.blackberryforums.com/linux-users-corner/
Offline   Reply With Quote
Old 03-25-2007, 07:59 PM   #13 (permalink)
New Member
 
Join Date: Mar 2007
Location: Katy, TX
Model: 8800
Carrier: AT&T
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm an 8800 user and will be happy to help with getting this script to work for me. I've been a Linux user for six years and am presently using Fedora Core 6 and Ubuntu 6.10. My BlackBerry is generally used with my company laptop, which has Windows XP.

When I've tried the script, I've had the video only show a couple of frames. I've tried with multiple mp4 formats as the source. All videos were rendered using Kino from personal DV files.
Offline   Reply With Quote
Old 03-25-2007, 08:01 PM   #14 (permalink)
BlackBerry God
 
LunkHead's Avatar
 
Join Date: Jan 2005
Location: Here
Model: 850
OS: 0.0.00001
PIN: kie swear
Carrier: USPS Priority
Posts: 11,014
Post Thanks: 174
Thanked 173 Times in 66 Posts
Default

Sweet! AND Welcome to the forums!!!!!!
Offline   Reply With Quote
Old 03-25-2007, 08:14 PM   #15 (permalink)
BlackBerry Extraordinaire
 
rivviepop's Avatar
 
Join Date: Dec 2006
Location: san francisco
Model: 8320
PIN: n/a
Carrier: t-mobile
Posts: 2,166
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by tuxi
When I've tried the script, I've had the video only show a couple of frames. I've tried with multiple mp4 formats as the source. All videos were rendered using Kino from personal DV files.
This smells like poor encoding/decoding libs (I can't say for sure, but it's the first thing that comes to mind based on experience). Do you:

- have a newer mplayer installed from FreshRPMS? (or maybe RF or ATrpms)
linky: http://zod.freshrpms.net/rpm.html?id=888

- have the "win32" DLL files unzipped to /usr/lib/win32/ on your machine?
linky: http://www.mplayerhq.hu/design7/dload.html
direct x86 snag: http://www3.mplayerhq.hu/MPlayer/rel...061022.tar.bz2

As we all know, video encoding/decoding w/linux can be sort of hit or miss depending on your source; on my laptop I have the above two in place which does't produce any bad videos (most of the time, of course there are exceptions) and actually they're quite good.

Feel free to upload a smaller mp4 (if legal) that's giving you trouble and I'll give it a whirl, see what happens on my end.
__________________
[ Linux & BlackBerry ] http://www.blackberryforums.com/linux-users-corner/
Offline   Reply With Quote
Old 03-25-2007, 08:16 PM   #16 (permalink)
BlackBerry God
 
LunkHead's Avatar
 
Join Date: Jan 2005
Location: Here
Model: 850
OS: 0.0.00001
PIN: kie swear
Carrier: USPS Priority
Posts: 11,014
Post Thanks: 174
Thanked 173 Times in 66 Posts
Default

My vids are ALL horrid!

@rivviepop don't you owe me a beer???? lol
Offline   Reply With Quote
Old 03-26-2007, 10:51 PM   #17 (permalink)
New Member
 
Join Date: Mar 2007
Location: Katy, TX
Model: 8800
Carrier: AT&T
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by rivviepop
This smells like poor encoding/decoding libs (I can't say for sure, but it's the first thing that comes to mind based on experience). Do you:

- have a newer mplayer installed from FreshRPMS? (or maybe RF or ATrpms)

- have the "win32" DLL files unzipped to /usr/lib/win32/ on your machine?
linky:
direct x86 snag:
I checked to see if my machine was setup as you describe before I ran the script.
rpm -qi mencoder gives
Code:
Name        : mencoder                     Relocations: (not relocatable)
Version     : 1.0                               Vendor: Freshrpms.net
Release     : 0.34.rc1try2.fc6              Build Date: Tue 09 Jan 2007 04:22:36 AM CST
Install Date: Sat 10 Feb 2007 07:50:47 AM CST      Build Host: python3.freshrpms.net
Group       : Applications/Multimedia       Source RPM: mplayer-1.0-0.34.rc1try2.fc6.src.rpm
Size        : 7362484                          License: GPL
Signature   : DSA/SHA1, Tue 09 Jan 2007 04:23:30 AM CST, Key ID 692ac459e42d547b
Packager    : Matthias Saou <matthias@rpmforge.net>
URL         : --
Summary     : MPlayer’s Movie Encoder
Description :
MPlayer’s Movie Encoder is a simple movie encoder, designed to encode
MPlayer-playable movies to other MPlayer-playable formats. It encodes to
MPEG-4 (DivX/XviD), one of the libavcodec codecs and PCM/MP3/VBRMP3 audio
in 1, 2 or 3 passes.  Furthermore  it has stream copying abilities, a
powerful filter system (crop, expand, flip, postprocess, rotate, scale,
noise, rgb/yuv conversion) and more.
I'll PM you with a URL to pick up the example video.
__________________
Tuxi
BlackBerry 8800
AT&T
BES (version unknown)
Windows XP, Ubuntu 8.10
Offline   Reply With Quote
Old 03-26-2007, 11:26 PM   #18 (permalink)
BlackBerry God
 
LunkHead's Avatar
 
Join Date: Jan 2005
Location: Here
Model: 850
OS: 0.0.00001
PIN: kie swear
Carrier: USPS Priority
Posts: 11,014
Post Thanks: 174
Thanked 173 Times in 66 Posts
Default

Looks OK to me but I will await rivviepop's response since he is far more advanced than me....

Quote:
Originally Posted by tuxi
I checked to see if my machine was setup as you describe before I ran the script.
rpm -qi mencoder gives
Code:
Name        : mencoder                     Relocations: (not relocatable)
Version     : 1.0                               Vendor: Freshrpms.net
Release     : 0.34.rc1try2.fc6              Build Date: Tue 09 Jan 2007 04:22:36 AM CST
Install Date: Sat 10 Feb 2007 07:50:47 AM CST      Build Host: python3.freshrpms.net
Group       : Applications/Multimedia       Source RPM: mplayer-1.0-0.34.rc1try2.fc6.src.rpm
Size        : 7362484                          License: GPL
Signature   : DSA/SHA1, Tue 09 Jan 2007 04:23:30 AM CST, Key ID 692ac459e42d547b
Packager    : Matthias Saou <matthias@rpmforge.net>
URL         : --
Summary     : MPlayer’s Movie Encoder
Description :
MPlayer’s Movie Encoder is a simple movie encoder, designed to encode
MPlayer-playable movies to other MPlayer-playable formats. It encodes to
MPEG-4 (DivX/XviD), one of the libavcodec codecs and PCM/MP3/VBRMP3 audio
in 1, 2 or 3 passes.  Furthermore  it has stream copying abilities, a
powerful filter system (crop, expand, flip, postprocess, rotate, scale,
noise, rgb/yuv conversion) and more.
I'll PM you with a URL to pick up the example video.
Offline   Reply With Quote
Old 03-26-2007, 11:32 PM   #19 (permalink)
BlackBerry Extraordinaire
 
rivviepop's Avatar
 
Join Date: Dec 2006
Location: san francisco
Model: 8320
PIN: n/a
Carrier: t-mobile
Posts: 2,166
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by tuxi
I'll PM you with a URL to pick up the example video.
OK, I have the video here, mplayer tells me it's a 4:3 and it's playing just fine on my laptop. I converted it to both a 240x180 and 320x240 (which are both 1.33:1 ratio, 4:3) and they both play perfectly fine on my Pearl without any issues. I'll PM you back a link in a sec after I upload them somewhere.

You had asked about what the right size is in PM -- well, the *specs* say an 8800 is supposed to be able to play 320x240 (which would be fullscreen) but I don't have one to test with over my way, so I am unsure. But the 240x180 version should probably play fine on your device, I would imagine it might have a black border on the left and right though? (you'll have to tell me)

Regardless, let us know how these vids I converted work on your 8800...
__________________
[ Linux & BlackBerry ] http://www.blackberryforums.com/linux-users-corner/
Offline   Reply With Quote
Old 03-27-2007, 07:56 AM   #20 (permalink)
New Member
 
Join Date: Mar 2007
Location: Katy, TX
Model: 8800
Carrier: AT&T
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by rivviepop
<snip>
You had asked about what the right size is in PM -- well, the *specs* say an 8800 is supposed to be able to play 320x240 (which would be fullscreen) but I don't have one to test with over my way, so I am unsure. But the 240x180 version should probably play fine on your device, I would imagine it might have a black border on the left and right though? (you'll have to tell me)

Regardless, let us know how these vids I converted work on your 8800...
Both of your videos performed better than my attempts at 320x240. I had already prepared a 240x180 prior to getting the link, so I also tested it. Both your and my 240x180 videos played with no hesitation. Your 320x240 version hesitated at the beginning, but it started playing OK after 30-60 frames.

All of the 4:3 videos play with black bars on the side since the display on the 8800 is apparently 16:9. I stick with my assertion that if 320 pixels is the width, then 180 must be the height. If this is correct, the proper 4:3 size is 240x180, and the player has to reduce the video size on the fly if it is in a higher resolution.

A question on the win32 codecs:
I copied the newest codecs into /usr/lib/win32. Some of the older codecs (with slightly different names) remain in the directory. Should I purge the directory and recopy the newest only? Thanks.
__________________
Tuxi
BlackBerry 8800
AT&T
BES (version unknown)
Windows XP, Ubuntu 8.10
Offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright © 2004-2014 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.