09 December 2009

ffmpeg2theora

Playing with my new video camera toy, I try to transcode all the clips from h.264/AAC .MOV to Theora using ffmpeg2theora with its default settings, however I find the size of the resulting file unpredictable: my first clip was filmed inside and was very short, so after the transcode the file size shrinked from ~24MB to 3MB. Excited by this, I tried the same transcoding with a large clip, filmed outside but much to my disappointment, the result was an expansion from ~421MB to ~570MB. Finally, a video of the fish tank shrinked from ~118MB to ~62MB. I can't see any pattern here, what I am supposed to to when uploading the next clip to something like YouTube? (I want the shortest upload time)

6 comments:

  1. First have you tried transmageddon? I'm not sure why we don't have that packaged but you can get rpm's at http://www.linuxrising.org/transmageddon/files/rpms/ . That might at least tell you if ffmpeg has sane defaults. Second, lighting has a lot to do with how good or bad a scene is encoded. Compression works on series of similar colors or at least that is a simplistic description. So, factors such as lighting will contribute a lot to how a scene is compressed. Also, the problem with encoding from one compressed format to another is that the source might actually distort the scene enough to make the destination format inefficent. If Theora is assuming it wants to recreate a live scene as close as possible it might choke a bit when the input contains a lot of compression artifacts. Or it might be the other way around where we assume most of Theora will be used for transcoding it might perform suboptimally with the defaults for more pristine inputs. It all depends what the developers used as inputs and what there assumption are. You would have to ask Monty about that. In any case I am sure they would like to hear about your usecases directly to see if they can improve on the encoder. I suggest you contact the Theora people on irc and file a bug if they think the issue is on their end and not just the ffmpeg encoder not using sane defaults.

    ReplyDelete
  2. Good suggestions J5, thanks! Is not the ffmpeg encoder, as I deal here only with decoding h.264 and encoding with theora.
    I will look at transmageddon and maybe try to talk with the Theora people, but for the moment I got an URGENT priority: the last yum update totally broke my F12 desktop, I must find a way to fix it before doing anything else.

    ReplyDelete
  3. You can ſimply uſe a adequate command line option! The ſtadard of ffmpeg2theodra is the /quality/ baſed ſetting -v 6, where 10 ſtands for the beſt quality and 0 for the ſmalleſt fileſize; but there’s alſo a /fixed bitrate/ variant inſtead, juſt uſe -V 200 (kb/s – or whatever elſe you want!). The ſame logic goes for the audio: ſtandard is -a 1 (with -2 (may be really ugly) up to 10 (beſt)) and -A 32 (kb/s fixed bitrate).

    ReplyDelete
  4. Indeed, it seems to be something about the variable bitrate, I cut 30 seconds from the start of the large (421MB) file, and ffmpeg2theora compressed it from 48MB to 37MB

    ReplyDelete
  5. Run it with -v6 ( a good compromise between video quality and file size).

    ReplyDelete
  6. @Anonymous: So, your advice is to run it with an unnecessary flag which redundantly specifies the quality setting? (Pssst: -v6 is the *DEFAULT*) ;)

    ReplyDelete