Opened 4 years ago

Closed 4 years ago

#657 closed defect (invalid)

xvid -- no multithreaded encoding.

Reported by: dE_logics Owned by:
Priority: normal Component: undetermined
Version: 0.7.7 Keywords: xvid threads
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I've xvid version 1.3.2, which supports multithreading, but I get only 1x cpu usage even when using -threads 2 -

ffmpeg -vf scale="a*234:234" -i FULL_HD_porsch.mp4 -threads 2 -maxrate 300 -bufsize 4000k -r 25 -vcodec libxvid -aq 1 -acodec libmp3lame ~/FULL_HD_porsch.avi

Change History (11)

comment:1 Changed 4 years ago by cehoyos

  • Cc de.techno@gmail.com removed
  • Keywords threads added; multi thread removed

Please provide a command line and complete, uncut console output for all (non-build) reports on this bug tracker!

(You do know that FFmpeg contains a native MPEG-4 ASP encoder that is not known to be worse than xvid?)

What happens if you (slowly) increase the thread count? With the native encoders, you have to use a higher thread count than the number of cores you want to use (same as make -j).
For me, -vcodec libxvid -threads 8 uses many threads, but it significantly hurts performance over -threads 1.

In case I understood correctly that you are writing down your experience somewhere:
Please note that 0.7 uses a deprecated syntax that gets outdated, you should definitely use current git head for tutorials and similar.

comment:2 follow-up: Changed 4 years ago by dE_logics

I'm using xvid cause of device compatibility reasons.

Right now I'm compiling from GIT.

comment:3 Changed 4 years ago by dE_logics

It works.

comment:4 in reply to: ↑ 2 Changed 4 years ago by cehoyos

Replying to dE_logics:

I'm using xvid cause of device compatibility reasons.

Could you elaborate?
Does "ffmpeg -i input -vtag XVID -vcodec mpeg4 -vf scale="a*234:234" out.avi" work?

comment:5 follow-up: Changed 4 years ago by dE_logics

Yes, but there's no use using the mpeg4 codec. First it's not multithreaded, second the compression is not as good.

comment:6 in reply to: ↑ 5 Changed 4 years ago by cehoyos

Replying to dE_logics:

Yes, but there's no use using the mpeg4 codec.

First it's not multithreaded

Multi-threading works fine here for the native FFmpeg MPEG-4 ASP encoder.

second the compression is not as good.

As said, this is not generally known. A reproducible test case that shows this would be very welcome!

comment:7 follow-up: Changed 4 years ago by dE_logics

That's strange. Here's my command line -

ffmpeg -t 00:00:30 -i game/media\(reserve\)/test\ media/FULL_HD_porsch.mp4 -vf scale='640:trunc((640/a)/2)*2' -sameq -r 25 -threads 16 -vcodec mpeg4 -an ~/test.avi

On 2 CPUs I get at most 52% CPU usage.

AND removing the scale filter gives me at most 60% cpu usage (16 threads), whereas using 16 threads I get ~80% usage on xvid.

comment:8 Changed 4 years ago by dE_logics

No... it's a bit different.

Using mpeg4 without the scale filter gives at most 65% usage, but using xvid without scale filter and with 64 threads gives upto 72% and is always greater than 65%. Using the scale filter with xvid and using 16 threads gives upto 65% of usage.

comment:9 in reply to: ↑ 7 Changed 4 years ago by cehoyos

Replying to dE_logics:

ffmpeg -t 00:00:30 -i game/media\(reserve\)/test\ media/FULL_HD_porsch.mp4 -vf scale='640:trunc((640/a)/2)*2' -sameq -r 25 -threads 16 -vcodec mpeg4 -an ~/test.avi

Could you try (for improved encoding quality that needs more CPU cycles):

ffmpeg -t 00:00:30 -i game/media\(reserve\)/test\ media/FULL_HD_porsch.mp4 -vf scale='640:trunc((640/a)/2)*2' -sameq -r 25 -threads 16 -vcodec mpeg4 -an -dia_size 4 -mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 ~/test.avi

comment:10 follow-up: Changed 4 years ago by dE_logics

That increases the size of the video by a lot.

ls -l -h
total 31M
-rw-r----- 1 de de 20M Nov 24 20:37 test.avi
-rw-r----- 1 de de 12M Nov 24 20:38 test_xvid.avi

BTW what's the bad with xvid? It's better, and both mpeg4 and xvid being opensource, mpeg4 looses it's purposes.

comment:11 in reply to: ↑ 10 Changed 4 years ago by cehoyos

  • Resolution set to invalid
  • Status changed from new to closed

Replying to dE_logics:

That increases the size of the video by a lot.

Your command line does not ask for a specific size...

BTW what's the bad with xvid?

Nothing.

It's better,

As said, this is not correct (but it is likely that it is slightly more difficult to use the native mpeg4 encoder because it allows more fine-tuning for the user).

and both mpeg4 and xvid being opensource, mpeg4 looses it's purposes.

Some people prefer less restrictive licenses...

I am closing this issue because it was about multi-threaded xvid which turned out to work fine iiuc.
Please do not hesitate to ask questions about FFmpeg usage either here or on ffmpeg-users (where more people will be able to answer).

Last edited 4 years ago by cehoyos (previous) (diff)
Note: See TracTickets for help on using tickets.