PDA

View Full Version : ffmpeg ipod encoding


Bear
20th February 2008, 16:32
I want to covnert some video which can playable on ipod by using ffmpeg to encode. I use the following command which copy from winff and it works fine:

-r 29.97 -vcodec h264 -s 640x480 -aspect 4:3 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -b 1000k -maxrate 1250k -bufsize 4M -bt 256k -refs 1 -coder 0 -me umh -me_range 16 -subq 5 -partitions +parti4x4+parti8x8+partp8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -qcomp 0.6 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -acodec aac -ab 80k -ar 48000 -ac 2

But I want to use crf (constant rate factor) to encode, so I change the command to :

-r 29.97 -vcodec h264 -s 640x480 -aspect 4:3 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -crf 23 -bufsize 4M -bt 256k -refs 1 -coder 0 -me umh -me_range 16 -subq 5 -partitions +parti4x4+parti8x8+partp8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -qcomp 0.6 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -acodec aac -ab 80k -ar 48000 -ac 2

I only replace "-b 1000k -maxrate 1250k" with -crf 23. The result is, the video bitrate is always around 250k and the final result looks terrible.

Can any ffmpeg knowledagable people to give me some tips? Thanks a lot.

Southstorm
20th February 2008, 18:36
Have you tried a lower -crf rate? 17-21 are typically decent, especially for viewing on an iPod.

teddg
21st February 2008, 14:44
I got the same results -- poor quality and very low bitrate, lowering the crf rate didn't help much.

changing -qmax 51 to 52, or deleting "-qmin 10 -qmax 51 -qcomp 0.6" both resulted in a good video file, but then there were "underflow" errors on the command line.

Southstorm
21st February 2008, 16:32
What about removing the "-bt 256k" setting? Since you're not using a defined bitrate now, this might confuse the encoder.

Bear
22nd February 2008, 03:23
I found the solution by testing the variable one by one. I posted it at: http://biggmatt.com/winff-forums/index.php?topic=98.0

After some testing, I finally make crf working, here is the command:

ffmpeg -threads 4 -i INPUT -r 29.97 -vcodec h264 -s 320x240 -aspect 4:3 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -crf 24 -bt 256k -refs 1 -coder 1 -me umh -me_range 16 -subq 5 -partitions +parti4x4+parti8x8+partp8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -acodec aac -ab 32k -ar 48000 -ac 2 OUTPUT

The result is much better then average bitrate method. I set a rather low sound bitrate because sound quality is not really important for that movie. You can change the crf value if you want to archive even better quality.

Don't you think the movie can work with ipod? I don't have a ipod to test

there are 2 things that prevent me to make the crf encode working.

1. -b 1000k -maxrate 1250k -bufsize 4M
2. -qcomp 0.6

At first I only removed -b 1000k -maxrate 1250k. Then add -crf 23. But it ddin't work. Then I test it one by one to see which one cause the problem. I finally found -bufsize 4M and -qcomp 0.6.

Hope this help.

halsboss
22nd February 2008, 10:17
Is there a PAL 25fps version of that commandline ? :)

Bear
26th February 2008, 02:36
Just want to make some corrections of my command:

ffmpeg -threads 4 -i INPUT -r 29.97 -vcodec h264 -s 320x240 -aspect 4:3 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -crf 24 -bt 256k -refs 1 -coder 0 -me umh -me_range 16 -subq 5 -partitions +parti4x4+parti8x8+partp8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -acodec aac -ab 32k -ar 48000 -ac 2 OUTPUT

-coder should be "0" instead of "1".

teddg
26th February 2008, 18:44
Just want to make some corrections of my command:

ffmpeg -threads 4 -i INPUT -r 29.97 -vcodec h264 -s 320x240 -aspect 4:3 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -crf 24 -bt 256k -refs 1 -coder 0 -me umh -me_range 16 -subq 5 -partitions +parti4x4+parti8x8+partp8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -trellis 2 -sc_threshold 40 -i_qfactor 0.71 -acodec aac -ab 32k -ar 48000 -ac 2 OUTPUT

-coder should be "0" instead of "1".

I don't have a ipod to test

This worked on my ipod and loaded into itunes with no trouble. Tested at 320px wide, 640px and 704px. (for some reason I thought ipods were limited to 640px width, but apparently not).

halsboss
1st March 2008, 00:53
Great ! Just wondering if this aligns in some way with http://forum.doom9.org/showthread.php?p=1077675#post1077675

NanoRip
3rd March 2008, 18:43
Here (http://nanorip.googlepages.com/) is a program I've written for my personal ipod stuff. I'm new to encoding and programming, so any feedback is appreciated.

Thanks Bear for that crf bat - I've included it in nanorip's custom profiles.