ffmpeg -list_devices true -f dshow -i dummy
ffmpeg -f gdigrab -i desktop out.mpg
ffmpeg -f gdigrab -framerate 5 -offset_x 10 -offset_y 20 -video_size 640x480 -i desktop out.mpg
E:\\ffmpeg.exe -f gdigrab -framerate 25 -video_size 1366x768 -i desktop -f dshow -i audio="麦克风 (Realtek High Definition Audio)" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -pix_fmt yuv420p -q:v 1 -ar 22050 -ac 1 -s 1366x768 -y e://out.mp4
Win32 GDI-based screen capture device.
This device allows you to capture a region of the display on Windows.
There are two options for the input filename: desktop or title=window_title
The first option will capture the entire desktop, or a fixed region of the desktop. The second option will instead capture the contents of a single window, regardless of its position on the screen.
For example, to grab the entire desktop using ffmpeg:
ffmpeg -f gdigrab -framerate 6 -i desktop out.mpg
Grab a 640x480 region at position 10,20:
ffmpeg -f gdigrab -framerate 6 -offset_x 10 -offset_y 20 -video_size vga -i desktop out.mpg
Grab the contents of the window named "Calculator"
ffmpeg -f gdigrab -framerate 6 -i title=Calculator out.mpg
D:\BaiduYunDownload\ffmpeg-shared\ffmpeg-bin\ffmpeg.exe -f dshow -i video="Integrated Camera" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -s 480x320 -f flv rtmp://192.168.1.124/live/livestream
D:\BaiduYunDownload\ffmpeg-shared\ffmpeg-bin\ffplay -max_delay 100000 "rtmp://192.168.1.124/live/livestream live=1"
//打开会有点慢,但是没有延时
D:\BaiduYunDownload\ffmpeg-shared\ffmpeg-bin\ffplay.exe -fflags nobuffer -f flv "rtmp://192.168.1.124/live/livestream live=1"
直播流
rtmpdump.exe -o savename.flv -r rtmp://127.0.0.1/live/testlive -v
点播流
rtmpdump.exe -o savename.flv -r rtmp://127.0.0.1/vod/test.flv
直播需要加-v参数
ffmpeg -i src_480x272.yuv aa.h264 提示 Output file #0 does not contain any stream
应该是 ffmpeg -s 480x272 -i src_480x272.yuv aa.h264 而且必须是放在 -i之前,确定是输入参数,否则变成输出参数了
ffmpeg -y -i input.mp4 -vf "movie='D\:\path\logo.png' [logo];[in][logo] overlay=10:10 [out]" output.mp4
ffmpeg -i JINUSEAN.mp4 -vf delogo=x=72:y=32:w=168:h=86:band=10 output.mp4
rtmp://live.hkstv.hk.lxdns.com/live/hks
rtmp://media3.sinovision.net:1935/live/livestream
ffmpeg -f gdigrab -i desktop -f dshow -i video="Integrated Camera" -r 25 -c:v libx264 -preset ultrafast -filter_complex overlay=main_w-overlay_w-10:main_h-overlay_h-10 -acodec mp3 -ar 44100 -ac 2 -t 30 d:/video/desktopAndCamera.mp4 -y
ffmpeg -f gdigrab -i desktop -f dshow -i video="Integrated Camera" -filter_complex "[1:v]scale=w=150:h=150:force_original_aspect_ratio=decrease[ckout];[0:v][ckout]overlay=x=W-w-10:y=H-h-10[out]" -map "[out]" -movflags faststart -t 30 d:/video/desktopAndCamera.mp4 -y
ffmpeg -f gdigrab -i desktop -f dshow -i video="Integrated Camera" -f dshow -i audio="External Microphone (Conexant SmartAudio HD)" -filter_complex "[1:v]scale=w=150:h=150:force_original_aspect_ratio=decrease[ckout];[0:v][ckout]overlay=x=W-w-10:y=H-h-10[out]" -map "[out]" -map 2 -movflags faststart -acodec mp3 -ar 44100 -ac 2 -t 30 d:/video/desktopAndCamera.mp4 -y
如果录制摄像头的时候出现卡顿,提示[video input] too full or near too full(101% of size: 3041280 [rtbufsize parameter])! ..
可以设置-thread_queue_size 50,类似于设置缓冲区队列长度,默认是8
命令也就是
ffmpeg -f gdigrab -thread_queue_size 50 -i desktop -f dshow -thread_queue_size 50 -i video="Integrated Camera" -r 25 -c:v libx264 -preset ultrafast -filter_complex overlay=main_w-overlay_w-10:main_h-overlay_h-10 -acodec mp3 -ar 44100 -ac 2 -t 30 d:/video/desktopAndCamera.mp4 -y
主要是针对于16位的表示大小
原理是 将同一点的音频 相加,得到的就是该点的值 参考 :http://blog.csdn.net/xiaojun111111/article/details/52692077
ffmpeg.exe -re -i 1234.mp4 -f dshow -i audio=”立体声混音 (Realtek High Definition ” -filter_complex amix=inputs=2:duration=first:dropout_transition=0 -t 10 out.mp4 -y
参考: http://blog.csdn.net/xiaojun111111/article/details/52467815
ffmpeg
-
i d:/video/wangfeng
.mp
4
-
i d:/video/quwanting
.mp
4
-
map
0
:
0
-
map
0
:
1
-
map
1
:
0
-
map
1
:
1
-
c
copy
-
program
title
=
CCTV
1
:
program_num
=
1
:
st
=
0
:
st
=
1
-
program
title
=
CCTV
2
:
program_num
=
2
:
st
=
2
:
st
=
3
-
y
-
f mpegts d:/video/multiProgram.ts
10、合并文件
ffmpeg -safe 0 -y -f concat -i concat.txt -c copy -strict experimental -f mp4 TEMP_123.mp4
concat.txt 文件格式:
file 3cac8f76b06d4af69695c3d00ec0795f_h2642000000nero_aac16-1.mp4
file 3cac8f76b06d4af69695c3d00ec0795f_h2642000000nero_aac16-2.mp4
file 3cac8f76b06d4af69695c3d00ec0795f_h2642000000nero_aac16-3.mp4
11、给视频(无音频流)添加音频流:
ffmpeg -re -i rtmp://onairzb.cdvcloud.com/d5039f/4859cc -f lavfi -i "anullsrc=r=44100:cl=stereo" -vcodec copy -acodec aac -ar 44100 -ac 2 -strict -2 -f flv rtmp://192.168.0.95/live/123456
其中ffmpeg 官方文档中 有 Video Source 和 Audio Source, 需要和 -f lavfi (代表使用虚拟设备)
37 Audio Sources
40 Video Sources
可以查看官方文档
ffmpeg -i d:/video/wangfeng.mp4 -i d:/video/logo.png -i d:/video/logo.png -filter_complex "overlay=x=10:y=10,overlay=x=W-w-10:y=H-h-10" d:/video/wangfenglogo.mp4
ffmpeg -i d:/video/wangfeng.mp4 -i d:/video/logo.png -i d:/video/logo.png -filter_complex "[0:v]scale=960:640[sout],[1:v]scale=100:100[logo1],[sout][logo1]overlay=x=10:y=10[lout1],[2:v]scale=100:100[logo2],[lout1][logo2]overlay=x=W-w-30:y=H-h-30" d:/video/wangfenglogo.mp4
ffmpeg -i d:/video/wangfeng.mp4 -filter_complex "[0:v]scale=960:640[sout],movie='d\:/video/logo.png'[m1],[m1]scale=100:100[logo1],[sout][logo1]overlay=x=10:y=10[lout1],movie='d\:/video/logo.png'[m2],[m2]scale=100:100[logo2],[lout1][logo2]overlay=x=W-w-30:y=H-h-30" d:/video/wangfenglogo.mp4
12.1添加timeline,logo可以阶段显示
ffmpeg -i d:/video/wangfeng.mp4 -filter_complex "[0:v]scale=960:640[sout],movie='d\:/video/logo.png'[m1],[m1]scale=100:100[logo1],[sout][logo1]overlay=x=10:y=10:enable=between(t\,10.0\,20.0)[lout1],movie='d\:/video/logo.png'[m2],[m2]scale=100:100[logo2],[lout1][logo2]overlay=x=W-w-30:y=H-h-30" d:/video/wangfenglogo.mp4
12.2 logo使用gif,无限循环,使用loop,setpts,shortest,注意window的ffmpeg 卡死有问题
transcode -y -i 'ftp://scott:[email protected]/lxj/1.mp4' -filter_complex "[0:v]scale=640:360[s363],movie=filename=\'ftp://scott:[email protected]/lxj/logo.gif\':loop=0,setpts=N/(FRAME_RATE*TB)[logomovie363_0],[logomovie363_0]scale=100:100[logoscale363_0],[s363][logoscale363_0]overlay=x=10:y=10:shortest=1[out363]" -map [out363] -c:v h264 -b:v 500k -crf 23 -r 25.0 -g 250 -map 0:a -c:a aac -ab 32k -ac 1 -ar 22050 -strict experimental -f mp4 TEMP_text123.mp4
ffmpeg -i d:/video/wangfeng.mp4 -filter_complex [0:v]drawtext="fontfile=simsun.ttc:text='Test Text':x=100:y=50:fontsize=24:[email protected]:box=1:[email protected]"[dt1];[dt1]drawtext="fontfile=simsun.ttf:text='hello world':x=100:y=100:fontsize=24:[email protected]:box=1:[email protected]"[vout] -map [vout] d:/video/wangfeng_drawtext.mp4
最新的ffmpeg支持hls_enc_key hls_enc_uri
transcode_has_dash.bak -timeout -1 -y -i 'ftp://scott:[email protected]/lxj/1.mp4' -filter_complex "[0:v]scale=640:360[out371]" -map [out371] -c:v h264 -b:v 500k -crf 23 -r 25.0 -g 250 -map 0:a -c:a aac -ab 32k -ac 1 -ar 22050 -strict experimental -f hls -hls_time 10 -hls_segment_filename text132.m3u8_%d.ts -hls_list_size 0 -hls_enc_key encryptionkey128 -hls_enc_key_url http://192.168.0.85/ text132.m3u8
相应参数:
"extra_param":" -hls_enc 1 -hls_enc_key encryptionkey128 -hls_enc_key_url 'http://192.168.0.85/file.key' ",
"format":"hls",
"output_file" : "text143.m3u8"
ffmpeg循环推流,添加genpts,不能copy文件,时间戳不递增导致问题
ffmpeg -threads 2 -fflags +genpts -stream_loop -1 -re -i wangfeng1.mp4 -c:v h264 -c:a aac -f flv rtmp://192.168.0.95/live/12345