Log in

View Full Version : PSPEnc, ffmpeg gui for PSP encoding (mpeg4 sp only)


jonny
17th September 2005, 14:56
You can find it here:

http://jonny.leffe.dnsalias.com

PSPEnc is a gui for FFMPEG. It uses Avisynth to handle the video. The output is an mp4 file compatible with PSP (only MPEG4 SP atm).

Features:
- Avs, Avi, Mkv, Ogm, Mpg, Wmv ... input (basically everything working with DirectShowSource).
- Automatic crop/addborders, to obtain correct aspect ratio.
- Automatic video bitrate calculation (you have to choose only audio bitrate and total output size).
- 1 pass, 2 pass, 1 pass with fixed quantizer, compressibility test, size prediction for fixed quantizer encodes.
- Job list.
- You can see quantizer distribution after every encode.
- You can run multiple istances of PSPEnc.

Notes:
- To encode from DVD source you should provide an avs script with progressive, cropped video and specify the correct aspect ratio (usually i do this with GKnot ^^).
- Compressibility test is based on the quantizer you specify (it basically tell you how near/far you are from this quant).
- If you obtain an output with wrong size (this is applicable mainly for 2 pass encodes), you have probably saturated video (and/or audio!).

no avc support atm ... ( until someone send me a psp with fw 2.0 for free :D )

bye
jonny

guada2
17th September 2005, 16:31
Happy to see you here.

:thanks:

danpos
17th September 2005, 21:44
@jonny

I've downloaded it and so I tested it out! It works like a charm and I did like a lot of prediction for quantizer encoding. My interest in it should be adapt it for encode to PALM's handheld. Could you give some advises to me about this target encoding? Keep up the good work! :)

TIA,

jonny
18th September 2005, 09:18
thanks to both :)

danpos, do you want to know the details of the size prediction (or general infos for PALM encoding)?

danpos
18th September 2005, 20:36
@jonny

Thanks for your interest in my questions. Both if possible! :) And if possible (again) I'll like to know more about your resize scheme.

Thanks in advance. ;)

Cya!

jonny
19th September 2005, 10:28
Size prediction:

First of all, AviSynth is required in the process.
To make a prediction from, for example, a .avi file, a script like this is used:

DirectShowSource("myvideo.avi")
SelectRangeEvery(1400, 14)

This means that 14 frames every 1400 will be returned from the original file (this is the 1% case).

Now, you pass the script to your encoding app (in this case FFMPEG) making a normal fixed quant encode.

To predict the final size, you must find a way to read frame size for every encoded frame (-vstats option is the way for FFMPEG - it creates a log file with the infos needed).

So:

Reading the log you have the size for each frame encoded.
Summing up the frame sizes (discarding some frames) and dividing this sum by the number of frames used, you have the average frame size.
Multiply the average frame size by the total number of frames and you have the predicted size.


About "discarding some frames":

SelectRangeEvery(1400, 14)

Using this istruction, we take the first 14 frames, than we jump to the next 14 frames skipping 1400-14 frames.
This jumps cause the codec to thing that there is a scene change, so a keyframe is inserted (artificial, because in your normal encode you'll never have this keyframe)
Keyframes take more space compared to normal delta frames, so, to make a good statistic you must discard those frames (if not, you'll obtain a totally crazy result).

This means that the first frame every 14 frames is discarded from the output when i make the calculations.
(bframes enabled complicates things a bit, other frames needs to be discarded - it's not the case of a psp encode :) )


PS: in the examples i've used 14 (mainly cos i've copy/pasted from an old thread) PSPEnc uses 13 as base for the SelectRangeEvery.
(14 is more convenient when bframes are enabled)


An old thread:
http://forum.doom9.org/showthread.php?t=44621&page=1&pp=20
(drop the initial part)





PALM:

PSP is my first little device ... ^^'
you have to do your searchs, i know nothing about PALM devices :P




PSPEnc's resolution picker:

The resolution picker is a bit strange.
I copy paste from an email i've recently send:


also, if I change the output resolution, it's telling me there is an aspect ratio error, and it's tellin me the aspect ratio is ~16/9 when it is in fact 1.3333 (192x144)


There is a reason for this.

PSPs with firmware 1.5 (like mine) basically stretch the video always to fit the psp screen (so the AR is always 16/9 for every resolution you choose)

There are only 2 exceptions:

320x240 can be viewed in 4/3 or stretched to 16/9
160x112 can be viewed in ~ 4/3 or stretched to 16/9

So:
If you choose 320x240 and 16/9, you should watch the video in "fullscreen"
If you choose 320x240 and 4/3, you should watch the video in "original", "normal", or "zoom"
(the same goes for 160x112)

All the other resolution are always displayed 16/9, no matter of what PSP's setting you use ("original", "normal", or "zoom" or "fullscreen")

On firmware 2.0 i think the stuff is changed ... in this case you should always use "fullscreen" on PSP if you choose 16/9 for output.


In addition to this:

When you open a file, PSPEnc assumes square pixels (and so the input AR is calculated - you can change it if the input have a different AR).
To match the output AR, you usually have 2 choices: crop one side or add borders to the other side (so you can usually choose one of the 2 mode in order to get correct AR on output).
PSPEnc always goes for cropping by default (adding borders is probably useful only for widescreen content - AR = ~ 2.35)

EDIT:
Some resolutions are not selectable because the output show big artifacts when played on PSP (at least on fw 1.5).


i think i'll start making a faq with this post :)

danpos
19th September 2005, 14:52
@jonny

WOW, what a great post you did mate !! :goodpost:

Surely the one clarified things up to me. :thanks:

Keep up the good work. ;)

Cya!

jonny
19th September 2005, 14:58
i can do this type of posts only once per year :p :D

:thanks: to you too

gutzalpus
2nd October 2005, 16:18
Any idea what would cause:

"Error: Exitcode=3"

as soon as I press the "Start all jobs" button? I installed the latest version of avisynth so I'm not sure what else would cause it.

EDIT: I installed the latest version of ffdshow and this corrected the problem.

jonny
2nd October 2005, 17:02
This kind of error is reported by ffmpeg (usually an exitcode != 0 means an error)
I've still not found a good way to get the exact error message :(
happy you solved with ffdshow, this could indicate a previous video or audio decoding problem

tip: if your source is an avi file, it could be more compatible to use "Method" = "AVISource" in the input panel (simply load the avi file and after press the "Change" button)

gutzalpus
7th October 2005, 10:18
I've also found that I get the same error whenever I try to convert a file with >2 channels of sound (xvid with 5.1 AC3, etc.)

So I have to manually demux and re-encode to stereo sound in order for pspenc to process the file. I'll try using "AVISource" and see if that makes a difference.

jonny
7th October 2005, 10:42
I've also found that I get the same error whenever I try to convert a file with >2 channels of sound (xvid with 5.1 AC3, etc.)
Thanks for the report, i'll do some tests.
PS: i'm adding ffmpeg's error logging, in the next pspenc's version you'll be able to see the full error message instead of the exitcode number (hopefully you'll see no more errors :) ).

jonny
7th October 2005, 13:48
I've done a quick test and ffmpeg seems to don't like audio with more than 2 channels, at least not in uncompressed pcm format (the way AviSynth output it).

Instead of demuxing, you could try to load directly the input file as "External audio", this should work.

EDIT: it works, at least with avi input (going to check more audio/container combinations)

EDIT2: a better solution is to play the video, open the audio filter properties, enable the ffdshow's mixer and select 2/0 - stereo output, this will work with every type of input.

jonny
10th October 2005, 21:33
v1.01 is out

nothing big but better than 1.00 :)

-------------------------

Changes:
- Added "Avi open", should be more compatible with avi input (use the generic open if this fails)
- "Add borders" is now the default method if the input aspect ratio is ~2.35
- FFMPEG's error logging (now you can see the exact FFMPEG's output after obtaining an "Exitcode" error)
- Added volume setting
- Added a check to see if AviSynth is installed
- Installer, with AviSynth and ffdshow included
- Maybe other things i don't remember :P

gutzalpus
13th October 2005, 03:40
jonny,

Thanks for all the great work on pspenc so far.

I have had success using the first method you suggest for multi-channel audio but in regards to the second, I haven't been able to locate the audio decoder options on ffdshow. Mine comes up with only video options.


Also, I occasionally run into some audio sync issues with pspenc encoded files. It isn't happening consistently and I haven't yet been able to isolate any particular settings which cause the problem.

jonny
13th October 2005, 13:19
strange, two icons should be on the tray (video and audio):

http://jonny.leffe.dnsalias.com/doom9/ff/ff00.png

Or, for example with Zoom Player, something like this should be possible (with a right click on video):

http://jonny.leffe.dnsalias.com/doom9/ff/ff01.png
(here you could see what is the audio decoder used)

If another decoder is used, this could indicate something wrong with ffdshow install (have you installed something audio/video related app after ffdshow?).


For the av synch probs - quite hard to get a cause, if you have some not copyrighted material and you want to send me it for testing, i'll be happy to check

Chris Benoit
16th October 2005, 14:56
I can't get PSPEnc to work.I run the mp4 generated files on my pc and i get the message rendering failes.I have klite and ffdshow install so i don't thing its a filter thing.

jonny
16th October 2005, 15:10
use quicktime to play on pc

put the file in this way on psp to play it:
\MP_ROOT\100MNV01\M4V10001.MP4

Chris Benoit
16th October 2005, 15:47
Yep i knew about the psp folder since i've made conversions before,but quicktime being the only player that played the generated files strikes me as odd!

How come?I've made mp4 before with 3gp converter,nero recode and other soft and the play just fine in media player classic,y are these mp4 any different and play only with quicktime?

jonny
16th October 2005, 15:57
i've not investigated too much about this :) (probably the answer is somewhere in the forum)

Chris Benoit
16th October 2005, 16:19
Ok i tried it and here are my results.

The volume boost is good,i put 300% and the sound was much louder,so now i can benefit from it when i view video files in public places (like the bus!).

But here's tha catch.The sound for some reason,ends prematurely.I've converted the same file both with psp enc and 3 gp converted.Tha last sentence in the sequence goes:

"This is Micheal Bluth"

In the pspenc video it goes "This is" and the audio stops then the last video frames (couples of secs) continue without audio.

Also it doesn't freeze at the last frame when video ends but instead it displayes a grey screen.

jp80
16th October 2005, 22:02
Would it be possible for pspenc to hardcode in the video a subtitle detected from a mkv/ogg by ffdshow ? If yes then how would it be possible to select the subtitle stream/language ?

jonny
17th October 2005, 11:06
In the pspenc video it goes "This is" and the audio stops then the last video frames (couples of secs) continue without audio.
Also it doesn't freeze at the last frame when video ends but instead it displayes a grey screen.

Is this happening in both quicktime / psp?
Can you follow the question #1 of the FAQ (on my site), commenting what you have installed/tried?
Also, detailed specs for the input file could help me to identify the problem (detailed infos while reporting a problem are crucial)


Would it be possible for pspenc to hardcode in the video a subtitle detected from a mkv/ogg by ffdshow ? If yes then how would it be possible to select the subtitle stream/language ?

1 - You should try to tweak the ffdshow's video decoder config. (obviously the Subtitles part), to see if they show up while encoding.
(you can open the video config. using the way described in some previous post)
2 - You could also try demuxing the sub and using an AviSynth script (with DirectShowSource/TextSub)
(i can't check the method #1 atm)

gutzalpus
17th October 2005, 12:34
I've noticed that when using Q=2 on the 1 pass quant setting, that the playback will occasionally become jerky on the psp. I'm just guessing, but I assume this is due to spikes in the bit rate. . . Is there any way to limit this? I'm not that familiar with ffmpeg command line options.

A nice feature for a future version might be to be able to add custom command line options for ffmpeg.

jonny
17th October 2005, 13:04
afaik there is no way (-maxrate doesn't work with a quant encode)
yep, with Q<=2 you'll probably notice a lot of stuttering (anyway the optimal encode should stay between 3 and 4 imo)
iirc jerky playback happen with a bitrate around 2000

you could do this check before doing quant encodes:

- run a compressibility test with the quant you want to use
- after the test finish, select the job and press "View details"
- change the output size in order to match the predicted size
- look at the bitrate (this will be ~ the average bitrate of the quant encode)

keeping the average bitrate to a reasonable value will limit for sure bitrate spikes


A nice feature for a future version might be to be able to add custom command line options for ffmpeg.

i'd prefer to add parameters directly in the interface, if you have particular needs for a parameter we can discuss about this ;)

damrod
2nd December 2005, 22:29
hi just test you app

good work !!

btw do you plan to add h264 video encoding?
firmware 2+ support it

i wonder if psp with firmware 2+ support he-aac....?

sony is a strange company... you can play mp4 files (video+audio in mpeg4....)
but you can't listen to mp4 audio files !!! only mp3 or atrac3..weird no?

also (i write a lot i know ;)) did you test psp advance...

jonny
3rd December 2005, 11:10
btw do you plan to add h264 video encoding?

no, i'm keeping fw 1.5 atm on my psp


also (i write a lot i know ) did you test psp advance

this app puts banners in both pc & psp and was violating xvid gpl license.
... and pmp is already superior

damrod
4th December 2005, 10:40
PMP? what's that?

my psp is new so fw 2.5 :-(

jonny
4th December 2005, 12:08
pmp is a media player based on ffmpeg ( http://forums.ps2dev.org/viewtopic.php?t=3571 )
i think full res xvid + mp3 will be soon possible ;)

2.5 ... is too bad :(

damrod
13th December 2005, 23:49
i look at pmp...mum look interesting but for the moment i will keep f 2.5 since i play with nfs most wanted...et i want to play h264...video in 368*208, aac 64 and h264 500 play good on my pc (1184*854@85hz-32bits), less details than original but it was expected... and on the psp ouahhhhhhhhhhhhhhhhhhh

if it can be usefull

ffmpeg -an -y -t 0:0:0.005 -i source.avs -f image2 -s 160x120 MAQ10001.THM

to generate the thimbnails for the psp (fake jpg lol...sony like bad jokes :) )

MAQxxxx are h264 file..M4Vxxxx are asp files if i remember right...

Wingz
12th January 2006, 05:06
Firstly i would like to thank you for this great program. I have been able to do almost everything that i want to do using it.

I have had success with .avi and .ogg/ogm files however i am having trouble converting matroska (.mkv) videos. Basically the video in the output file plays too fast while the audio plays at the proper speed. Needless to say this causes big sync errors.

So here is some information i have been able to find out to help you as displayed from ffdshow video decoder:

INPUT FILE:
Input FOURCC: DX50
Movie FPS: 29.970
Decoder: libavcodec mpeg4
Output colorspace: YV12,adj

and the Video Mixing Renderer (which i also found in the ffdshow menu) says that the average fps = 24. This average changes slightly as more frames are renered but remains around this area.

OUTPUT FILE:
Input FOURCC: MP4V
Movie FPS: 25.000
Decoder: libavcodec mpeg4
Output colorspace: YV12,adj

and the average fps = 29.8. This seems to be the fps value that i can set in PSPEnc as i have also tried encoding the file with ouput fps=14.958 and the filter set to "change fps". But the same problem occured.

I hope this is enough information to help you see my problem. If you need me to look up something else just let me know.

Thanks

jonny
12th January 2006, 09:47
do you have the latest Haali Media Splitter?
http://haali.cs.msu.ru/mkv/

Wingz
14th January 2006, 05:48
Sorry to say that is wasn't that simple... i did already have the lastest splitter. But just so you know here is what i have installed:

ffdshow-20051221
matroska splitter-1.6.33.22
oggds-0995

i did reinstall the matroska splitter with the one from your link and it did not fix the problem...

thanks

jonny
16th January 2006, 11:33
that's strange, i've not the time look deeply, a quick solution could be remuxing everything in an avi, with VirtualDubMod

Drillakilla
12th February 2006, 02:18
is it me or do all videos encoded for the psp come out with ghosting effect. i have tried psp video 9, psp enc, nero recode, all the mp4 files i have encoded look perfect when i play them on my laptop, but when i transfer them to the psp, they come with a gosting effect on fast moving scenes.

is this the case with psp movies?? i have noticed on umds they have a slight ghosting effect but not as bad. I recently started using pspenc, surprsingly not all the videos i have encoded have had that bad ghosting. iv mainly been encoding avi files to mp4. Even some of the movies that i have downloaded off net have had ghosting effect. please please someone verify this for me, as this has been driving me crazy for almost a month now.

damrod
12th February 2006, 07:11
ghosting effect?

i will look on my psp with video...maybe a problem with the screen...but you don't have this problem in games like nfs ...?

jonny
12th February 2006, 11:34
the problem is mainly the psp screen
also using ConvertFPS to fix the framerate can make things slightly worse
raising brightness before encoding can help


Even some of the movies that i have downloaded off net have had ghosting effect

Forum rules (http://forum.doom9.org/forum-rules.htm):
6) No warez, cracks, serials or illegally obtained copyrighted content! Links to content of a questionable nature, asking for, offering, or asking for help/helping to process such content in any way or form is not tolerated.

Drillakilla
12th February 2006, 18:15
how can you increase brightness before encoding?? is there a sciptpart i can add to my avs??

Drillakilla
12th February 2006, 18:25
also you mentioned convert framesps could make it worse?? what are the alternatives to doing this??

i just want to say thanks for the help

jonny
12th February 2006, 18:29
here is a script example:

directshowsource("test.avi")
tweak(bright=32)

bright can go between -255.0 and 255.0

you should try different values to see what you like more


EDIT: changefps gives you less ghosting, but the result will stutter a bit.
(there is no 100% clear solution)

Drillakilla
13th February 2006, 03:09
tried the brightness adhust at different levels, 32 definatly did the job ( picture got a lot of grey though), im going to run some more tests on levels between 20 and 30.

why is it though umd dont have ghosting problem??

thanks for your help mate

also does anyone have a avisynth script for dvd to mp4 conversion?? something that keeps the best quality possible?

jonny
13th February 2006, 09:48
i think umds are slightly preprocessed in a similar way

to frameserve a dvd via avisynth look at this guide:

Guides ->
MPEG-4 (DivX / XviD/ NeroDigital / x264) ->
DGIndex frameserving guide

E.J.
28th February 2006, 22:20
Very good tool Jonny.

BTW, PMP Mod is great!.

I have been doing some experiments with mencoder / ffmpeg

First I encode the video with mencoder, this let me add hardcoded subtitles to the video and other stuff, audio with '-oac copy'

Then i use ffmpeg to generate the mp4 file using as input the file generated by mencoder with '-vcodec copy', and aac audio. Now I have a mp4 file with xvid (mpeg4 ASP) video, and AAC CBR audio.

I'm using the '-f psp' switch in ffmpeg to force a psp compliant mp4, stil when i try to play it with the psp it says the file is incompatible, it plays fine on mplayer, vlc, etc...

The thing is, if the video is reencoded with ffmpeg it works.

Is ffmpeg doing something to the video that mencoder can't?

PD: Keep the awesome work with PMP MOD!, thanks.

jonny
28th February 2006, 23:39
"-vcodec copy" never worked for me too
i've tried to "mux" audio/video in a psp compatible mp4 too, but ffmpeg seems broken for this job
( the only compatible way is encoding directly with it :( )

PS:
thank you! :)

E.J.
1st March 2006, 15:54
As long as i can tell the problem comes from the atom settings ffmpeg adds to the video.

If you encode the video with ffmpeg it adds the correct atom id to the video stream, but when using -vcodec copy ffmpeg doesn't add it nor sets the fourcc to mp4v (unless you use - vtag mp4v).

Im very acustomed to mencoder and haven't been able to get the same results with ffmpeg, especially with 2 pass encoding, thats why im trying to make it this way.

I have read that there is a program named atomchanger, maybe this one can do the magic for me...

PS: You're welcome.