I tried it with FFmpeg version 0.8.5, using an AVI input file just like you.
The following command produced correct results:
ffmpeg -i 1.avi -ss 00:00:05 -t 00:00:01.50 -vcodec libx264 -vpre default -acodec libfaac out1.mp4
Here are some tips to get it working:
Update to the latest version of FFmpeg.
For Ubuntu, follow the tutorials here. I've been using them myself.
On OS X, install FFmpeg using Homebrew, by calling brew install ffmpeg
.
On Windows, just download the precompiled versions.
Use the correct length format.
Note that the duration format is using decimal points, not commas, e.g. hh:mm:ss[.xxx]
.
Remove the -threads 0
option.
Enabling -threads 0
however gave me the error "nal buffer is too small". I don't even know why they allow a value of zero here, and unless you have a specific reason to do so, I would just leave this argument out. Ideally, it should enable auto-threads
in libx264
, but there might be a bug I'm not aware of.
Encode without B-pictures.
Depending on the size of the output video, I don't know if libx264
is even able to reliably produce output using B-pictures that reference one or more intra-coded pictures. This might even lead to the artifacts you describe.
You can try to disable B-pictures (or "B-frames") with -bf 0
.
Thank you for your response. My ffmpeg version is 0.5.1, it's from ubuntu reps =(. Are you compiled ffmpeg yourself? I will try to cut my video considering your advice. – Rnd_d – 2011-11-14T14:45:49.500
@Rnd_d Yes, I did. It would make sense to re-compile from source, which isn't that hard on Ubuntu. There are excellent tutorials here, just make sure you open the one for your Ubuntu version. I've been using these tutorials to compile all FFmpeg versions I'm using for Ubuntu.
– slhck – 2011-11-14T14:47:55.130Thank you very very much! I've compiled last version of ffmpeg usgin tutorials you considered. Quality of encoded video and audio has improved! Disabling b-frames actually got rid of artifacts. – Rnd_d – 2011-11-14T16:41:58.297
You're welcome! If you have any questions about the flags FFmpeg and libx264 use, there's a good guide here.
– slhck – 2011-11-14T21:38:38.470