///-Stream 재전송----------------------------------------------------------------------------------

./ffmpeg -i rtmp://서버ip -acodec copy -vcodec copy -f mpegts -bsf:v h264_mp4toannexb udp://destip:1234

///-image----------------------------------------------------------------------------------

YUV -> JPEG

date;for i in {001..100};do ../ffmpeg -s 1920x1080 -pix_fmt yuv420p -i ./ho$i.yuv ./$i.jpg -loglevel panic;done;date

./ffmpeg -s 1920x1080 -pix_fmt yuv420p -i ../../ho0000241.yuv ./test.jpg

ffmpeg -s 640x480 -pix_fmt yuv420p -i test-yuv420p.yuv test-640x480.jpg

ffmpeg -s 640x480 -pix_fmt uyvy422 -i test-yuv422uyvy.yuv test-640x480.jpg

JPEG-> YUV

ffmpeg -i test-640x480.jpg -s 640x480 -pix_fmt yuv420p test-yuv420p.yuv

///-Video----------------------------------------------------------------------------------

/// h265

ffmpeg -i input -c:v libx265 -preset medium -crf 28 -c:a aac -b:a 128k output.mp4

///

ffmpeg -i BBC.2008.OCEANS.8of8.Arctic.Ocean.720p.AC3.mkv -t 120 -b 600k -s 1280x720 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame BBBC.avi

ffmpeg -i Black.Hawk.Down.2001.720p.BluRay.x264-snoopy.mkv -t 120 -b 600k -s 1280x720 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame black.avi

ffmpeg -i Black.Hawk.Down.2001.720p.BluRay.x264-snoopy_nosub.mkv -t 120 -b 600k -s 1280x720 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame black.mkv
ffmpeg -i Black.Hawk.Down.2001.720p.BluRay.x264-snoopy_nosub.mkv -t 120 -s 1280x528 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame black.mkv
ffmpeg -i Black.Hawk.Down.2001.720p.BluRay.x264-snoopy_nosub.mkv -t 120 -s 1280x528 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame black.mp4
ffmpeg -i Black.Hawk.Down.2001.720p.BluRay.x264-snoopy_nosub.mkv -t 120 -s 1280x528 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libfaac black.mp4

ffmpeg -i Black.Hawk.Down.2001.720p.BluRay.x264-snoopy_nosub.mkv -t 120 -s 1280x528 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libfaac black.mp4
ffmpeg -i Black.Hawk.Down.2001.720p.BluRay.x264-snoopy_nosub.mkv -t 120 -s 1280x528 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libfaac black.mp4


ffmpeg -i Black.Hawk.Down.2001.720p.BluRay.x264-snoopy_nosub.mkv -t 120 -b 1200k -s 720x480 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libfaac black720480.mp4
ffmpeg -i Black.Hawk.Down.2001.720p.BluRay.x264-snoopy_nosub.mkv -t 120 -b 1200k -s 720x480 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame black720480.mkv
///-----------------------------------------------------------------------------------

./ffmpeg -i Ghost.House.2004.XviD.AC3.2AUDIO.CD1-WAF.avi -t 60 -b 1200k -s 320x240  -vcodec libxvid -acodec copy gh_ac3.avi


./ffmpeg -i ac3-xvidac3cimg-amtr.dc-samplei.avi -t 60 -b 600k -s 176x144 -vcodec libxvid -ar 48000 -ab 128k -ac 6 -acodec ac3 gbb_ac3.avi


./ffmpeg -i ac3-xvidac3cimg-amtr.dc-samplei.avi -t 60 -b 600k -s 176x144 -vcodec libx264 -ar 48000 -ab 128k -ac 6 -acodec ac3 gbb_ac3.avi


./ffmpeg -i ac3-xvidac3cimg-amtr.dc-samplei.avi -t 60 -b 600k -s 176x144 -vcodec libx264 -ar 48000 -ab 128k -ac 6 -acodec ac3 gbb_ac3.avi


./ffmpeg -i loveages_xvid.avi -t 60 -b 1200k -vcodec libx264 -ar 44100 -ab 192k -ac 2 -acodec ac3 love_x264_ac3.avi

 

./ffmpeg -i NCIS.Los.Angeles.S01E01.720p.HDTV.X264-DIMENSION.mkv -t 60 -sameq -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame ncis.mkv

./ffmpeg -i NCIS.Los.Angeles.S01E01.720p.HDTV.X264-DIMENSION.mkv -t 60 -sameq -vcodec copy -ar 44100 -ab 128k -ac 2 -acodec libmp3lame ncis.mkv

 

./ffmpeg -i NCIS.Los.Angeles.S01E01.720p.HDTV.X264-DIMENSION.mkv -t 30 -sameq -vcodec libx264 -ar 48000 -ab 128k -ac 6 -acodec ac3 ncis-ac3-6ch.mkv

 


./ffmpeg -i NCIS.Los.Angeles.S01E01.720p.HDTV.X264-DIMENSION.mkv -t 60 -vcodec copy -ar 48000 -ab 128k -ac 6 -acodec ac3 ncis-ac3-6ch.avi


#if 0
#define gprintf(fmt, args...)      \
 LOGE("[%d],%s:%d, %s(): "fmt,           \
   gettid(), GET_SHORT_FILENAME(__FILE__), __LINE__, __FUNCTION__,     ##args)
#else
#define gprintf(fmt, args...)
#endif   

 

char name[256];

int i;
int *ptr = (int *)aFileName.get_str();

for (i = 0; i < aFileName.get_size(); i++) {
    name[i] = ptr[i];
}


./ffmpeg -i HighKick.E55.091126.HDTV.720p.x264.AC3-ThinkBiG.mkv -t 360 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec ac3 high.mkv


./ffmpeg -i 'f(x)-LA-cha-Ta(4in1)3.mkv' -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec ac3 fx_lachata.mkv

 

 


///--------------------------------------------------------------------------------------------------------------------


 [ffmpeg] 동영상의 길이(시간) 확인하기 

ffmpeg으로 동영상에서 음성이나 영상 추출시 사용할 수 있다.

----- 영상 -------------------------------------------
FPS 구하기 : 비디오스트림의 r_frame_rate를 변환하면 fps를 구할 수 있다.
double fps   = av_q2d(pFormatCtx->streams[videoStream]->r_frame_rate);

동영상 길이 구하기 :
 비디오스트림의 time_base는 프레임당 시간값이 저장되어 있다.
 그리고 비디오스트림의 duration에는 총 프레임 수가 저장되어 있다.

 이 두 값을 곱하면 동영상의 총 길이를 구할 수 있다.
double dur = av_q2d(pFormatCtx->streams[videoStream]->time_base) * pFormatCtx->streams[videoStream]->duration;


----- 음성 -------------------------------------------
audioStream의 데이터 값 중 duration 값에는 오디오에 할당된 실제 바이트가 입력되어 있다.
pFormatCtx->streams[audioStream]->duration

따라서 wave header를 생성시 이 값을 그대로 넣으면 된다.

wf.nSubChunk2Size = (DWORD)( pFormatCtx->streams[audioStream]->duration );

audio의 시간을 알고 싶다면

pFormatCtx->streams[audioStream]->duration / wf.nAvgBytesPerSec

하면 초단위의 시간이 나온다.

---------------------------------------------------------------------------------------------
// FFMPEG을 이용한 웨이브 헤더 생성

MY_WAVEFORMATEX wf;
wf.Riff   = 0x46464952;    // "RIFF" { 'R', 'I', 'F', 'F' };
wf.Wave   = 0x45564157;    // "WAVE" { 'W', 'A', 'V', 'E' };
wf.Fmt   = 0x20746D66;    // "fmt " { 'f', 'm', 't', ' ' };
wf.nSubChunk1Size = 16;
wf.wFormatTag  = WAVE_FORMAT_PCM;  // PCM_WAVE = 1
wf.nChannels  = pCodecCtx_a->channels > 2 ? 2 : pCodecCtx_a->channels;
wf.nSamplesPerSec = pCodecCtx_a->sample_rate;
switch(pCodecCtx_a->sample_fmt) {
    case SAMPLE_FMT_U8 :     wf.wBitsPerSample = 8;     break;
    case SAMPLE_FMT_S16 :    wf.wBitsPerSample = 16;   break;
    case SAMPLE_FMT_S32 :    wf.wBitsPerSample = 32;   break;
    default :    bAudio = false;                                           break;
}
wf.nBlockAlign  = (wf.wBitsPerSample / 8) * wf.nChannels;
wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
wf.Data    = 0x61746164;    // "data" { 'd', 'a', 't', 'a' };
wf.nSubChunk2Size = (DWORD)( pFormatCtx->streams[audioStream]->duration );
wf.nChunkSize  = wf.nSubChunk2Size + sizeof(MY_WAVEFORMATEX) - 8;

 

 

ffmpeg -i test_h264_mp3_176x144.avi -vcodec copy -ar 44100 -ab 128k -ac 2 -acodec libmp3lame aa.mkv
ffmpeg -i test_h264_mp3_176x144.avi -vcodec copy -acodec copy aa.mkv

ffmpeg -i 320x240_csi.mkv -vcodec copy -acodec copy aa.avi

 

./ffmpeg -i test_h264_mp3_176x144.avi -vcodec copy -an aa.avi

./ffmpeg -i test_h264_mp3_176x144.avi -vn -ar 44100 -ab 128k -ac 2 -acodec libmp3lame novideo.mkv


ffmpeg -i test_h264_mp3_176x144.avi -vcodec copy -ar 44100 -ab 128k -ac 2 -acodec libmp3lame aa.mkv

 

ffmpeg -i test_h264_mp3_176x144.mkv -vcodec copy -ar 44100 -ab 128k -ac 2 -acodec libmp3lame gg.avi

 

./ffmpeg -i test_h264_mp3_176x144.avi -vn -ar 44100 -ab 128k -ac 2 -acodec libmp3lame novideo.avi


./ffmpeg -i test_h264_mp3_176x144.avi -vcodec copy -ar 44100 -ab 128k -ac 2 -acodec libmp3lame av.avi

 


ffmpeg -i ac3-xvidac3cimg-amtr.dc-samplei.avi -sameq  -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame erase.mkv

 

ffmpeg -i Ghost.House.2004.XviD.AC3.2AUDIO.CD1-WAF.avi -b 1200k -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame ghost.mkv


ffmpeg -i Ghost.House.2004.XviD.AC3.2AUDIO.CD1-WAF.avi -b 1200k -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame ghost.mkv


ffmpeg -i csi.miami.s03e08.hdtv-lol.avi -t 360 -b 1200k -s 176x144 -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame 308_176_144.mkv


./ffmpeg -i csi.miami.s03e08.hdtv-lol.avi -t 60 -b 600k -s 176x144 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame ac3_test_48k_mp3.avi

 

ffmpeg -i csi.miami.s03e08.hdtv-lol.avi -t 360 -b 1200k -s 176x144 -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame 308_176_144.mkv


./ffmpeg -i loveages_xvid.avi -t 360 -b 1200k -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame loveage_x264_mp3.mkv


./ffmpeg -i loveages_xvid.avi -t 120 -b 1200k -vcodec mpeg4 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame loveage_mpeg4_mp3.mkv

 

 

 


./ffmpeg -threads 4 -i NCIS.S07E06.720p.HDTV.x264-CTU.mkv -t 120 -b 3000k -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame ncis_720p_mp3.mkv

./ffmpeg -i NCIS.S07E06.720p.HDTV.x264-CTU.mkv -t 360 -b 3000k -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame ncis_720p_mp3.mkv


./ffmpeg -i NCIS.S07E06.720p.HDTV.x264-CTU.mkv -t 360 -b 3000k -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame ncis_720p_mp3.avi

 

// xvid
./ffmpeg -threads 4 -i NCIS.S07E06.720p.HDTV.x264-CTU.mkv -t 180 -b 5000k -vcodec libxvid -ar 44100 -ab 128k -ac 2 -acodec libmp3lame xvid_ncis_720p_mp3.avi

./ffmpeg -threads 4 -i xvid_ncis_720p_mp3.avi -t 90 -b 3000k -vcodec libxvid -ar 44100 -ab 128k -ac 2 -acodec libmp3lame 264_ncis_720p_mp3.avi
./ffmpeg -threads 4 -i xvid_ncis_720p_mp3.avi -t 90 -b 3000k -vcodec libxvid -ar 44100 -ab 128k -ac 2 -acodec libmp3lame 264_ncis_720p_mp3.mkv

 

// docu
./ffmpeg -i H264_720P_dessin_docu.avi -t 180 -vcodec copy -ar 44100 -ab 128k -ac 2 -acodec libmp3lame docu_720p_mp3.avi
./ffmpeg -i H264_720P_dessin_docu.avi -t 180 -b 3000k -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame docu_720p_mp3.avi
./ffmpeg -i H264_720P_dessin_docu.avi -t 180 -b 3000k -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame docu_720p_mp3.mkv

- win32
./ffmpeg -i H264_720P_dessin_docu.avi -t 180 -vcodec copy -ar 44100 -ab 128k -ac 2 -acodec libmp3lame docu_720p_mp3.avi
ffmpeg -i docu_720P_dessin_docu.avi -t 180 -b 3000k -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame docu_720p_mp3.avi
ffmpeg -i docu_720P_dessin_docu.avi -t 180 -b 3000k -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame docu_720p_mp3.mkv


ffmpeg -threads 4 -i coyote_300sec_720ph264mp3.mkv -t 60 -b 5000k -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame co_720p.avi

ffmpeg -i co_720p.avi -b 5000k -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame co_720p.mkv

 


//yu

./ffmpeg -i yu_06.avi -t 120 -b 3000k -vcodec libx264 -ar 44100 -ab 128k -ac 2 -acodec libmp3lame yu_720p_mp3.avi


// coyote

./ffmpeg -i coyote_300sec_720ph264mp3.mkv -t 180 -s 1536x720 -b 5000k -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame coyote_1536_720p_mp3.avi

./ffmpeg -i coyote_300sec_720ph264mp3.avi -vcodec copy -ar 48000 -ab 128k -ac 2 -acodec libmp3lame coyote_300sec_720ph264mp3_fix.mkv


./ffmpeg -i coyote_300sec_720ph264mp3.avi -b 4500k -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame coyote_300sec_720ph264mp3_fix_avi_ffmpeg.mkv

 

 


./

./ffmpeg -i tellme.mpg -t 60 -b 5000k -s 1280x720 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame bbc.avi
./ffmpeg -i tellme.mpg -t 60 -b 5000k -s 1280x720 -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame bbc.mkv

 


./ffmpeg -threads 4 -i NCIS.S07E06.720p.HDTV.x264-CTU.mkv -t 80 -b 6000k -vcodec mpeg4 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame ncis.mp4


./ffmpeg -i ncis.mp4 -t 60 -b 5000k -vcodec libx264 -ar 48000 -ab 128k -ac 2 -acodec libmp3lame ncis.avi

 

동영상 자르기

ffmpeg   -i   동영상.mp4 -ss  시작초  -t  몇초동안자를것인가  -vcodec copy -acodec copy  동영상2.mp4

ffmpeg   -i   동영상.mp4 -ss  5  -t  25 -vcodec copy -acodec copy  동영상2.mp4

라고 하면 5초부터 30초까지 잘라지는 것임.


///-- 자막-subtitle-closed caption-----------------------------------------------------------------------------------------------------------------

 2008  ./ffmpeg -i sub.tp -codec:s:0 sub.srt

 2009  ./ffmpeg -i sub.tp -codec:s:1 sub.srt

 2010  ./ffmpeg -i sub.tp -codec:s:2 sub.srt

 2011  ./ffmpeg -i sub.tp -vn -an -codec:s srt sub.srt

 2016  ./ffmpeg -i sub.tp -vn -an -c:s:0 srt sub.srt

 2018  ./ffmpeg -i sub.tp -vn -an -c:s:1 srt sub.srt

 2020  ./ffmpeg -f lavfi -i movie=sub.tp[out+subcc] -map 0:1 sub.srt

 2021  ./ffmpeg -f lavfi -i movie=sub.tp[out+subcc] -map 0:2 sub.srt

 2022  ./ffmpeg -f lavfi -i movie=sub.tp[out+subcc] -map 0:1 sub.srt

 2025  ./ffprobe -f lavfi -i movie=sub.tp[out+subcc]

 2026  ./ffmpeg -i sub.tp -an -vn -bsf:s mov2textsub -scodec copy -f rawvideo sub.srt



./ccextractor -in=ts -out=srt -nobom -o sub.srt -utf8 -svc 1 "/home/lionelj/hoho/file/media/ts/세계테마기행.E1669.지중해의 푸른 전설, 몰타 2부.160531.1080i.HDTV.MPEG2-Empyree.ts"
./ccextractor -in=ts -out=srt -nobom -o sub.srt -utf8 -svc 1 "/home/lionelj/hoho/file/media/ts/세계테마기행.E1670.지중해의 푸른 전설, 몰타 3부.160601.1080i.HDTV.MPEG2-Empyree.ts"
./ccextractor -in=ts -out=srt -nobom -o sub.srt -utf8 -svc 1 "/home/lionelj/hoho/file/media/ts/[트와이스] Tell Me + CHEER UP (160529) - KBS열린음악회.tp"
./ccextractor -in=ts -out=srt -nobom -o sub.srt -utf8 -svc 1 "/home/lionelj/hoho/file/media/ts/KBS1tsdump.ts"
./ccextractor -in=ts -out=srt -nobom -o sub.srt -utf8 -svc 1 "/home/lionelj/hoho/file/media/ts/KBS2_tsdump.ts"



///--audio output null 로 보내기

ffmpeg -i /tmp/hofifo.ts -ar 8000 -ac 1 -acodec pcm_s16le /mnt/mmc6/ho.wav

fmpeg -i /tmp/hofifo.ts -ar 8000 -ac 1 -acodec pcm_s16le -f null /dev/null

ffmpeg -i /tmp/hofifo.ts -vn -ar 8000 -ac 1 -acodec pcm_s16le -f null /dev/null

'멀티미디어' 카테고리의 다른 글

mplayer 에서 ffmpeg demuxer 써서 플레이 하는 방법  (0) 2009.11.13
ffmpeg 변환 하는 명령어 모음  (0) 2009.11.11
MATROSKA 뽀개기 -_-;;  (0) 2009.10.08
Matroska Header  (0) 2009.09.29
Posted by Real_G