Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Video files for your Sony Clie/PSP (UPDATED FEB 05)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
rcxAsh
Guru
Guru


Joined: 03 Jul 2003
Posts: 457
Location: /etc/localtime

PostPosted: Fri Jan 14, 2005 11:30 pm    Post subject: Video files for your Sony Clie/PSP (UPDATED FEB 05) Reply with quote

UPDATE February 2005
Most of this guide is now out dated! You can still use it if you want... but, why would you want to when the CVS version of ffmpeg has this support intergrated now! Thanks to our very own tjcannell for the patches!

http://sourceforge.net/mailarchive/forum.php?thread_id=6402849&forum_id=1506

Get some CVS ebuilds here:
https://forums.gentoo.org/viewtopic-t-204881-highlight-cvs+ebuilds+svn.html

NB: for the UX and TH users out there, you will still need to follow the MP4 codec section of this guide, that is, if you haven't learned that already from the 1src forums.

With the later CVS versions of ffmpeg with psp support, you do not need to use the ATOMChanger or MobileHackerz patches anymore. Yay :)

Everyone say thanks to tjcannell!


If you have a modern Sony Clie, you'll know that converting videos for it is a pain. NB, this is for the following Clies: UX40/50, TH55, VZ90.

Newer versions of Image Converter (1.5 and 2.0) make this easier, but are Windows programs.

Visiting http://1src.com, I found that a Japanese programmer had written a program that transcodes video to the extremely strict MP4 variant that the Sony PSP and Clie VZ90 use.

The program uses a modified version of ffmpeg to do the transcoding. So, it's possible to do it in Linux. There are a couple post-processing tools which still require Windows, or at least wine.

I hope that this works. In working this out, I had went through many bad compiles of ffmpeg, as well as other tinkerings. So I hope that the methods described below are the ones that I used to get it working... lol

One of my first tips.. so bear with me.

Outline:
0. If you are using the cvs version of ffmpeg, which has builtin MP4 support, skip to step 6 (for Clie users). PSP and VZ90 users, you should be set once you install a version of ffmpeg that has psp support (eg, CVS version). (Update April 13, 2005)
Using the stock cvs version of ffmpeg, an example command line that I use is:
Code:
ffmpeg -y -i inputfile.avi -title "videotitle" -f psp -r 14.985 -s 320x240 -b 768 -ar 24000 -ab 32 outputfile.mp4


1. Compile modified xvid
2. Compile modified CVS version of ffmpeg
3. transcode with new ffmpeg
4. Use QT3GPPFlatten.exe in Windows (EDIT: seems optional!)
5. Use ATOMChanger with wine or in Windows
6. Preparing you Clie (Non-VZ90 users)
7. Last notes
I personally like to work in a clean directory. So I will walk through using that.
Code:
cd
mkdir ffmpeg
cd ffmpeg


1. Compiling modified xvid
First download the modified bitstream.c file from http://www.nurs.or.jp/~calcium/3gpp/sources/
Code:
wget http://www.nurs.or.jp/~calcium/3gpp/sources/xvidcore_patched_diff_011.tar.gz

Extract it:
Code:
tar -xvzf xvidcore_patched_diff_011.tar

Inside, you will find bitstream.c.

Now emerge the latest version of xvid (at the time of writing, 1.0.2), but hit ctrl z once you see that the source is unpacked:
Code:
lostech root # emerge xvid
Calculating dependencies ...done!
>>> emerge (1 of 1) media-libs/xvid-1.0.2 to /
>>> md5 src_uri ;-) xvidcore-1.0.2.tar.bz2
>>> Unpacking source...
>>> Unpacking xvidcore-1.0.2.tar.bz2 to /var/tmp/portage/xvid-1.0.2/work
 * Applying 1.0.2-DESTDIR.patch ...                                       [ ok ]
 * Applying xvid-1.0.1-64bit-clean.patch ...                              [ ok ]
>>> Source unpacked.

[1]+  Stopped                 emerge xvid
lostech root #
At this point, copy the bitstream.c file you just extracted to the portage work directory:
Code:
 cp bitstream.c /var/tmp/portage/xvid-1.0.2/work/xvidcore-1.0.2/src/bitstream/

Then resume the emerge:
Code:
fg
.

Let the emerge finish.

NB, this is pretty messy. It will be destroyed anytime you upgrade or reemerge xvid. A better thing to do would be to write a replacement ebuild and stick it in your /usr/local/portage tree.

2. Compiling a modified version of ffmpeg
You will need the CVS version of ffmpeg. I personally decided to use the exact same version as MobileHacerz did (the programmer who made the code modifications we are using). Download this version like so:
Code:
wget http://www1.mplayerhq.hu/MPlayer/cvs/FFMpeg-20041210.tar.bz2

Extract:
Code:
 tar -xvjf FFMpeg-20041210.tar.bz2

Then download the modified source files from the same site where we got the xvidcore modifications:
Code:
wget http://www.nurs.or.jp/~calcium/3gpp/sources/ffmpeg_patched_diff_019.tar.gz

Then extract that archive into the original ffmpeg source directory:
Code:
tar -xvzf ffmpeg_patched_diff_019.tar.gz -C ./FFMpeg-20042110/

Enter the directory:
Code:
 cd FFMpeg-20042110

Then configure. You can modify the configure switches as you see fit. But AFAIK, you will definately need aac and xvid. You may need the rest. Best to be safe and use it anyways.
Code:
./configure --enable-mp3lame --enable-faac --enable-faad --disable-ffserver --disable-ffplay --enable-small --enable-memalign-hack --enable-gpl --enable-xvid --disable-vhook --enable-faadbin

Now make:
Code:
make

Let it compile. Note that if you did not upgrade to a newer version of xvid, the compile may break when it reaches xvidff.c. I had this happen to me.

After the program is done, you can confirm that you have compiled it correctly if you run the binary like such and see:
Code:
ashley@lostech FFMpeg-20041210 $ ./ffmpeg
ffmpeg version 0.4.9-pre1-based-MobileHackerz, build 4736, Copyright (c) 2000-2004 Fabrice Bellard
  configuration:  --enable-mp3lame --enable-faac --enable-faad --disable-ffserver --disable-ffplay --enable-small --enable-memalign-hack --enable-gpl --enable-xvid --disable-vhook --enable-faadbin
  built on Jan 14 2005 16:43:40, gcc: 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)
usage: ffmpeg [[infile options] -i infile]... {[outfile options] outfile}...
Hyper fast Audio and Video encoder
...

Notice the extra string added to the end of the version string, "-based-MobileHackerz"

After this, you can do a "make install" if you want. Or, you can just cd into that directory and run it each time if you prefer. For now, I have left it in its own directory and run it from there.

3. Transcoding with your new ffmpeg
Download MobileHackerz's 3GP Converter from here: http://www.nurs.or.jp/~calcium/3gpp/
Unzip it somewhere and look at the file ./default_setting/Transcoding_PSP.ini

Yes, you will use these example commands for your Sony Clie as well. The Sony Clie and PSP use the same file format.

The main lines that you will want to pay attention to are the ffmpeg lines of course.

Here is an example conversion that I did:
Code:
./ffmpeg -y -i \[Nameless_Death\]School_Rumble_-_CM\[25B1E5B7\].avi -title "SRPV" -bitexact -vcodec xvid -s 320x240 -r 14.985 -b 216 -acodec aac -ac 2 -ar 24000 -ab 32 -f 3gp temp2.3gp


If all goes well, ffmpeg should happily churn away. You will end up with a 3gp file.

4. Use QT3GPPFlatten.exe in Windows edit: seems optional!
Edit: It seems that this step is optional. I converted a video skipping this step, and it still played on my UX40.

Now before I start, I just want to mention that it may be possible to run this program in wine. However, you need to install QuickTime. As in QuickTime for Windows, or QT3GPPFlatten will just say that it failed to open the video (with wine when I tried).

This step is rather quick, however. So if you have QEmu or VMWare, it could be relatively painless to do. (A lot better than using Image Converter)

Again, look at the Transcoding_PSP.ini file for examples on how to use the QT3GPPFlatten.exe program. It is a command line program. I have this program on a samba share, mapped as network drive E: in Windows 98 on VMWare. I use it like this:
Code:
C:\WINDOWS> E:
E:\> cd 3GP_Converter022
E:\3GP_Converter022> cores\QT3GPPFlatten cores\temp2.3gp cores\temp2b.3gp -c QT_3GPP(MobileMP4)_QVGA_AAC.ini

Notice that I am not in the cores directory when I call QT3GPPFlatten.

If all goes well, you should get a new 3gp file.

5. Using ATOMChanger
ATOMChanger is a Windows program, but I have had success using it with wine. It's up to you. I will use wine in the next example, but using it in Windows isn't any different.

cd into the directory where you have extracted the 3GP Converter for Windows. Do not enter the cores directory again. I haven't played around with file locations much with wine and the ATOMChanger yet, so to be safe, just throw the 3gp file that QT3GPPFlatten created in the same directory.

Call ATOMChanger like so:
Code:
wine cores/ATOMChanger.exe temp2b.3gp linuxtest.mp4 Camouflage_MP4_for_PSP.ini

If all goes well, you should see something like:
Code:
ATOMChanger for 3GP_Converter Version 0.15
http://www.nurs.or.jp/~calcium/
PSP/CLIE PEG-VZ90ŎĂMP4ɕϊ܂
VideoTrack : 1 320 x 240 14.99fps 216000bps
AudioTrack : 2 24000Hz 2ch 32000bps
You should also have a new mp4 file!

Yay!

If you are a VZ90 or PSP user, throw this onto the proper directory on your memory stick, and you should be good to go!!!

If you are not a VZ90 user, then continue reading.

Watching MP4 video on your Sony Clie
If you do not have a VZ90, but own a UX40/50 or a TH55, then you must download and install the MP4 codecs onto your Clie. You should also download CliePet's Full Movie Player.
New Video Codecs
Full Movie Player

Read the 1src thread to see which files you need to install for the new codecs, as well as how to install them. Note that you do not need to install the MediaLauncher. CliePet's Full Movie Player replaces this.

After you have installed these programs on your Clie, simply put your MP4 files on your memory stick in /MOVIES/ and you should be good to go!

Last notes
I found out about the 3GPP Converter here: http://www.1src.com/forums/showthread.php?t=75447

Although this method now allows for all the video transcoding to be done in Linux, I would still like to have everything be done in Linux. If anyone knows anything about software that will do the same things as QT3GPPFlatten and ATOMChanger, I would greatly appreciate it!

I hope that this works for everyone else!

Edits:
January 15, 2005 - Discovered that you may not even need to use Windows anymore; wine will suffice; QT3GPPFlatten is not really needed it seems.
April 12, 2005 - Added link to thread with CVS ebuilds, including ffmpeg
_________________
rcxAsh


Last edited by rcxAsh on Wed Apr 13, 2005 8:43 pm; edited 6 times in total
Back to top
View user's profile Send private message
tjcannell
n00b
n00b


Joined: 21 Aug 2003
Posts: 10

PostPosted: Thu Jan 20, 2005 11:14 pm    Post subject: Reply with quote

I had sucess using a slightly different technique creating MP4 for my Sony PSP.

I retreived the latest CVS version of ffmpeg, then made some relatively minor changes (including some complete guesses) to movenc.c

I can currently only encode at 768kbps, and i'm pretty sure i've got some of the fields wrong, but at least it means I don't have to dabble with 'other' OS's executables.

If anyone wants to know how I did it, just post here, and I'll spill the beans.
Back to top
View user's profile Send private message
rcxAsh
Guru
Guru


Joined: 03 Jul 2003
Posts: 457
Location: /etc/localtime

PostPosted: Thu Jan 20, 2005 11:34 pm    Post subject: Reply with quote

Hey, that sounds great! There may be one or two Linux users in the 1src forums who would be interested too. However, what do you mean that you can only convert at 768kbps? What happens if you try to use a different bitrate? (IIRC, I think that I read that Sony Clies don't normally play at such high bitrates..? I don't have a PSP)

Anyways, I'd be interested to know your method. I'm going to be away next week, so I may not reply right away, but please do share.
_________________
rcxAsh
Back to top
View user's profile Send private message
tjcannell
n00b
n00b


Joined: 21 Aug 2003
Posts: 10

PostPosted: Sat Jan 22, 2005 2:00 pm    Post subject: Reply with quote

I've done a little more work on tidying up my changes. And I've posted onto the ffmpeg developers mailing list to see about getting it submitted to the codebase. I'll see what happens...

All I did was look at the current MP4 generating source in ffmpeg CVS and some hex dumps of working PSP MP4's.

I've tried to make all the changes universal so that they work on the Sony PDA's as well, but without the hardware it's a bit tricky to test.

I could post the file changes here if anyone is interested .... I'll try posting on the 1src forum as well.
Back to top
View user's profile Send private message
rcxAsh
Guru
Guru


Joined: 03 Jul 2003
Posts: 457
Location: /etc/localtime

PostPosted: Sun Feb 27, 2005 4:33 pm    Post subject: Reply with quote

Hey tjcannell,

I finally got around to checking out the CVS version of ffmpeg, which now has your patch applied.

It works great!

But BTW, would it be possible to make it work at higher resolutions? Eg, the Sony Clie can handle up to 480x320 I believe. 320x240 is apparently the official maximum resolution though. Anyways, from the 1src forum:
djboa wrote:
yeah it is hardlocked to 320x240 ... seems like the x*y properties are written in two ways:
- to identify the file
- during the stream to setup decoding

only the first is needed to trick the player, but this patch also writes the second information so that any stream encoded at anything but 320x240 is garbled when decoded ... unfortunately he just pastes some preset hex codes into the code as identifiers, but I will have a go at commenting some of them out and see if that fixes it ...

How difficult would it be to do what he's saying, and is that even right?

Thanks again tjcannell!
_________________
rcxAsh
Back to top
View user's profile Send private message
apyh
n00b
n00b


Joined: 17 Mar 2003
Posts: 67
Location: Texas

PostPosted: Tue Apr 12, 2005 4:55 pm    Post subject: Reply with quote

would someone mind updating this thread? That link to the ffmpeg ml doesn't work for me, I'm guessing I got to be a member of the project (don't have a sourceforge account).
Back to top
View user's profile Send private message
rcxAsh
Guru
Guru


Joined: 03 Jul 2003
Posts: 457
Location: /etc/localtime

PostPosted: Wed Apr 13, 2005 12:42 am    Post subject: Reply with quote

Hey, sorry, didn't notice that SourceForge now requires you to log in...

Either way, all you really need is the cvs version of ffmpeg. Use the new psp output mode with the -f switch.

If you don't want to build the cvs stuff by hand, you can get some cvs ebuilds (including a cvs ebuild for ffmpeg) from this thread here:
https://forums.gentoo.org/viewtopic-t-204881-highlight-cvs+ebuilds+svn.html
_________________
rcxAsh
Back to top
View user's profile Send private message
apyh
n00b
n00b


Joined: 17 Mar 2003
Posts: 67
Location: Texas

PostPosted: Wed Apr 13, 2005 5:59 pm    Post subject: Reply with quote

so the psp switch outputs a mp4 file? or do i still have to go thru steps 4 and 5?
Back to top
View user's profile Send private message
rcxAsh
Guru
Guru


Joined: 03 Jul 2003
Posts: 457
Location: /etc/localtime

PostPosted: Wed Apr 13, 2005 8:37 pm    Post subject: Reply with quote

apyh wrote:
so the psp switch outputs a mp4 file? or do i still have to go thru steps 4 and 5?

Ah, sorry for the confusion. No, you do not have to go through any of the steps that I have listed if you use the CVS ffmpeg. That is, unless you are using a Sony Clie, in which case you will still need to install the MP4 codecs and the Full Movie Player on your Clie.

I usually do my video conversions with a line such as this:
Code:
ffmpeg -y -i "$1" -title "$1" -f psp -r 14.985 -s 320x240 -b 768 -ar 24000 -ab 32 "$1".mp4

Where the "$1" are the file names... (I put this into a bash script, hence the $1s)
_________________
rcxAsh
Back to top
View user's profile Send private message
dncohen
n00b
n00b


Joined: 29 Nov 2004
Posts: 43

PostPosted: Mon Apr 25, 2005 10:43 pm    Post subject: Reply with quote

I tried compiling the cvs ffmpeg on my own (not an ebuild), and the encoding fails as follows...
Code:


ffmpeg version 0.4.9-pre1, build 4753, Copyright (c) 2000-2004 Fabrice Bellard
  configuration:
  built on Apr 25 2005 15:19:56, gcc: 3.4.3 20041125 (Gentoo Linux 3.4.3-r1, ssp-3.4.3-0, pie-8.7.7)
Input #0, avi, from 'MythBusters - 2x20 - Son of a Gun.avi':
  Duration: 00:43:39.5, start: 0.000000, bitrate: 1127 kb/s
  Stream #0.0: Video: mpeg4, yuv420p, 640x414, 29.97 fps
  Stream #0.1: Audio: mp3, 48000 Hz, stereo, 128 kb/s
Output #0, psp, to 'MythBusters - 2x20 - Son of a Gun.avi.mp4':
  Stream #0.0: Video: mpeg4, yuv420p, 320x240, 14.98 fps, q=2-31, 768 kb/s
  Stream #0.1: Audio: 0x0000, 24000 Hz, stereo, 32 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
[mpeg4 @ 0x7b5cd0]removing common factors from framerate
Unsupported codec for output stream #0.1


Is this a matter of enable flags when configuring ffmpeg, or what?

Thanks for any help.
[/code]
Back to top
View user's profile Send private message
dncohen
n00b
n00b


Joined: 29 Nov 2004
Posts: 43

PostPosted: Tue Apr 26, 2005 4:01 am    Post subject: Reply with quote

In answer to my own question, yes it was a matter of enabling the right compile options. Also, and this is what tripped me up, after running configure a second time, make sure to 'make clean'.

The options I've used are --enable-memalign-hack --enable-gpl --enable-xvid --enable-faac.

The encoding has succeeded, now to get it on the psp and see if it plays...
Back to top
View user's profile Send private message
ghedlund
n00b
n00b


Joined: 02 May 2005
Posts: 1

PostPosted: Mon May 02, 2005 10:29 pm    Post subject: PSP Encoding Script Reply with quote

Using info from this post, I've put together a little script which takes in the input movie and creates the corresponding mpeg4 movie and .thm file for the PSP. It's pretty basic and I haven't tested it fully yet, but I hope it will be helpful to people.

Example:

pspencode.sh inputfile.avi outputprefix

This will create files outputprefix.mp4 and outputprefix.thm in the current directory. The .thm file will be a JPEG image taken at one second into the video. The following command does the same thing:

pspencode.sh inputfile.avi outputprefix high high "My Video" 1

For an explaination of all the options, please see the script file.

Requirements:

-> ffmpeg (the newest CVS version mentioned at the top of this post)
-> transcode (optional, used only to ouput some info about the source file)

If you do not wish to have the transcode tools installed, you will see errors in some of the script output, but everything should still work fine.

http://www.cs.mun.ca/~ghedlund/pspencode.sh

Have fun!
Back to top
View user's profile Send private message
apyh
n00b
n00b


Joined: 17 Mar 2003
Posts: 67
Location: Texas

PostPosted: Thu Jun 23, 2005 8:34 pm    Post subject: Reply with quote

I accidentally nuked my ffmpeg cvs folder last week, after getting a recent cvs snapshot, i'm unable to compile ffmpeg with the --enable-faadbin option.

Is this option required (i'm still using all the other options, including --enable-faad).

When I have --enable-faadbin in the config option, compiling craps out on libavformat:

Code:
make[1]: Leaving directory `/home/garza/ffmpeg/libavformat'
gcc -Wl,--warn-common -rdynamic -g  -o ffmpeg_g ffmpeg.o cmdutils.o -L./libavformat -lavformat -L./libavcodec -lavcodec -lm -lz -lmp3lame -lfaac-lxvidcore
./libavcodec/libavcodec.a(faad.o)(.text+0x11f): In function `faac_decode_end':
/home/garza/ffmpeg/libavcodec/faad.c:184: undefined reference to `dlclose'
./libavcodec/libavcodec.a(faad.o)(.text+0x144): In function `faac_decode_init':
/home/garza/ffmpeg/libavcodec/faad.c:196: undefined reference to `dlopen'
./libavcodec/libavcodec.a(faad.o)(.text+0x151):/home/garza/ffmpeg/libavcodec/faad.c:199: undefined reference to `dlerror'./libavcodec/libavcodec.a(faad.o)(.text+0x16f):/home/garza/ffmpeg/libavcodec/faad.c:212: undefined reference to `dlsym'./libavcodec/libavcodec.a(faad.o)(.text+0x18b):/home/garza/ffmpeg/libavcodec/faad.c:213: undefined reference to `dlsym'./libavcodec/libavcodec.a(faad.o)(.text+0x1a7):/home/garza/ffmpeg/libavcodec/faad.c:228: undefined reference to `dlsym'./libavcodec/libavcodec.a(faad.o)(.text+0x1c3):/home/garza/ffmpeg/libavcodec/faad.c:230: undefined reference to `dlsym'./libavcodec/libavcodec.a(faad.o)(.text+0x1df):/home/garza/ffmpeg/libavcodec/faad.c:232: undefined reference to `dlsym'./libavcodec/libavcodec.a(faad.o)(.text+0x1fb):/home/garza/ffmpeg/libavcodec/faad.c:235: more undefined references to `dlsym' follow./libavcodec/libavcodec.a(faad.o)(.text+0x231): In function `faac_decode_init':
/home/garza/ffmpeg/libavcodec/faad.c:245: undefined reference to `dlclose'
collect2: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1
Back to top
View user's profile Send private message
nzmark
n00b
n00b


Joined: 13 Jun 2005
Posts: 28

PostPosted: Mon Oct 03, 2005 7:55 pm    Post subject: Reply with quote

368x208 is why incompatible video format?? Video 9 make it correctly
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum