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 convert some.flv or some.avi or some.wmv with FFmpeg to be sure that this video will be playable and seekable in JW Player?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

This is an answer to last comment by you @abrahab.

You don't need to mp4box a file to be able to pseudo stream it via nginx. The MP4 streaming module takes care of it irrespective of positioning of moov atoms (mp4box shifts the moov atom to beginning of file).


Now for the 500 server error, are you using "-frag" option with mp4box? MP4 streaming module can't read fragmented MP4 files. Good use of mp4box for pseudo streaming is to interleave the videos for better seeking. Moov atom shifting is an added advantage.

I always do this to mp4box an FFmpeg-encoded file

MP4Box -add MyVideo.mp4 -isma Myvideo-box.mp4

This will also interleave the MP4 file in 500 milliseconds of chunks by default.

share|improve this answer
    
To do "in-place" file interleaving without having to create a new file, directly use MP4Box -isma -inter 500 Myvideo.mp4 –  Vineet Oct 3 '12 at 5:16
add comment

Generally, you want to create x264 video within an MP4 container, so the following should be enough. Make sure to replace input name and CRF options. The latter sets the quality, where sane values range from 19 to 25 – lower means better quality, but also higher bitrate:

ffmpeg -i input.avi -c:v libx264 -crf 22 -c:a libfaac -movflags faststart output.mp4

You can also use Handbrake for encoding if you like the GUI way.

Now, what you need to do is move the MP4 container's MOOV atom to the beginning. This atom (in essence, a unit of data in the MP4 container) will contains important metadata about the video/audio streams themselves. -movflags faststart should do exactly that.

If your FFmpeg version doesn't have this option, consider upgrading. If you cannot upgrade, you can achieve the same thing with any of the below tools:

  • QTIndexSwapper, an Adobe AIR application

  • MP4Box, free and open source, running a command similar to the following, where you can change the interval (here, 500):

    mp4box -inter 500 input.mp4

  • qt-faststart in Python, which works everywhere where Python is installed.

    qtfaststart input.mp4

That's about it. The rest of the toolchain is actually more complicated than that. You need to properly set up your web server so it handles h.264 content if you want HTTP pseudo-streaming. Check JW Player's documentation for more:

Video Delivery: HTTP Pseudo-Streaming | LongTail Video | Home of the JW Player

You need the h.264 streaming module for Apache, Lighttpd, IIS and NginX and then continue with the JW Player setup. As this is not in the scope of this question and a far broader topic, any problems that might occur during streaming need proper debugging – but the video encoding stage should not matter that much.

share|improve this answer
    
thanks, I do all the same way, but seems the problem still with the video :( I do ffmpeg -i 1.flv -vcodec libx264 -f mp4 -an -g 1 -f mp4 -g 30 -level 3 new.mp4 then mp4box and mp4 can not seek and nginx report 500 internal server error for start parameter more that 0. when video coded without -vcoded libx264 (default mp4 coder) all work file (but quality! sick!) :( (sorry, now, not allowed to upvote you answer) –  abrahab Jun 18 '12 at 20:31
    
This seems like a h.264 plugin issue with NginX rather than any video conversion problem. I'm not the expert in web video streaming per se, but I see you already asked about this on Stack Overflow? stackoverflow.com/questions/11079748/… –  slhck Jun 18 '12 at 20:36
    
I am also thinking that maybe nginx can not read this video format properly. video from youtube is also played well. yes, I am asked on stack about nginx issue, but seems no answers. :( –  abrahab Jun 18 '12 at 20:42
    
+1 for -movflags faststart exactly what I needed –  andrew Dec 9 '13 at 1:26
add comment

You can try this with ffmpeg:

ffmpeg.exe -i "INPUT_FILE.AVI" -threads 2 -s 800x600 -r 25.00 -threads 1 -pix_fmt yuv420p -g 300 -qmin 3 -b 2048k -async 1 -acodec pcm_s16le -ar 22050 -ac 1 -ab 128k -y "OUTPUT_FILE.mp4"
share|improve this answer
4  
22 kHz PCM Stereo audio for internet streaming video? Doesn't sound too efficient. And why would you set the audio bitrate to 128k then? –  slhck Aug 26 '12 at 9:56
    
@slhck , you can change 22k to 44k replacing "-ar 22050" with "ar 44100" –  SEARAS Nov 10 '12 at 10:41
    
@SEARAS The problem isn't the sampling rate. It's the fact that the audio is uncompressed PCM stereo. For internet streaming. That doesn't figure. –  slhck Nov 10 '12 at 10:42
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.