Thanks for the info about order of options @bodhi.zazen and @LordNeckbeard. Apparently the libvpx encoder is a little more picky about that. When I added -threads option after -c:v libvpx, it visibly uses more cores according to top.
-threads 0 only uses 1 core, -threads 8 uses 2 cores, and -threads 16 uses 4 cores. I've tried using a higher number, but the encoder says more than 16 threads is not recommended, and doesn't use any more CPU. Encoding speed itself is about twice as fast now. Thanks again for the help!
It is well worth running a deinterlacing video filter during your video encode and this may very well lessen some of the odd screen effects that you are seeing in your output video. A second thought, unrelated to motion artefact but well worth adding in, is the use of a de-noising filter.
1. Deinterlacing:
For FFmpeg the best and fastest choice is yadif
which in the usual quirky geek fashion simply stands for 'Yet Another DeInterlacing Filter'!
yadif
can be used with no options or you can specify an option for each of 3 fields:
- mode: The basic interlacing mode to adopt
- parity: The picture field parity assumed for the input interlaced video
- deint: Specify which frames to deinterlace
The safe defaults can be specified on the FFmpeg command line as:
-vf yadif=0:-1:0
If you wish to alter these all of the deeper detail is contained here:
FFmpeg Filter Documentation: yadif
https://ffmpeg.org/ffmpeg-filters.html#yadif-1
A further deinterlacing filter called mcdeint
(motion-compensation deinterlacing) can also be applied but you may find this painfully slow. A typical command line for use of this filter would be:
-vf yadif=1:-1:0,mcdeint=2:1:10
And again the fine detail of the mcdeint
options can be seen in the FFmpeg documentation:
FFmpeg Filter Documentation: mcdeint
https://ffmpeg.org/ffmpeg-filters.html#mcdeint
2. Denoising:
A final though that may well be worth some experimentation is the use of a denoising filter, although this should not effect motion artefact it is still a well worth addition. Under FFmpeg there are a few choices but one well worth looking at is nlmeans
(denoise frames using Non-Local Means algorithm). You will need the very latest FFmpeg for this one.
To use this in the easiest command line try the following:
-vf yadif=0:-1:0,nlmeans
There is a hit with nlmeans
in terms of encoding time, not as severe a penalty as is seen with mcdeint
but still a consideration...
If you have an older copy of FFmpeg with no access to this newest filter there is an older denoise filter that can safely be used with trust in the sane defaults:
-vf yadif=0:-1:0,hqdn3d
I note on my own system that hqdn3d
is very, very much faster than the newer nlmeans
. Better? Well I suspect that is a debate for another forum :)
And hopefully a combination of any of these thoughts will solve your problem...
References:
Best Answer
As always with FFmpeg there are a number of choices to make, and I have narrowed this down a little further to create a clear answer:
1. Your input file's codecs are supported in TS container:
Examine your input file with FFmpeg as follows:
If the file contains codecs that are well supported in a TS container, for example H.264 video and AAC sound, you can simply copy the streams across:
This will give great results although you may need to vary this command line depending on your actual use of the output file (streaming, a certain playback device etc).
2. Your input file's codecs are not supported in a TS container:
If your input file contains codecs that are not well supported in a TS container you will need to re-encode either video or audio streams or both. The default codecs for FFmpeg and the TS container are mpeg2video and mp2 sound. If you are happy to go with these default codecs the following will give great results:
This certainly gave quite reasonable results on my system and should on yours as well...
3. You wish to segment your file for HTTP Live Streaming (HLS):
And finally you may wish to produce a segmented TS file with playlist for use with HTTP Live Streaming (HLS). There are as always several ways to accomplish this but the sample command line below will work well for input files whose codecs are supported in a TS container:
If you wish to alter the codecs of the input file simply add the required settings in place of
-codec copy
, I believe that H.264 and AAC are popular codecs for this type of streaming. A lot of room for experimentation with the segment options which are described here...Notes: