2010/02/10

Experience on FFmpeg








1. Download ffmpeg 0.5 from official website. 
2. Extract to some working folder. 
3. Complie and install ffmpeg per INSTALL document.
    $ ./configure
    $ ./make
    $ sudo make install


$ ls -al /usr/local/bin/
   :
-rwxr-xr-x  1 root root 5799064 2010-02-09 13:58 ffmpeg
-rwxr-xr-x  1 root root 5782616 2010-02-09 13:58 ffserver
   :



$ ls -al /usr/local/lib/
   :
-rw-r--r--  1 root root  21996316 2010-02-09 13:58 libavcodec.a
-rw-r--r--  1 root root    222218 2010-02-09 13:58 libavdevice.a
-rw-r--r--  1 root root   6363704 2010-02-09 13:58 libavformat.a
-rw-r--r--  1 root root    218412 2010-02-09 13:58 libavutil.a
   :



$ ffmpeg -i NBA.rmvb -t 3 -s 320x240 -y 1235.avi
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration:
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 0 / 52.20. 0
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  built on Feb  9 2010 13:57:50, gcc: 4.4.1
[NULL @ 0x8bbe3b0]Unsupported video codec
Input #0, rm, from 'NBA.rmvb':
  Duration: 00:23:49.98, start: 0.000000, bitrate: 718 kb/s
    Stream #0.0: Audio: aac, 32000 Hz, stereo, s16, 64 kb/s
    Stream #0.1: Video: rv40, yuv420p, 848x480, 639 kb/s, 12 tbr, 1k tbn, 12 tbc
    Stream #0.2: Data: 0x0000
Output #0, avi, to '1235.avi':
    Stream #0.0: Video: mpeg4, yuv420p, 320x240, q=2-31, 200 kb/s, 90k tbn, 12 tbc
    Stream #0.1: Audio: mp2, 32000 Hz, stereo, s16, 64 kb/s
Stream mapping:
  Stream #0.1 -> #0.0
  Stream #0.0 -> #0.1
Press [q] to stop encoding
frame=   22 fps=  0 q=3.3 Lsize=     168kB time=3.02 bitrate= 455.7kbits/s  
video:132kB audio:24kB global headers:0kB muxing overhead 8.056301%
 
$ ls -al NBA.rmvb 1235.avi
-rw-r--r-- 1 yenping yenping    172272 2010-02-10 11:43 1235.avi
-rwxr-xr-x 1 nobody  nogroup 128482171 2010-02-09 14:20 NBA.rmvb


$ ffmpeg -i 1235.avi
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration:
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 0 / 52.20. 0
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  built on Feb  9 2010 13:57:50, gcc: 4.4.1
Input #0, avi, from '1235.avi':
  Duration: 00:00:03.08, start: 0.000000, bitrate: 446 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 12 tbr, 12 tbn, 12 tbc
    Stream #0.1: Audio: mp2, 32000 Hz, stereo, s16, 64 kb/s
At least one output file must be specified
 



Play 1235.avi by Totem movie player in Ubuntu.
(Video length: 0:03, Size: 320x240)
















Build for mips platform

$ ./configure --arch=mips --enable-cross-compile --cross-prefix=mipsel-linux- --prefix=/home/yenping/workspace/test --disable-debug --disable-ffserver --enable-pthreads
 
--prefix, path to install
--disable-debug,
--disable-ffserver, no need to build ffserver
--enable-pthreads, seems not work in my mips

$ ls -al ../test/*
../test/bin:
-rwxr-xr-x 1 root root 4660156 2010-02-10 10:33 ffmpeg

../test/lib:
-rw-r--r-- 1 root root 4551048 2010-02-10 10:33 libavcodec.a
-rw-r--r-- 1 root root   32018 2010-02-10 10:33 libavdevice.a
-rw-r--r-- 1 root root 1260618 2010-02-10 10:33 libavformat.a
-rw-r--r-- 1 root root   78320 2010-02-10 10:33 libavutil.a
  :


$ file ../test/bin/ffmpeg
../test/bin/ffmpeg: ELF 32-bit LSB executable, MIPS, MIPS32 version 1 (SYSV), dynamically linked (uses shared libs), stripped


Copy to mips and trial run.
# ./ffmpeg -i NBA.rmvb -t 3 -s 320x240 -y 1235.avi     
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --arch=mips --enable-cross-compile --cross-prefix=mipsel-linux- --prefix=/home/yenping/workspace/test --disable-debug --disable-ffserver --enable-pthreads
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 0 / 52.20. 0
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  built on Feb 10 2010 10:29:16, gcc: 3.4.4 mipssde-6.03.00-20051020
[NULL @ 0x103845d0]Unsupported video codec
Input #0, rm, from 'NBA.rmvb':
  Duration: 00:23:49.98, start: 0.000000, bitrate: 718 kb/s
    Stream #0.0: Audio: aac, 32000 Hz, stereo, s16, 64 kb/s
    Stream #0.1: Video: rv40, yuv420p, 848x480, 639 kb/s, 12 tbr, 1k tbn, 12 tbc
    Stream #0.2: Data: 0x0000
Output #0, avi, to '1235.avi':
    Stream #0.0: Video: mpeg4, yuv420p, 320x240, q=2-31, 200 kb/s, 90k tbn, 12 tbc
    Stream #0.1: Audio: mp2, 32000 Hz, stereo, s16, 64 kb/s
Stream mapping:
  Stream #0.1 -> #0.0
  Stream #0.0 -> #0.1
Press [q] to stop encoding
frame=   22 fps=  2 q=3.2 Lsize=     168kB time=3.02 bitrate= 455.6kbits/s   
video:132kB audio:24kB global headers:0kB muxing overhead 8.058008%



At the same time, check running processes in other terminal.
# ps
   :
 5891 root       5964 R   ./ffmpeg -i NBA.rmvb -t 3 -s 320x240 -y 1235.avi
 5894 root        332 R   ps  

   :
Only one process/thread is found !?

# ls -al NBA.rmvb 1235.avi
-rw-r--r--    1 root     root       172198 Jan  2 20:37 1235.avi
-rwxrwxrwx    1 root     root    128482171 Jun  7  2031 NBA.rmvb



# ./ffmpeg -i 1235.avi
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --arch=mips --enable-cross-compile --cross-prefix=mipsel-linux- --prefix=/home/yenping/workspace/test --disable-debug --disable-ffserver --enable-pthreads
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 0 / 52.20. 0
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  built on Feb 10 2010 10:29:16, gcc: 3.4.4 mipssde-6.03.00-20051020
Input #0, avi, from '1235.avi':
  Duration: 00:00:03.08, start: 0.000000, bitrate: 446 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 12 tbr, 12 tbn, 12 tbc
    Stream #0.1: Audio: mp2, 32000 Hz, stereo, s16, 64 kb/s
At least one output file must be specified


More trial runs.
Grab a video clip from a video file...
You may do it in below two ways....
<1> $ ffmpeg -t 10 -i NBA.rmvb -ss 00:00:20 -y 1237.avi
<2> $ ffmpeg -ss 00:00:20 -t 10 -i NBA.rmvb -y 1237.avi

In way <1>, ffmpeg seems to move from head frame to the offset frame set by param -ss and then starts to record ten(10) seconds clips. If the starting offset is larger, we have to waste time to wait....

In way <2>, FFmpeg seems jumping to the starting offset and starts recording clips. 

So I'll use way <2> to grab a video clip.


Grab a single screen shot.
$ ffmpeg -ss 1 -i 1235.avi -r 1 -t 1 -s 84x58 -f image2 imgX.jpg



1 則留言:

CYP1973 提到...

Redirect stderr to stdout....So that we can do some more works....

# ./ffmpeg -i 1235.avi 2>&1 | grep Duration
Duration: 00:00:03.08, start: 0.000000, bitrate: 446 kb/s