ffmpeg
- 裁剪yuv视频:
ffmpeg -pix_fmt yuv420p -s 416x240 -i test.yuv -pix_fmt yuv420p -vf crop=w:h:x:y test1.yuv
x:y:裁剪区域的左上角坐标 - 获取固定帧数的yuv视频:
ffmpeg -pix_fmt yuv420p -s 416x240 -i "BasketballPass_416x240_50.yuv" -pix_fmt yuv420p -s 416x240 -frames 1 test.yuv
- 获取某几帧视频:
./ffmpeg -s 1280x720 -i 720p.yuv -c:v rawvideo -filter:v "select='between(n\, 10\, 15)'" out720p.yuv
- 剪切mp4视频:
ffmpeg -ss 00:00:00 -t 00:00:30 -i test.mp4 -vcodec copy -acodec copy output.mp4
ss:开始时间,t:截取时长
- 加入-avoid_negative_ts避免结尾不是关键帧出现的空白
- 加入-c:v libx264 -c:a aac -strict experimental -b:a 98k重新编码,避免交集或空白 - 合并视频:
ffmpeg -f concat -i list.txt -c copy concat.mp4
list.txt:
file ./split.mp4
file ./split1.mp4
- 解码:
ffmpeg -i test.mp4 test.yuv
- 把265码流打包成mp4:
ffmpeg -f hevc -i test.265 -vcodec copy test.mp4
- 音视频打包成mp4:
ffmpeg -i test.265 -i test.aac -vcodec copy -acodec copy test.mp4
- 从mp4中提取出265码流:
ffmpeg -i test.mp4 -vcodec copy -f hevc test.265
- 从mp4中提取出音频:
ffmpeg -i test.mp4 -vn -acodec copy test.aac
- 缩放10bit yuv: (详细缩放可查看https://ffmpeg.org/ffmpeg-scaler.html文档)
-ffmpeg.exe -s:v 3840x2160 -pix_fmt yuv420p10le -i test_4k.yuv -vf scale=1920:1080 -c:v rawvideo -pix_fmt yuv420p10le test_1080p.yuv
-保持纵横比(指定其中一个,另一个设为-1):ffmpeg.exe -s:v 3840x2160 -i test_4k.yuv -vf scale=1920:-1 -c:v rawvideo test_1080p.yuv
-指定图像宽高(宽拉伸为原来的2倍):ffmpeg.exe -s:v 3840x2160 -i test_4k.yuv -vf scale=iw*2:ih -c:v rawvideo test_1080p.yuv
/ffmpeg.exe -s:v 3840x2160 -i test_4k.yuv -vf "scale=iw/2:ih/2" -c:v rawvideo test_1080p.yuv
/ffmpeg.exe -s:v 3840x2160 -i test_4k.yuv -vf "scale=iw*.5:ih*.5" -c:v rawvideo test_1080p.yuv
- 改变帧率:
ffmpeg.exe -s:v 1920x1080 -pix_fmt yuv420p10le -r 120 -i test_1080p_120fps.yuv -c:v rawvideo -pix_fmt yu v420p10le -r 25 test_1080p_25fps.yuv
- 8bit/10bit转换:
ffmpeg -s:v 1920x1080 -pix_fmt yuv420p -i test_8bit.yuv -pix_fmt yuv420p10le test_10bit.yuv
-pixel_format is an input option for raw demuxers.
-pix_fmt is an output option for the target format.
- 生成与视频匹配的无声音频:
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i test.265 -