ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

顯示具有 ffmpeg 標籤的文章。 顯示所有文章
顯示具有 ffmpeg 標籤的文章。 顯示所有文章

2015年3月10日 星期二

split video file with ffmpeg

ref: http://stackoverflow.com/questions/5651654/ffmpeg-how-to-split-video-efficiently

結果新版 ffmpeg 要指定 -vcodec, -acodec 才行。
舊版的只需要用 -codec 就可以。

所以 command 是:
ffmpeg -i DOS.mkv -t  1:10:20 -acodec copy -vcodec copy DOS1.mkv
ffmpeg -i DOS.mkv -ss 1:10:20 -acodec copy -vcodec copy DOS2.mkv
以上的例子就是把 DOS.mkv 從 1:10:20 分成前後兩段。

ref: http://superuser.com/questions/820747/slicing-video-file-into-several-segments

比較不好,,要要 encoding...
ffmpeg -i input.mp4 -c:v libx264 -crf 22 -map 0 -segment_time 9 -g 9 -sc_threshold 0 -force_key_frames "expr:gte(t,n_forced*9)" -f segment output%03d.mp4


ref: https://matthewsdan.wordpress.com/2015/04/16/ffmpeg-split-video-into-custom-number-of-clips/

這個不用 encoding..

for i in *.mp4 *.flv *.avi *wmv; do ffmpeg -i "$i" -f segment -segment_time 5 -c:v copy -reset_timestamps 1 output%d.avi; done
也就是說:
ffmpeg -i XXX.mp4 -f segment -segment_time 5 -c:v copy -reset_timestamps 1 output%d.mp4

2011年4月1日 星期五

Video Converter Factory Pro 使用感想 -- 太慢

因為Video Converter Factory Pro 有限時免費的優惠,所以去 download 下來用了。
結果: (跟我自己用 ffmpeg 的結果比較)

有 UI 和預設的一堆 device profile 是比較方便的地方。
還有一些 crop, clip, effect 是 ffmpeg 沒有的。

但是,單就轉檔 來看..

Video Converter Factory 實在太慢了呀 ..

一個 1:12 的影片,用 ffmpeg 轉,大約 20min。
Video Converter Factory Pro 竟然要 1:27

轉的時候我看了一下 cpu loading,只有一個core 達到 90%,其他 3 顆都只有 10~20%。
所以大概是沒有 support multi-thread 吧。

我用 ffmpeg 轉檔是手動下 -thread 4 的 option,所以四個 core 都是 80 ~ 90%。

2011年3月14日 星期一

ffmpeg with libxvid libx264

deb http://www.debian-multimedia.org squeeze main non-free 加到 sources.list 中,

-- 實際上是去 download debian-multimedia-keyring_2010.12.26_all.deb 下來裝。

update 後,install avidemux ,就會因為 dependency problem,要 remove ffmpeg,選第二個 option,升級ffmpeg。

之後的 ffmpeg 就有 x264 跟 xvid 的 support -- 查是 non-free 裡的 ffmpeg.\
FFmpeg version SVN-r25838, Copyright (c) 2000-2010 the FFmpeg developers built on Jan 21 2011 08:21:58 with gcc 4.4.5 configuration: --enable-libdc1394 --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter --enable-libdirac --disable-decoder=libdirac --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-libvpx --enable-librtmp --extra-libs=-lgcrypt --disable-altivec --disable-armv5te --disable-armv6 --disable-vis libavutil 50.33. 0 / 50.33. 0 libavcore 0.14. 0 / 0.14. 0 libavcodec 52.97. 2 / 52.97. 2 libavformat 52.87. 1 / 52.87. 1 libavdevice 52. 2. 2 / 52. 2. 2 libavfilter 1.65. 0 / 1.65. 0 libswscale 0.12. 0 / 0.12. 0 libpostproc 51. 2. 0 / 51. 2. 0 Hyper fast Audio and Video encoder

2010年9月28日 星期二

ffmpeg -ffprobe

要看ffmpeg 怎麼找到transport stream 中的 stream 和 format,看 ffprobe 就可以。
ffprobe.c 基本就是open file 然後 show stream , format, packet.
所以所有 stream type identify 的動作都是在 ffprobe.c 中的 open_input_file( ) 完成的。
static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename) { int err, i; AVFormatContext *fmt_ctx; fmt_ctx = avformat_alloc_context(); if ((err = av_open_input_file(&fmt_ctx, filename, iformat, 0, NULL)) < 0) { print_error(filename, err); return err; } /* fill the streams in the format context */ if ((err = av_find_stream_info(fmt_ctx)) < 0) { print_error(filename, err); return err; } dump_format(fmt_ctx, 0, filename, 0); /* bind a decoder to each input stream */ for (i = 0; i < fmt_ctx->nb_streams; i++) { AVStream *stream = fmt_ctx->streams[i]; AVCodec *codec; if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) { fprintf(stderr, "Unsupported codec (id=%d) for input stream %d\n", stream->codec->codec_id, stream->index); } else if (avcodec_open(stream->codec, codec) < 0) { fprintf(stderr, "Error while opening codec for input stream %d\n", stream->index); } } *fmt_ctx_ptr = fmt_ctx; return 0; }
mpeg transport stream 的 probe 方式是: mpegts.c (analyze())
static int analyze(const uint8_t *buf, int size, int packet_size, int *index){ int stat[TS_MAX_PACKET_SIZE]; int i; int x=0; int best_score=0; memset(stat, 0, packet_size*sizeof(int)); for(x=i=0; i<size-3; i++){ if(buf[i] == 0x47 && !(buf[i+1] & 0x80) && (buf[i+3] & 0x30)){ stat[x]++; if(stat[x] > best_score){ best_score= stat[x]; if(index) *index= x; } } x++; if(x == packet_size) x= 0; } return best_score; } 逐一檢查 :
  • byte0 == 0x47
  • byte1 & 0x80 == 0x00
  • byte3 & 0x30 != 0x00
以 state[] 作為一個 packet size(188) 的檢測結果。
傳入 10 個 packet_size 來檢查。
這樣,如果傳入的 stream data 剛好是對齊 byte0 的話。最後 state[0]=10.
如果是對齊 byte[1]。state[1]=9

mpegts.c 在 mpegts_probe( ) 里分別 probe 三種type 的 stream:
score = analyze(p->buf, TS_PACKET_SIZE *check_count, TS_PACKET_SIZE , NULL)*CHECK_COUNT/check_count; dvhs_score= analyze(p->buf, TS_DVHS_PACKET_SIZE*check_count, TS_DVHS_PACKET_SIZE, NULL)*CHECK_COUNT/check_count; fec_score = analyze(p->buf, TS_FEC_PACKET_SIZE *check_count, TS_FEC_PACKET_SIZE , NULL)*CHECK_COUNT/check_count; 因為是 sample stream file 是 mpeg2 transport stream,而且第一個 byte 就對齊了 sync byte 0x47,所以第一個 analyz( ) 會 return 10.

而mpegts_probe( ) 最後 return:
AVPROBE_SCORE_MAX + score - CHECK_COUNT 其中 CHECK_COUNT 就是送進去sample 的 packet number (10)。所以計算結果是 AVPROBE_SCORE_MAX。
probe 的結果是得到 fmt -- AVInputFormat 的 fmt

這個 probe 到的 format 再被用來 open stream:
err = av_open_input_stream(ic_ptr, pb, filename, fmt, ap);
av_open_input_stream 實際上是依據 pb, filename create 一個 AVFormatContext 的 structure。把 fmt 填進 structure 中,並且由 fmt 的
read_header( ) 從 stream 中 parsing header information,填入 ap --- AVFormatParameters

2010年9月24日 星期五

build ffmpeg with --disable-optimizations

因為要用 gdb run,所以用 --disable-optimizations 的 option。 結果會出現: In file included from /home/ffmpeg/ffmpeg/libavcodec/x86/dsputil_mmx.c:31: /home/ffmpeg/ffmpeg/libavcodec/x86/dsputil_mmx.h: In function ‘transpose4x4’: /home/ffmpeg/ffmpeg/libavcodec/x86/dsputil_mmx.h:98: error: can't find a register in class ‘GENERAL_REGS’ while reloading ‘asm’ /home/ffmpeg/ffmpeg/libavcodec/x86/dsputil_mmx.h:98: error: ‘asm’ operand has impossible constraints make: *** [libavcodec/x86/dsputil_mmx.o] Error 1 google 的結果說是 gcc 的問題,好像是 ebp 可不可以拿來用的問題。 但是 apply 所有 google 到的 solution 都沒有效。 所以,只好... configure --disable-mmx --disable-mmx2 --disable-optimizations --disable-stripping 這樣就 OK 了... 很糟糕又丟臉的方法,但是主要是要 trace transport stream 的 decoding process,所以 assembly optimize 部份可以先略過...

2010年9月16日 星期四

log - build and install x264

********************************************************************** Done. The new package has been installed and saved to /home/charles-chang/1seg/x264/x264_1:0.20100917-1_i386.deb You can remove it from your system anytime using: http://www.blogger.com/img/blank.gif dpkg -r x264 ********************************************************************** 這一篇 (http://wiki.videolan.org/User:J-b#live555_.28optional.29 ) 好像說得比較清楚,可以用自己的 dependent library,在自己的 folder build,不會跟 system 混在一起。

2010年5月3日 星期一

Log : Build MediaInfo from Source (VS2005)

在 Windows 下用 VS2005 build 有點麻煩,但是希望能單步執行,所以還是用 VS2005 試試看。
MediaInfo 的 VS2005 project 檔只有 lib 有,GUI interface 沒有VS2005 的,只有 VS2008 的。
如果 follow MediaInfo 的說明 checkout 的話,trunk 和所有的 tag 都會被 checkout 下來。(800多MB)
MediaInfo 要 zenlib, zlib
開啟 tag\v0.7.31\Project\MSVC2005\MediaInfoLib_MSVC.sln
會 complain zenlib, zlib 的 sub project link 沒有東西。

zenlib:
zenlib 同樣是 MediaInfo 的專案,所以還是在 sourceforge download
將 download 下來的 zen lib copy 到 tag\ 下
這個看 VS2005 開啟時 complain 的 message 就可以知道
zlib:
zlib 比較麻煩,到 zlib.net 去只有最新版。要 1.2.3 版要另外找。
zlib 1.2.5 使用 VS2008 作 project,VS2005沒辦法開啟
找到 1.2.3 版,用 VS2005 build 會出現 fail :
inffas32.asm(720) : error A2070: invalid instruction operands
單純google 這個 error 就會出現很多說明,大概是 VS2005 的 MASM 不認識這個語法。
所以要手動修改:
 movd mm7,[esi] 
變成:
 movd mm7,dword ptr [esi]
這樣就可以 build 過了
將整個 zlib-1.2.3 copy 到 tag 下,rename 成 zlib。
開啟 v0.7.31 的 MediaInfoLib_MSVC.sln 修改一下。
"..\..\..\zlib\projects\MSVC2005\zlib.vcproj"
改成
""..\..\..\zlib\projects\visualc6\zlib.vcproj"

這樣 重新打開 MediaInfoLib_MSVC.sln,就OK 了。
build 也 OK

2010年4月28日 星期三

memo : ffmpeg , convert to mp4 320x240

紀錄一下 convert 成 mp4 320x240 的 convert parameter
ffmpeg -threads 2 -i "VIDEO_TS/VTS_01_0.VOB" -f mp4 -r 29.97 -vcodec libx264 -s 320x240 "vts_01.mp4"
這是 WinFF 用的 command

2009年9月8日 星期二

code reading : sample code of ffmpeg : avcodec_sample0.5.c

av_register_all( ) 建立起所有 support codec, decoder, demuxer, muxer... 的 linking list。


av_probe_input_format2( ) 會讀取 file 內容,從標頭猜測 格式。

實際上這一段就是一一呼叫所有 codec 的 XXX_probe( ) function,取出score,score 最高的codec 就是了..

probe 和 decode 在不同的目錄:
  • probe : libformat
  • decode : libavcodec
用 CODEC_ID 來傳遞, probe 得到 CODEC_ID,再由 ID (string compare) 找出codec function table.

decode file stream 是利用以下 data sequence:
/* Start codes. */
#define SEQ_END_CODE            0x000001b7
#define SEQ_START_CODE          0x000001b3
#define GOP_START_CODE          0x000001b8
#define PICTURE_START_CODE      0x00000100
#define SLICE_MIN_START_CODE    0x00000101
#define SLICE_MAX_START_CODE    0x000001af
#define EXT_START_CODE          0x000001b5
#define USER_START_CODE         0x000001b2

build ffmpeg sample in mingw - success

Linking Order 有關,從 install log 看 ffmpeg.exe 的linking order:
-lavdevice -lavformat -lavcodec -lavutil -lswscale -lm
這樣那個 avcodec_sample_0.5.0.c 就可以 build 了。 ./a.exe 出現 segment fault. 用 dbg run
(gdb) run
Starting program: c:\codepiece/a.exe
[New thread 2472.0x6a0]

Program received signal SIGSEGV, Segmentation fault.
0x0040cccd in url_open ()
(gdb) bt
#0  0x0040cccd in url_open ()
#1  0x0040f399 in url_fopen ()
#2  0x004025c1 in av_open_input_file ()
#3  0x0040144c in main (argc=1, argv=0x3e2430) at avcodec_sample.c:51
知道是因為沒給 argument,所以 open url,給定一個 mpg file後就 OK 了。 這個sample 會將 mpg 存為 6 個 ppm file...

make fail - disable all encoder in ffmpeg

阿,上一篇把所有 encoder都disable 的話會fail...
c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0x4a57): undefined reference to `ff_epzs_motion_search'
c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0x4bba): undefined reference to `ff_get_mb_score'
c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0xf64d): undefined reference to `ff_rate_estimate_qscale'
c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0xfb74): undefined reference to `h263_encode_init'
c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0xfc0f): undefined reference to `ff_rate_control_init'
c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0x10894): undefined reference to `ff_rate_estimate_qscale'
c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0x10ce0): undefined reference to `ff_init_me'
c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0x1184d): undefined reference to `ff_rate_estimate_qscale'
c:/ffmpeg/build/libavcodec/libavcodec.a(snow.o):snow.c:(.text+0x11886): undefined reference to `ff_write_pass1_stats'
collect2: ld returned 1 exit status
所以重新打開好了...(雖然看起來好像開 h264 encoder就可以..)

ffmpeg config log

因為只是要try decode,所以關掉一堆功能.. config log:
$ ../ffmpeg-export-2009-09-02/configure --prefix=/mingw --disable-debug --disable-optimizations --disable-stripping --enabl
e-memalign-hack --enable-gpl --enable-static --disable-shared --disable-ffserver --disable-altivec --disable-amd3dnow --dis
able-mmx --disable-mmx2 --disable-sse --disable-ssse3 --disable-yasm --disable-encoders --disable-hwaccels --disable-indevs
 --disable-protocol=gopher --disable-protocol=http --disable-protocol=rtmp --disable-protocol=rtp --disable-protocol=tcp --
disable-protocol=udp --disable-network
install prefix            /mingw
source path               /c/ffmpeg/ffmpeg-export-2009-09-02
C compiler                gcc
.align is power-of-two    no
ARCH                      x86 (generic)
big-endian                no
runtime cpu detection     no
yasm                      no
MMX enabled               no
MMX2 enabled              no
3DNow! enabled            no
3DNow! extended enabled   no
SSE enabled               no
SSSE3 enabled             no
CMOV enabled              no
CMOV is fast              no
EBX available             yes
EBP available             no
10 operands supported     yes
gprof enabled             no
debug symbols             no
strip symbols             no
optimizations             no
static                    yes
shared                    no
postprocessing support    no
new filter support        no
filters using lavformat   no
network support           no
threading support         no
SDL support               yes
Sun medialib support      no
AVISynth enabled          no
libdc1394 support         no
libdirac enabled          no
libfaac enabled           no
libfaad enabled           no
libfaad dlopened          no
libgsm enabled            no
libmp3lame enabled        no
libnut enabled            no
libopencore-amrnb support no
libopencore-amrwb support no
libopenjpeg enabled       no
libschroedinger enabled   no
libspeex enabled          no
libtheora enabled         no
libvorbis enabled         no
libx264 enabled           no
libxvid enabled           no
zlib enabled              no
bzlib enabled             no

Enabled decoders:
aac                     ffv1                    pcm_s32be
aasc                    ffvhuff                 pcm_s32le
ac3                     flac                    pcm_s8
adpcm_4xm               flic                    pcm_u16be
adpcm_adx               flv                     pcm_u16le
adpcm_ct                fourxm                  pcm_u24be
adpcm_ea                fraps                   pcm_u24le
adpcm_ea_maxis_xa       gif                     pcm_u32be
adpcm_ea_r1             h261                    pcm_u32le
adpcm_ea_r2             h263                    pcm_u8
adpcm_ea_r3             h263i                   pcm_zork
adpcm_ea_xas            h264                    pcx
adpcm_g726              huffyuv                 pgm
adpcm_ima_amv           idcin                   pgmyuv
adpcm_ima_dk3           imc                     pgssub
adpcm_ima_dk4           indeo2                  ppm
adpcm_ima_ea_eacs       indeo3                  ptx
adpcm_ima_ea_sead       interplay_dpcm          qcelp
adpcm_ima_iss           interplay_video         qdm2
adpcm_ima_qt            jpegls                  qdraw
adpcm_ima_smjpeg        kmvc                    qpeg
adpcm_ima_wav           loco                    qtrle
adpcm_ima_ws            mace3                   ra_144
adpcm_ms                mace6                   ra_288
adpcm_sbpro_2           mdec                    rawvideo
adpcm_sbpro_3           mimic                   rl2
adpcm_sbpro_4           mjpeg                   roq
adpcm_swf               mjpegb                  roq_dpcm
adpcm_thp               mlp                     rpza
adpcm_xa                mmvideo                 rv10
adpcm_yamaha            motionpixels            rv20
alac                    mp1                     rv30
amv                     mp2                     rv40
ape                     mp3                     sgi
asv1                    mp3adu                  shorten
asv2                    mp3on4                  smackaud
atrac3                  mpc7                    smacker
avs                     mpc8                    smc
bethsoftvid             mpeg1video              snow
bfi                     mpeg2video              sol_dpcm
bmp                     mpeg4                   sonic
c93                     mpegvideo               sp5x
cavs                    msmpeg4v1               sunrast
cinepak                 msmpeg4v2               svq1
cljr                    msmpeg4v3               svq3
cook                    msrle                   targa
cscd                    msvideo1                theora
cyuv                    mszh                    thp
dca                     nellymoser              tiertexseqvideo
dnxhd                   nuv                     tiff
dpx                     pam                     tmv
dsicinaudio             pbm                     truehd
dsicinvideo             pcm_alaw                truemotion1
dvbsub                  pcm_bluray              truemotion2
dvdsub                  pcm_dvd                 truespeech
dvvideo                 pcm_f32be               tta
eac3                    pcm_f32le               twinvq
eacmv                   pcm_f64be               txd
eamad                   pcm_f64le               ulti
eatgq                   pcm_mulaw               v210
eatgv                   pcm_s16be               v210x
eatqi                   pcm_s16le               vb
eightbps                pcm_s16le_planar        vc1
eightsvx_exp            pcm_s24be               vcr1
eightsvx_fib            pcm_s24daud             vmdaudio
escape124               pcm_s24le               vmdvideo
vmnc                    vqa                     wnv1
vorbis                  wavpack                 ws_snd1
vp3                     wmav1                   xan_dpcm
vp5                     wmav2                   xan_wc3
vp6                     wmv1                    xl
vp6a                    wmv2                    xsub
vp6f                    wmv3

Enabled encoders:

Enabled hwaccels:

Enabled parsers:
aac                     dvdsub                  mpeg4video
ac3                     h261                    mpegaudio
cavsvideo               h263                    mpegvideo
dca                     h264                    pnm
dirac                   mjpeg                   vc1
dnxhd                   mlp                     vp3
dvbsub

Enabled demuxers:
aac                     iss                     pcm_u24be
ac3                     lmlm4                   pcm_u24le
aiff                    m4v                     pcm_u32be
amr                     matroska                pcm_u32le
apc                     mjpeg                   pcm_u8
ape                     mlp                     pva
asf                     mm                      qcp
ass                     mmf                     r3d
au                      mov                     rawvideo
avi                     mp3                     rl2
avs                     mpc                     rm
bethsoftvid             mpc8                    roq
bfi                     mpegps                  rpl
c93                     mpegts                  segafilm
cavsvideo               mpegtsraw               shorten
daud                    mpegvideo               siff
dirac                   msnwc_tcp               smacker
dnxhd                   mtv                     sol
dsicin                  mvi                     sox
dts                     mxf                     str
dv                      nc                      swf
dxa                     nsv                     thp
ea                      nut                     tiertexseq
ea_cdata                nuv                     tmv
eac3                    ogg                     truehd
ffm                     oma                     tta
flac                    pcm_alaw                txd
flic                    pcm_f32be               vc1
flv                     pcm_f32le               vc1t
fourxm                  pcm_f64be               vmd
gsm                     pcm_f64le               voc
gxf                     pcm_mulaw               vqf
h261                    pcm_s16be               w64
h263                    pcm_s16le               wav
h264                    pcm_s24be               wc3
idcin                   pcm_s24le               wsaud
iff                     pcm_s32be               wsvqa
image2                  pcm_s32le               wv
image2pipe              pcm_s8                  xa
ingenient               pcm_u16be               yuv4mpegpipe
ipmovie                 pcm_u16le

Enabled muxers:
ac3                     m4v                     pcm_mulaw
adts                    matroska                pcm_s16be
aiff                    matroska_audio          pcm_s16le
amr                     mjpeg                   pcm_s24be
asf                     mlp                     pcm_s24le
asf_stream              mmf                     pcm_s32be
ass                     mov                     pcm_s32le
au                      mp2                     pcm_s8
avi                     mp3                     pcm_u16be
avm2                    mp4                     pcm_u16le
crc                     mpeg1system             pcm_u24be
daud                    mpeg1vcd                pcm_u24le
dirac                   mpeg1video              pcm_u32be
dnxhd                   mpeg2dvd                pcm_u32le
dts                     mpeg2svcd               pcm_u8
dv                      mpeg2video              psp
eac3                    mpeg2vob                rawvideo
ffm                     mpegts                  rm
flac                    mpjpeg                  roq
flv                     mxf                     sox
framecrc                mxf_d10                 spdif
gif                     null                    swf
gxf                     nut                     tg2
h261                    ogg                     tgp
h263                    pcm_alaw                truehd
h264                    pcm_f32be               vc1t
image2                  pcm_f32le               voc
image2pipe              pcm_f64be               wav
ipod                    pcm_f64le               yuv4mpegpipe

Enabled protocols:
file                    pipe

Enabled filters:
crop

Enabled bsfs:
aac_adtstoasc           mjpega_dump_header      noise
dump_extradata          mov2textsub             remove_extradata
h264_mp4toannexb        mp3_header_compress     text2movsub
imx_dump_header         mp3_header_decompress

Enabled indevs:

Enabled outdevs:

License: GPL version 2 or later
Creating config.mak and config.h...

2009年9月7日 星期一

build ffmpeg sample in mingw

光是一個 av_register_all( ),就噓要 link 4 個 library:
gcc testffmpeg.c -lavformat -lavcodec -lavutil -lz

* 而且要按照這個次序..!!!!

至於那個 sample file,最後還要加一個library : lswscale

google 了一下: ffmpeg static library link order

發現有說明,因為ffmpeg 的各個 library 裡有重複的 object file,所以link order 很重要。

如果要做出一個單一的 library 包含現在的 library,好像要 --enable-gpl,同時 disable 一些 codec。


log -ffmpeg install

$ make install
install -d "/mingw/lib"
install -m 644 libavfilter/libavfilter.a "/mingw/lib"
ranlib "/mingw/lib/libavfilter.a"
install -d "/mingw/lib"
install -m 644 libavdevice/libavdevice.a "/mingw/lib"
ranlib "/mingw/lib/libavdevice.a"
install -d "/mingw/lib"
install -m 644 libavformat/libavformat.a "/mingw/lib"
ranlib "/mingw/lib/libavformat.a"
install -d "/mingw/lib"
install -m 644 libavcodec/libavcodec.a "/mingw/lib"
ranlib "/mingw/lib/libavcodec.a"
install -d "/mingw/lib"
install -m 644 libavutil/libavutil.a "/mingw/lib"
ranlib "/mingw/lib/libavutil.a"
install -d "/mingw/lib"
install -m 644 libswscale/libswscale.a "/mingw/lib"
ranlib "/mingw/lib/libswscale.a"
install -d "/mingw/include/libavfilter"
install -d "/mingw/lib/pkgconfig"
install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavfilter"/avfilter.h "/mingw/include/libavfilter"
install -m 644 "/c/ffmpeg/build"/libavfilter/libavfilter.pc "/mingw/lib/pkgconfig"
install -d "/mingw/include/libavdevice"
install -d "/mingw/lib/pkgconfig"
install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavdevice"/avdevice.h "/mingw/include/libavdevice"
install -m 644 "/c/ffmpeg/build"/libavdevice/libavdevice.pc "/mingw/lib/pkgconfig"
install -d "/mingw/include/libavformat"
install -d "/mingw/lib/pkgconfig"
install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavformat"/avformat.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavformat"/
avio.h "/mingw/include/libavformat"
install -m 644 "/c/ffmpeg/build"/libavformat/libavformat.pc "/mingw/lib/pkgconfig"
install -d "/mingw/include/libavcodec"
install -d "/mingw/lib/pkgconfig"
install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavcodec"/avcodec.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavcodec"/opt
.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavcodec"/vdpau.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavcodec"/xvmc.h "/mingw/in
clude/libavcodec"
install -m 644 "/c/ffmpeg/build"/libavcodec/libavcodec.pc "/mingw/lib/pkgconfig"
install -d "/mingw/include/libavutil"
install -d "/mingw/lib/pkgconfig"
install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/adler32.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/avstr
ing.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/avutil.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/base64.h "/c/ff
mpeg/ffmpeg-export-2009-09-02/libavutil"/common.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/crc.h "/c/ffmpeg/ffmpeg-exp
ort-2009-09-02/libavutil"/fifo.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/intfloat_readwrite.h "/c/ffmpeg/ffmpeg-expor
t-2009-09-02/libavutil"/log.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/lzo.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libav
util"/mathematics.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/md5.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/mem.
h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/pixfmt.h "/c/ffmpeg/ffmpeg-export-2009-09-02/libavutil"/rational.h "/c/ffmp
eg/ffmpeg-export-2009-09-02/libavutil"/sha1.h "/mingw/include/libavutil"
install -m 644 "/c/ffmpeg/build"/libavutil/libavutil.pc "/mingw/lib/pkgconfig"
install -d "/mingw/include/libswscale"
install -d "/mingw/lib/pkgconfig"
install -m 644 "/c/ffmpeg/ffmpeg-export-2009-09-02/libswscale"/swscale.h "/mingw/include/libswscale"
install -m 644 "/c/ffmpeg/build"/libswscale/libswscale.pc "/mingw/lib/pkgconfig"
gcc -DHAVE_AV_CONFIG_H -I. -I"/c/ffmpeg/ffmpeg-export-2009-09-02" -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_FILE_OFFSET_B
ITS=64 -D_LARGEFILE_SOURCE -std=c99 -fno-common -fomit-frame-pointer -g -Wdeclaration-after-statement -Wall -Wno-switch -Wdi
sabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual -Wwrite-strings -Wundef -O3 -fno-math-er
rno -fno-tree-vectorize        -MMD -MF ffmpeg.d -MT ffmpeg.o -c -o ffmpeg.o /c/ffmpeg/ffmpeg-export-2009-09-02/ffmpeg.c
gcc -L"/c/ffmpeg/build"/libavcodec -L"/c/ffmpeg/build"/libavdevice -L"/c/ffmpeg/build"/libavfilter -L"/c/ffmpeg/build"/libav
format -L"/c/ffmpeg/build"/libavutil -L"/c/ffmpeg/build"/libpostproc -L"/c/ffmpeg/build"/libswscale -Wl,--warn-common -Wl,--
as-needed -Wl,-rpath-link,"/c/ffmpeg/build"/libpostproc -Wl,-rpath-link,"/c/ffmpeg/build"/libswscale -Wl,-rpath-link,"/c/ffm
peg/build"/libavfilter -Wl,-rpath-link,"/c/ffmpeg/build"/libavdevice -Wl,-rpath-link,"/c/ffmpeg/build"/libavformat -Wl,-rpat
h-link,"/c/ffmpeg/build"/libavcodec -Wl,-rpath-link,"/c/ffmpeg/build"/libavutil -Wl,-Bsymbolic -o ffmpeg_g.exe ffmpeg.o cmdu
tils.o -lavfilter -lavdevice -lavformat -lavcodec -lavutil -lswscale -lz -lm  -lvfw32
cp -p ffmpeg_g.exe ffmpeg.exe
strip ffmpeg.exe
install -d "/mingw/bin"
install -c -m 755 ffmpeg.exe ffplay.exe "/mingw/bin"
install -d "/mingw/share/ffmpeg"
install -m 644 /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-baseline.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffp
resets/libx264-default.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-fastfirstpass.ffpreset /c/ffmpeg/ffmpeg
-export-2009-09-02/ffpresets/libx264-hq.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-ipod320.ffpreset /c/ff
mpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-ipod640.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-lossle
ss_fast.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-lossless_max.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-
02/ffpresets/libx264-lossless_medium.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-lossless_slow.ffpreset /c
/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-lossless_slower.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/lib
x264-lossless_ultrafast.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-main.ffpreset /c/ffmpeg/ffmpeg-export-
2009-09-02/ffpresets/libx264-max.ffpreset /c/ffmpeg/ffmpeg-export-2009-09-02/ffpresets/libx264-normal.ffpreset /c/ffmpeg/ffm
peg-export-2009-09-02/ffpresets/libx264-slowfirstpass.ffpreset "/mingw/share/ffmpeg"

2009年9月6日 星期日

bookmark - ffmpeg and SDL tutorial

ffmpeg and SDL tutorial : 這個就是有名的 "How to write a video player in 1000 lines".


順便寫一下,這個也有說明 ffmpeg 的 source code architecture

www.wiki.multimedia.cx

其實這些link 在 ffmpeg 的主站就有link

bookmark : video sample site - mplayer

mplayer 的網站有放很多壓縮格式的 sample file:

2009年9月3日 星期四

ffplay in gdb & ffmpeg library

試試在 gdb 裡面 run ffmpeg。
首先要build none-strip 版本。
先 configure --help 列出 configure option。其中有:
Developer options (useful when working on FFmpeg itself):
--disable-debug          disable debugging symbols
--enable-debug=LEVEL     set the debug level []
--enable-gprof           enable profiling with gprof []
--disable-optimizations  disable compiler optimizations
--enable-extra-warnings  enable more compiler warnings
--disable-stripping      disable stripping of executables and shared libraries
所以重新configuer,加上 --disable-optimizations --disable-stripping。
然後就可以開始make
gdb 的話,我是用 gdb-6.8-mingw-3 這個版本 (一樣,download bz2 解開,覆蓋 mingw 下)。
先照著 Tetralet 這一篇 作一次,了解 gdb 的使用方式。
還有 study area 這一篇 也是 step by step,也照著作一下。

ffplay.c 是ffmpeg 附的播放程式。可以從這邊開始 run,看 ffmpeg decode 的程序。
ffplay.c 的 decode 是在 open_stream( ) 中 create 的 decode_thread( ) 作得。
其中 libavformat/utils.c : av_read_frame_internal( ) 負責從 stream 中解出 frame。

follow 這一篇(http://ffmpeg.arrozcru.org/wiki/index.php?title=Static)的 ffmpeg build 步驟,ffmpeg include 和 lib 會被 install 在
/usr/local/include
/usr/local/lib
所以compile 的時候要加上 -I/usr/local/include -L/usr/local/lib -lavdevice -lavformat -lavcodec -lavutil -lswscale

如果在config ffmpeg 時指定 --prefix=/mingw ,就不用 額外 寫明 -I, -L path。

標籤

網誌存檔