프로그램 사용/vi2017. 2. 10. 20:43


:sp

:vsp


[링크 : https://www.linux.com/learn/vim-tips-using-viewports]


보이는 것만 둘로 나눈 것이기에

다른쪽에서 수정하면 동시에 수정되는 것이 보인다

'프로그램 사용 > vi' 카테고리의 다른 글

vi 버퍼 컨트롤  (0) 2017.02.13
vi buffer window tab 차이점?  (0) 2017.02.11
vi 현재 위치에서 끝까지 복사  (0) 2017.02.01
vi 단어 단위 이동  (0) 2017.02.01
vi syntax highlight 선택하기  (0) 2017.01.03
Posted by 구차니
Programming/ffmpeg2017. 2. 10. 17:38

[링크 : https://github.com/mpenkov/ffmpeg-tutorial/blob/master/tutorial01.c]


사용된 헤더별 구조체

libavcodec/avcodec.h

- AVCodecContext

- AVCodec

- AVPacket


libavformat/avformat.h

- AVFormatContext


libswscale/swscale_internal.h ??

- SwsContext 


libavutil/frame.h

from libavcodec/avcodec.h

- AVFrame


libavutil/dict.h

- AVDictionary 



av_register_all() // Initialize libavformat and register all the muxers, demuxers and protocols.


avformat_open_input()

avformat_find_stream_info()

av_dump_format()

avcodec_find_decoder()

avcodec_open2()

av_frame_alloc()

avpicture_get_size()


av_malloc()

sws_getContext()


avpicture_fill()

while(av_read_frame())

avcodec_decode_video2()

sws_scale()

av_free_packet()


av_free()

avcodec_close()

avformat_close_input() 


AVFormatContext *pFormatCtx = NULL;

AVCodecContext  *pCodecCtx = NULL;

AVCodec         *pCodec = NULL;

AVFrame         *pFrame = NULL; 

AVFrame         *pFrameRGB = NULL;

AVPacket        packet;

AVDictionary    *optionsDict = NULL;

struct SwsContext      *sws_ctx = NULL;


av_register_all();

avformat_open_input(&pFormatCtx, argv[1], NULL, NULL);

avformat_find_stream_info(pFormatCtx, NULL);

av_dump_format(pFormatCtx, 0, argv[1], 0);


pCodecCtx=pFormatCtx->streams[videoStream]->codec;

pCodec=avcodec_find_decoder(pCodecCtx->codec_id);

avcodec_open2(pCodecCtx, pCodec, &optionsDict)

pFrame=av_frame_alloc();

pFrameRGB=av_frame_alloc();

numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,

pCodecCtx->height);

buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));


sws_ctx = sws_getContext(

    pCodecCtx->width,

    pCodecCtx->height,

    pCodecCtx->pix_fmt,

    pCodecCtx->width,

    pCodecCtx->height,

    PIX_FMT_RGB24,

    SWS_BILINEAR,

    NULL,

    NULL,

    NULL    );

avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,

pCodecCtx->width, pCodecCtx->height);


while(av_read_frame(pFormatCtx, &packet)>=0)

{

avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished,  &packet);

av_free_packet(&packet);

}

av_free(buffer);

av_free(pFrameRGB);

av_free(pFrame);

avcodec_close(pCodecCtx);

avformat_close_input(&pFormatCtx); 



void av_register_all (void)

// Initialize libavformat and register all the muxers, demuxers and protocols.

[링크 : https://www.ffmpeg.org/.../group__lavf__core.html#ga917265caec45ef5a0646356ed1a507e3]


int avformat_open_input (AVFormatContext ** ps,

const char * url,

AVInputFormat * fmt,

AVDictionary ** options 

)

[링크 : https://www.ffmpeg.org/.../group__lavf__decoding.html#ga31d601155e9035d5b0e7efedc894ee49]


void avformat_close_input (AVFormatContext ** s)

[링크 : https://www.ffmpeg.org/.../group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4]


int avformat_find_stream_info ( AVFormatContext * ic, AVDictionary ** options )

// Read packets of a media file to get stream information.

[링크 : https://www.ffmpeg.org/.../group__lavf__decoding.html#gad42172e27cddafb81096939783b157bb]


void av_dump_format ( AVFormatContext * ic,

int index,

const char * url,

int is_output 

)

//Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.

[링크 : https://www.ffmpeg.org/.../group__lavf__misc.html#gae2645941f2dc779c307eb6314fd39f10]


AVCodec* avcodec_find_decoder ( enum AVCodecID id )

// Find a registered decoder with a matching codec ID.

[링크 : https://www.ffmpeg.org/.../group__lavc__decoding.html#ga19a0ca553277f019dd5b0fec6e1f9dca]


int avcodec_open2 ( AVCodecContext * avctx,

const AVCodec * codec,

AVDictionary ** options 

)

// Initialize the AVCodecContext to use the given AVCodec.

// Warning - This function is not thread safe!

[링크 : https://www.ffmpeg.org/.../group__lavc__core.html#ga11f785a188d7d9df71621001465b0f1d]


AVFrame* av_frame_alloc ( void )

// Allocate an AVFrame and set its fields to default values.

[링크 : https://www.ffmpeg.org/doxygen/3.2/group__lavu__frame.html#gac700017c5270c79c1e1befdeeb008b2f]


attribute_deprecated int avpicture_get_size ( enum AVPixelFormat pix_fmt,

int width,

int height 

)

[링크 : https://www.ffmpeg.org/doxygen/3.2/group__lavc__picture.html#gad2eba60171ee81107d2ca3a6957f4f2d]


int av_image_get_buffer_size ( enum AVPixelFormat pix_fmt,

int width,

int height,

int align 

)

[링크 : https://www.ffmpeg.org/doxygen/3.2/group__lavu__picture.html#ga24a67963c3ae0054a2a4bab35930e694]


void* av_malloc ( size_t size )

[링크 : https://www.ffmpeg.org/.../group__lavu__mem__funcs.html#ga9722446c5e310ffedfaac9489864796d]



struct SwsContext* sws_getContext ( int srcW,

int srcH,

enum AVPixelFormat srcFormat,

int dstW,

int dstH,

enum AVPixelFormat dstFormat,

int flags,

SwsFilter * srcFilter,

SwsFilter * dstFilter,

const double * param 

)

[링크 : https://www.ffmpeg.org/doxygen/3.2/group__libsws.html#gaf360d1a9e0e60f906f74d7d44f9abfdd]


attribute_deprecated int avpicture_fill ( AVPicture * picture,

const uint8_t * ptr,

enum AVPixelFormat pix_fmt,

int width,

int height 

)

[링크 : https://www.ffmpeg.org/doxygen/3.2/group__lavc__picture.html#gab740f592342cbbe872adf3e85c52e40c]


int av_image_fill_arrays ( uint8_t * dst_data[4],

int dst_linesize[4],

const uint8_t * src,

enum AVPixelFormat pix_fmt,

int width,

int height,

int align 

)

[링크 : https://www.ffmpeg.org/doxygen/3.2/group__lavu__picture.html#ga5b6ead346a70342ae8a303c16d2b3629]


int av_read_frame ( AVFormatContext * s,

AVPacket * pkt 

)

[링크 : https://www.ffmpeg.org/doxygen/3.2/group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61]


attribute_deprecated int avcodec_decode_video2 ( AVCodecContext * avctx,

AVFrame * picture,

int * got_picture_ptr,

const AVPacket * avpkt 

)

[링크 : https://www.ffmpeg.org/doxygen/3.2/group__lavc__decoding.html#ga3ac51525b7ad8bca4ced9f3446e96532]


int avcodec_receive_frame ( AVCodecContext * avctx,

AVFrame * frame 

)

[링크 : https://www.ffmpeg.org/doxygen/3.2/group__lavc__decoding.html#ga11e6542c4e66d3028668788a1a74217c]




+

2017.03.06


avcodec_register_all();

av_register_all();

avformat_network_init();


[링크 : http://laconicd.blogspot.com/2014/01/ffmpeg.html]

[링크 : http://egloos.zum.com/aslike/v/3083403]


+

2017.03.08

[링크 : https://www.codeproject.com/Tips/111468/FFmpeg-Tutorial]

[링크 : http://dranger.com/ffmpeg/tutorial01.html]

[링크 : https://ffmpeg.org/doxygen/trunk/doc_2examples_2decoding_encoding_8c-example.html]

'Programming > ffmpeg' 카테고리의 다른 글

vlc "network-caching" / ffmpeg "buffer_size" 소스 검색  (0) 2017.03.07
ffplay.c  (0) 2017.03.06
ffmpeg 3.2 소스관련  (0) 2017.02.10
ffmpeg - vlc cache 설정관련  (0) 2017.02.10
ffmpeg + opengl  (0) 2017.02.09
Posted by 구차니
Programming/ffmpeg2017. 2. 10. 17:20

'Programming > ffmpeg' 카테고리의 다른 글

ffplay.c  (0) 2017.03.06
ffmpeg 예제 소스 분석  (0) 2017.02.10
ffmpeg - vlc cache 설정관련  (0) 2017.02.10
ffmpeg + opengl  (0) 2017.02.09
ffmpeg / ffplay 딜레이 관련 분석  (0) 2017.02.09
Posted by 구차니
Programming/ffmpeg2017. 2. 10. 13:33

도대체 vlc의  :network-caching 설정은 어디를 적용하는거야?!?!?


일단 구조적으로

rtsp 쪽 네트워크 버퍼

ffmpeg avcodec decoder쪽 버퍼

sdl등의 비디오 버퍼

버퍼만 해도 세개인데 어느녀석을 건드려야 레이턴시가 줄어들까?


[링크 : https://wiki.videolan.org/..HowTo/Advanced_Streaming_Using_the_Command_Line/]

[링크 : http://stackoverflow.com/.../which-functions-of-live555-is-used-in-vlc-for-network-caching-option]

'Programming > ffmpeg' 카테고리의 다른 글

ffmpeg 예제 소스 분석  (0) 2017.02.10
ffmpeg 3.2 소스관련  (0) 2017.02.10
ffmpeg + opengl  (0) 2017.02.09
ffmpeg / ffplay 딜레이 관련 분석  (0) 2017.02.09
ffmpeg 예제 (sdl / live555)  (0) 2017.02.06
Posted by 구차니
Programming/ffmpeg2017. 2. 9. 21:21


[링크 : http://aslike.egloos.com/category/└%20FFMPEG] // 연재 중단으로 openGL 관련내용 x

[링크 : http://sijoo.tistory.com/82]

'Programming > ffmpeg' 카테고리의 다른 글

ffmpeg 예제 소스 분석  (0) 2017.02.10
ffmpeg 3.2 소스관련  (0) 2017.02.10
ffmpeg - vlc cache 설정관련  (0) 2017.02.10
ffmpeg / ffplay 딜레이 관련 분석  (0) 2017.02.09
ffmpeg 예제 (sdl / live555)  (0) 2017.02.06
Posted by 구차니
프로그램 사용/sdl2017. 2. 9. 21:18

sdl 이라는 녀석으로 한번 해봐야 하려나..

윈도우에서는 DirectDraw를 쓴다고 하니 일단 Platformsdk 안깔아도 되서 편할듯


[링크 : http://prog3.com/sbdm/blog/hjl240/article/details/47857175] sdl + mfc

[링크 : http://dranger.com/ffmpeg/] // ffmpeg + sdl + mfc

'프로그램 사용 > sdl' 카테고리의 다른 글

sdl tutorial  (0) 2022.05.27
SDL - Simple DirectMedia Layer  (0) 2021.07.06
SDL - Simple DirectMedia Layer  (0) 2011.12.12
Posted by 구차니
Programming/ffmpeg2017. 2. 9. 19:43

vlc 에서 rtsp 추가 옵션을 보면

캐쉬로 기본 1000ms 가 설정되는데 이걸 어디서 설정하나 검색중..


ffplay의 max_delay?

ffplay -max_delay 500000 -rtsp_transport udp -v trace "rtsp://user:pass@CamIP:Port/URL" 

[링크 : https://github.com/ZoneMinder/ZoneMinder/issues/811]


ffplay -h 도움말을 보니 이렇게 us 단위라네..

-max_delay         <int>   ED... maximum muxing or demuxing delay in microseconds 


다시 읽어 보니.. 레이턴시에 영향을 주긴 하지만.. TCP에는 적용사항이 없고

UDP에서 패킷 재조합시간에 대한 내용이라 일단 패스~

When receiving data over UDP, the demuxer tries to reorder received packets (since they may arrive out of order, or packets may get lost totally). This can be disabled by setting the maximum demuxing delay to zero (via the max_delay field of AVFormatContext). 

[링크 : https://ffmpeg.org/ffmpeg-protocols.html#rtsp]

[링크 : https://ffmpeg.org/doxygen/2.7/structAVFormatContext.html#a58422ed3d461b3440a15cf057ac5f5b7]


AVFormatContext의 buffer_size

cache 버퍼 크기

av_dict_set(&options, "buffer_size", "655360", 0); 

[링크 : http://stackoverflow.com/questions/29075467/set-rtsp-udp-buffer-size-in-ffmpeg-libav]

  [링크 : https://git.libav.org/?p=libav.git;a=commit;h=e3ec6fe7bb2a622a863e3912181717a659eb1bad] commit log

  [링크 : https://git.libav.org/?p=libav.git;a=blob;f=libavformat/rtsp.c;h...d] rtsp whole source

  [링크 : https://git.libav.org/?p=libav.git;a=blobdiff;f=libavformat/rtsp.c;h...f] diff


1547 AVDictionary *metadata;

[링크 : https://ffmpeg.org/doxygen/trunk/avformat_8h_source.html#l01331] AVFormatContext structure


int av_dict_set (AVDictionary ** pm, const char * key, const char * value, int flags ) 

[링크 : https://www.ffmpeg.org/doxygen/2.7/group__lavu__dict.html#ga8d9c2de72b310cef8e6a28c9cd3acbbe]


AVCodecContext의 rc_buffer_size

int AVCodecContext::rc_buffer_size

decoder bitstream buffer size


encoding: Set by user.

decoding: unused

Definition at line 2291 of file avcodec.h. 

[링크 : https://www.ffmpeg.org/doxygen/2.5/structAVCodecContext.html#a15000607a7e2371162348bb35b0184c1]


일단... 두개 옵션을 줘서 어느 구간에서 지연시간들이 생기는지 검사할 수 있는 듯?

Also setting -probesize and -analyzeduration to low values may help your stream start up more quickly (it uses these to scan for "streams" in certain muxers, like ts, where some can appears "later", and also to estimate the duration, which, for live streams, the latter you don't need anyway). This should be unneeded by dshow input. 

[링크 : https://trac.ffmpeg.org/wiki/StreamingGuide#Latency]

'Programming > ffmpeg' 카테고리의 다른 글

ffmpeg 예제 소스 분석  (0) 2017.02.10
ffmpeg 3.2 소스관련  (0) 2017.02.10
ffmpeg - vlc cache 설정관련  (0) 2017.02.10
ffmpeg + opengl  (0) 2017.02.09
ffmpeg 예제 (sdl / live555)  (0) 2017.02.06
Posted by 구차니

auth.log에서 정규표현식으로 아이피 빼내니 편하긴 하네

공부해봐야지 ㅠㅠ


.*?((?:\d{1,3}\.){3}\d{1,3})|.+

$1



[링크 : http://stackoverflow.com/questions/23707270/notepad-keep-only-ip-addresses]

Posted by 구차니

밴하고 있을 시간을 -1로 하면 영구 차단이라고 한다.

bantime = -1

[링크 : http://serverfault.com/questions/415040/permanent-block-of-ip-after-n-retries-using-fail2ban]


그런데 fail2ban 설정을 바꾼다고 재시작 해버리니 밴이 풀리네?!

그걸 유지할 방법이 없을려나


192.168.0.xxx 이런식으로 대역을 전체 막는 방법

$ vi /etc/fail2ban/jail.conf

banaction = iptables-multiport


$ vi /etc/fail2ban/action.d/iptables-multiport.conf

actionban = iptables -I fail2ban-<name> 1 -s <ip>/24 -j <blocktype>

actionunban = iptables -D fail2ban-<name> -s <ip>/24 -j <blocktype>


$ man iptables

       [!] -s, --source address[/mask][,...]

              Source  specification.  Address  can  be either a network name, a hostname, a network IP address (with /mask), or a plain IP address. Hostnames will be

              resolved once only, before the rule is submitted to the kernel.  Please note that specifying any name to be resolved with a remote query such as DNS is

              a  really bad idea.  The mask can be either an ipv4 network mask (for iptables) or a plain number, specifying the number of 1's at the left side of the

              network mask.  Thus, an iptables mask of 24 is equivalent to 255.255.255.0.  A "!" argument before the address specification inverts the sense  of  the

              address.  The  flag  --src  is an alias for this option.  Multiple addresses can be specified, but this will expand to multiple rules (when adding with

              -A), or will cause multiple rules to be deleted (with -D).


[링크 : https://www.righter.ch/index.php/2014/12/10/block-a-whole-ip-range-with-fail2ban/]


블랙리스트 파일

[링크 : http://looke.ch/wp/list-based-permanent-bans-with-fail2ban]


수동 ban

$ fail2ban-client 

    set <JAIL> banip <IP>                    manually Ban <IP> for <JAIL>

    set <JAIL> unbanip <IP>                  manually Unban <IP> in <JAIL>


하나만 차단하기

$ sudo fail2ban-client set ssh banip 221.194.44.252

대역 차단하기

$ sudo fail2ban-client set ssh banip 221.194.44.252/24 


$ sudo iptables -L

Chain fail2ban-ssh (1 references)

target     prot opt source               destination

REJECT     all  --  221.194.44.0/24      anywhere             reject-with icmp-port-unreachable

REJECT     all  --  221.194.44.252       anywhere             reject-with icmp-port-unreachable

RETURN     all  --  anywhere             anywhere 


[링크 : https://www.howtoforge.com/community/threads/how-to-manually-unban-ip-blocked-by-fail2ban.51366/]

'프로그램 사용 > fail2ban' 카테고리의 다른 글

fail2ban ssh 차단 실패???  (0) 2017.03.06
fail2ban phpmyadmin  (0) 2017.02.28
fail2ban 재시작을 위한 차단목록 추가?  (0) 2017.02.15
ssh 로그인 보안 - fail2ban  (4) 2017.02.08
apache ip deny  (0) 2017.02.08
Posted by 구차니

간단하게 요약하면..

이번 로그 파일을 합치고

/etc/webalizer/webalizer.conf를 복사해서

새로운 설정파일을 만든 후

아래와 같이 설정파일을 지정해서(-c) 돌리는 방법이라고 해야하나?

$ sudo webalizer -c /etc/webalizer/webalizer.conf.old 


[링크 : http://www.pc-freak.net/blog/linux-generating-web-statistics-apache-logs-webalizer/]



실험을 해보니.. incremental이나 history 적용하니

옛날 버전이 되지 않아서, 두개 설정 데이터를 지우거나 구버전 설정파일에서는 해당 기능을 꺼야

이전 버전들이 새로 생성된다.

Posted by 구차니