Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I use FFmpeg to convert a flash video (.flv) to an OGG Theora video to display in HTML 5?


When I tried using

ffmpeg -i dayinthelife.wmv -vcodec libtheora -acodec libvorbis -b 750k dayinthelife.ogv

it generated the following output.

Seems stream 1 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 29.97 (30000/1001)
Input #0, asf, from 'dayinthelife.wmv':
  Duration:output 00:01:14.19, start: 5.000000, bitrate: 3754 kb/s
    Stream #0.0: Audio: wmav2, 48000 Hz, stereo, s16, 192 kb/s
    Stream #0.1: Video: wmv3, yuv420p, 1440x1080, 24000 kb/s, 29.97 tbr, 1k tbn, 1k tbc
Output #0, ogg, to 'dayinthelife.ogv':
    Stream #0.0: Video: libtheora, yuv420p, 1440x1080, q=2-31, 500 kb/s, 90k tbn, 29.97 tbc
    Stream #0.1: Audio: vorbis, 48000 Hz, stereo, s16, 64 kb/s
Stream mapping:
  Stream #0.1 -> #0.0
  Stream #0.0 -> #0.1
[libtheora @ 0x2551920]theora_encode_init failed
Error while opening codec for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height
share|improve this question
    
Does this happen with any FLV file? (Note that you're actually using a WMV file as input here). Which version of FFmpeg are you using? –  slhck Nov 1 '11 at 19:15
    
It happens with any of the three flv files and 2 wmv files I've tried. I'm reinstalling ffmpeg now based on the guide you gave me in your deleted answer. –  Yitzchak Nov 1 '11 at 19:24
    
Please try that and see if it works. I've had mixed results with the various FFmpeg versions that you get from the repositories. –  slhck Nov 1 '11 at 19:36
    
It does work, though after reading up on it, I used ffmpeg2theora for the rest. –  Yitzchak Nov 2 '11 at 19:30
    
I see. I undeleted my answer if you still find it useful, otherwise you could self-answer and tell us more about ffmpeg2theora! :) –  slhck Nov 2 '11 at 19:31
show 1 more comment

2 Answers

up vote 1 down vote accepted

That's relatively easy:

ffmpeg -i input.flv -vcodec theora -acodec vorbis output.ogv

Specify the desired target bitrate with the -b option, for example -b 1M or -b 512K.


Note that you need to compile ffmpeg with support for Theora and Vorbis. If yours does not have these options, follow the guide here to compile it with the appropriate libraries.

More specifically, these flags: --enable-libtheora --enable-libvorbis.

share|improve this answer
    
I tried that before asking. I got the error [libtheora @ 0x2551920]theora_encode_init failed and an empty output file. What do I do about that? –  Yitzchak Nov 1 '11 at 18:26
add comment

This is a sort of a tangeant, but it will get the job done.

Handbrake is an free encoder built on FFmpeg that will convert a number of video formats to MP4. If you specify that you want to have your output "Web Optimized" it will give you an HTML5 compatible video in MP4.

Here are the steps to get your video in Ogg/Theora.

  • Open Handbrake
  • Specify "Web Optimized"
  • Get the commandline output that Handbrake would run, but don't run it.
  • In a text editor, change the libraries from MP4 to the Ogg/Theora libraries.
  • Run the modified output through FFmpeg.
share|improve this answer
    
If FFmpeg can't encode the video in the first place, I don't know if that would really help. –  slhck Nov 1 '11 at 22:32
    
It is more likely the case that the correct options have not been passed to FFmpeg. However, there is also a chance that there is corruption in the file you are trying to rerender. –  JonathanEyre Nov 2 '11 at 13:15
    
The very basic options suffice to convert, I've successfully done it with my FFmpeg installation (e.g. ffmpeg -i input.flv -vcodec libtheora -acodec libvorbis output.ogv) – I suspect an erroneous input file or FFmpeg configuration. –  slhck Nov 2 '11 at 13:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.