WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: cpu shuts off while encoding using ffmpeg  (Read 4370 times)

Offline manit123

  • Sr. Member
  • ****
  • Posts: 315
cpu shuts off while encoding using ffmpeg
« on: November 23, 2013, 01:00:34 AM »
It seems that it may be overheating because same effects were observed in windows xp on same computer.
So I tried to use cpulimit in linux
Compilation  gave following error
Quote
$ gcc -o cpulimit cpulimit.c
/tmp/ccOmXgMd.o: In function `compute_cpu_usage':
cpulimit.c:(.text+0x72f): undefined reference to `clock_gettime'
/tmp/ccOmXgMd.o: In function `main':
cpulimit.c:(.text+0x13c4): undefined reference to `clock_gettime'
cpulimit.c:(.text+0x13ec): undefined reference to `clock_gettime'
see attached code for further details (537lines)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11540
Re: cpu shuts off while encoding using ffmpeg
« Reply #1 on: November 23, 2013, 01:41:43 AM »
Hi manit123
What happens if you do:
Code: [Select]
gcc -o cpulimit cpulimit.c -lrt

Offline manit123

  • Sr. Member
  • ****
  • Posts: 315
Re: cpu shuts off while encoding using ffmpeg
« Reply #2 on: November 24, 2013, 04:49:18 AM »
Quote
$ tce-load -wi gcc.tcz
libmpc.tcz.dep OK
mpfr.tcz.dep OK
Downloading: gmp.tcz
Connecting to repo.tinycorelinux.net (89.22.99.37:80)
gmp.tcz              100% |*******************************|   292k  0:00:00 ETA
gmp.tcz: OK
Downloading: mpfr.tcz
Connecting to repo.tinycorelinux.net (89.22.99.37:80)
mpfr.tcz             100% |*******************************|   180k  0:00:00 ETA
mpfr.tcz: OK
Downloading: libmpc.tcz
Connecting to repo.tinycorelinux.net (89.22.99.37:80)
libmpc.tcz           100% |*******************************| 45056   0:00:00 ETA
libmpc.tcz: OK
Downloading: binutils.tcz
Connecting to repo.tinycorelinux.net (89.22.99.37:80)
binutils.tcz         100% |*******************************|  2164k  0:00:00 ETA
binutils.tcz: OK
Downloading: gcc_libs.tcz
Connecting to repo.tinycorelinux.net (89.22.99.37:80)
gcc_libs.tcz         100% |*******************************|   304k  0:00:00 ETA
gcc_libs.tcz: OK
Downloading: gcc.tcz
Connecting to repo.tinycorelinux.net (89.22.99.37:80)
gcc.tcz              100% |*******************************| 17224k  0:00:00 ETA
gcc.tcz: OK
tc@box:/tmp/tce/optional$ tce-load -wi make.tcz
Downloading: make.tcz
Connecting to repo.tinycorelinux.net (89.22.99.37:80)
make.tcz             100% |*******************************| 90112   0:00:00 ETA
make.tcz: OK
$ cd ~/cpulimit-1.1/
$make

gcc -o cpulimit cpulimit.c -lrt -Wall -O2
cpulimit.c:32:20: fatal error: getopt.h: No such file or directory
compilation terminated.
make: *** [cpulimit] Error 1
$ gcc -o cl cpulimit.c -lrt
cpulimit.c:32:20: fatal error: getopt.h: No such file or directory
compilation terminated.
« Last Edit: November 24, 2013, 04:56:53 AM by manit123 »

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14761
Re: cpu shuts off while encoding using ffmpeg
« Reply #3 on: November 24, 2013, 06:06:03 AM »
You need to load compiletc rather than gcc

Offline manit123

  • Sr. Member
  • ****
  • Posts: 315
Re: cpu shuts off while encoding using ffmpeg
« Reply #4 on: November 24, 2013, 11:49:01 PM »
that helped.
Mark this thread as solved.
« Last Edit: November 25, 2013, 12:06:15 AM by manit123 »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11540
Re: cpu shuts off while encoding using ffmpeg
« Reply #5 on: November 25, 2013, 10:18:56 AM »
Hi manit123
Quote
Mark this thread as solved.
It is the responsibility of the person who started the thread to mark it as solved. Go to the original post, click  Modify, and
add  [SOLVED]  to the subject line.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: cpu shuts off while encoding using ffmpeg
« Reply #6 on: November 25, 2013, 01:36:03 PM »
A cpulimit extension may be a welcomed contribution to repo.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline manit123

  • Sr. Member
  • ****
  • Posts: 315
Re: cpu shuts off while encoding using ffmpeg
« Reply #7 on: December 14, 2013, 08:33:25 AM »
Sorry for my late reply.
I have noticed ffmpeg taking > 80% CPU time in 'top' results.
The compiled binary gave 'segmentation fault' in all trials (run as root , use pid , use process name , launch process with cpulimit) as suggested at http://cpulimit.sourceforge.net/.
You can try it yourself . 

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: cpu shuts off while encoding using ffmpeg
« Reply #8 on: December 14, 2013, 09:00:16 AM »
I have noticed ffmpeg taking > 80% CPU time in 'top' results.
What do you mean? CPU percentage vs. CPU time values are distinct.
Quote
The compiled binary gave 'segmentation fault' in all trials
Which process segfaults, ffmpeg or cputime?
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline manit123

  • Sr. Member
  • ****
  • Posts: 315
Re: cpu shuts off while encoding using ffmpeg
« Reply #9 on: December 22, 2013, 08:04:14 AM »
Here is stacktrace of cpulimit
Code: [Select]
$ gdb cpulimit
GNU gdb (GDB) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/tc/cpulimit-old/cpulimit-1.1/cpulimit...(no debugging symbols found)...done.
(gdb) run --limit 40 ffmpeg -i '/mnt/sda3/recent/video/Badminton Men_s Singles Final - Malaysia Vs China at London 2012 Olympic Games.mp4' -vcodec libx264 -acodec libmp3lame /mnt/sda3/recent/video/mmfs-old.mp4 
Starting program: /home/tc/cpulimit-old/cpulimit-1.1/cpulimit --limit 40 ffmpeg -i '/mnt/sda3/recent/video/Badminton Men_s Singles Final - Malaysia Vs China at London 2012 Olympic Games.mp4' -vcodec libx264 -acodec libmp3lame /mnt/sda3/recent/video/mmfs-old.mp4
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.

Program received signal SIGSEGV, Segmentation fault.
0xb761ce42 in ?? () from /lib/libc.so.6
(gdb) bt
#0  0xb761ce42 in ?? () from /lib/libc.so.6
#1  0xb761cc92 in strtol () from /lib/libc.so.6
#2  0x08048b26 in main ()

If you get latest svn . Then  it works.

If I want to create extension of this program.
I know two ways
(1)make a tcz which just contains compiled i386 binary in /bin folder. Easy . I somehow forgot - how to do this  ? (I had created a oxford tcz after I managed to install application from my CD )
(2)Dependency will be compiletc.tcz & svn. Then script should download latest code by running
$svn checkout https://svn.code.sf.net/p/cpulimit/code/trunk cpulimit
because
Quote
$ svn checkout https://cpulimit.svn.sourceforge.net/svnroot/cpulimit/trunk cpulimit
svn: Repository moved permanently to 'https://svn.code.sf.net/p/cpulimit/code/trunk'; please relocate
This will create folder cpulimit containing following files
Quote
Makefile     cpulimit.c   list.h       process.h    procutils.h
README        list.c     process.c    procutils.c
Now run
$cd cpulimit ; make ; sudo cp cpulimit /bin
This is better as it compiles binary according to user processor.
But , this heavy on requirement & after reading https://code.google.com/p/tcztools/ -> I am still confused.
« Last Edit: December 22, 2013, 08:07:05 AM by manit123 »