3

I am trying to achieve real-time transcoding of mkv / H264 videos on a low-end (slow CPU) platform.

Using the following command line as a testing harness:

avconv -i test.mkv -c:v mjpeg -q:v 3 -c:a libmp3lame -f (codec) -y /dev/null

I get the following results: 37fps using the rawvideo codec, 21fps using the mpeg4 codec.

So I am searching for an "intermediary" codec, which would provide faster compression. I do not need too much of a compression ratio, since resulting data will not be stored, but directly streamed by an UPnP server (but, obviously, not saturating my network with raw video is desirable).

Any advice?

Regards.

2
  • If compression ratio isn't a factor, why not use rawvideo? If compression ratio does matter, what complexity/compression performance are you looking for? Commented Jun 23, 2013 at 5:16
  • I don't think I can embed rawvideo data in an AVI container, can I? With respect to performance, I am searching for a compression format acceptable for an AVI container, and which avconv can compress at real-time or better fps (so, > 25fps) on my platform.
    – oparisy
    Commented Jun 23, 2013 at 10:51

1 Answer 1

1

You can try using the MPEG2 codec

MPEG2 is quite fast to encode. This should work -c:v mpeg2video -r 25 -b:v 8192k increasing the bitrate should give the rate control more slack and give faster encoding speed. You can also try the -intra option which disables motion estimation at the cost of significantly higher bitrate. If that's not enough there should be a quantization step parameter which you can use to speed up the encoding at expense of visual quality.

You can also try lower resolution H264 with ultrafast preset

I'm not sure how low-end you mean when you say low-end, I'm successfully transcoding to 720p H264 in realtime on a Core 2 Duo 2ghz CPU... so I'm providing this if your idea of low-end is similar to my idea of low-end :)

The libx264 codec accepts presets to the encoder which trade of encoding speed for bitrate at constant visual quality.

You could try with the fastest preset:

-c:v libx264 -preset ultrafast -tune zerolatency -profile high10  \
    -bsf:v h264_mp4toannexb

(The -bsf:v parameter is necessary if you're going to stream)

You can also try playing with the -cbr parameter, it controls bit allocation and thus visual quality/bitrate. The default value is 23; 0 is lossless and 51 is worst quality/lowest bitrate.

The resolution plays a big role in encoding speed and I've found that a lower resolution h264 video that has been upsampled looks comparable to mpeg2 that has not been downsampled (at a much lower bitrate and hopefully faster encoding speed, don't quote me on that :3).

So you can try playing with that as well:

-filter:v scale=-1:480

This will re-scale your video to be 480 lines high and keep the same aspect ratio.

(I just setup transcoding to H264 myself, here: Realtime transcoding to H264+AAC in Matroska container if you want to look.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .