9
FFmpeg 命令行工具 - 图像处理和数字音频
source link: http://blog.danthought.com/programming/2020/11/23/ffmpeg-tools-image-processing-and-digital-audio/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
这篇文章讲解 FFmpeg 命令行工具中使用图像处理和数字音频相关的功能。
静态图片:
ffmpeg -i videoclip.avi -ss 01:23:45 image.jpg
动态图片:
ffmpeg -i promotion.swf -pix_fmt rgb24 promotion.gif
内置视频源
使用内置视频源创建静态图片:
ffmpeg -f lavfi -i color=c=red:s=728x90 -frames:v 1 leaderboard.png
视频和序列图片之间的转换
视频转换为序列图片:
ffmpeg -i clip.avi frame%d.jpg
序列图片转换为视频:
ffmpeg -f image2 -i img%d.jpg -r 25 video.mp4
可以使用 FFmpeg 命令行工具 - 视频编辑 中讲解的视频过滤器来对图片进行编辑。
图片格式转换
PNG 格式转换为 JPG 格式:
ffmpeg -i illustration.png illustration.jpg
通过 iOS 利用 AudioToolbox 将 PCM 编码为 AAC 来了解数字音频的理论知识。
常见的音频采样率:
常见的音频量化格式:
常见的音频格式:
生产单一音调的音频:
ffmpeg -f lavfi -i aevalsrc="sin(440*2*PI*t)" -t 10 noteA4.mp3
生产左右两个音调的音频:
ffplay -f lavfi -i aevalsrc="sin(261.63*2*PI*t)|cos(523.25*2*PI*t):c=FL+FR"
通过 volume 音频过滤器调节音量:
ffmpeg -i live.mp3 -af volume=1/2 quiet_music.mp3
ffmpeg -i sound.aac -af volume=10dB louder_sound.aac
通过 pan 音频过滤器可以进行单声道和立体声之间的转换。
通过 -map_channel 选项可以指定到文件的音频流的声道:
-map_channel [in_file_id.stream_spec.channel_id|-1][:out_file_id.stream_spec]
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK