FFmpeg命令 ---- 封裝和圖片轉換


轉封裝

保持編碼格式:
ffmpeg -i test.mp4 -vcodec copy -acodec copy test_copy.ts
ffmpeg -i test.mp4 -codec copy test_copy2.ts

改變編碼格式:
ffmpeg -i test.mp4 -vcodec libx265 -acodec libmp3lame out_h265_mp3.mkv

修改幀率:
ffmpeg -i test.mp4 -r 15 -codec copy output.mp4 (錯誤命令)
ffmpeg -i test.mp4 -r 15 output2.mp4

修改視頻碼率:
ffmpeg -i test.mp4 -b 400k output_b.mkv (此時音頻也被重新編碼)

修改視頻碼率:

ffmpeg -i test.mp4 -b:v 400k output_bv.mkv

修改音頻碼率:
ffmpeg -i test.mp4 -b:a 192k output_ba.mp4
如果不想重新編碼video ,需要加上-vcodec copy

修改音視頻碼率
ffmpeg -i test.mp4 -b:v 400k -b:a 192k output_bva.mp4

修改視頻分辨率:
ffmpeg -i test.mp4 -s 480x270 output_480x270.mp4

修改音頻采樣率 :
ffmpeg -i test.mp4 -ar 44100 output_44100hz.mp4

圖片和視頻轉換

截取一張圖片
ffmpeg -i test.mp4 -y f image2 -ss 00:00:02 -vframes 1 -s 640x360 test.jpg
ffmpeg -i test.mp4 -y f image2 -ss 00:00:02 -vframes 1 -s 640x360 test.bmp
-i 輸入
-y 覆蓋
-f 格式
image2 一種格式
-ss 起始值
-vframes 幀 如果大於 1 那么 輸出加 %03d test%03d.jpg
-s 格式大小 size

轉換視頻為圖片(每幀一張圖)
ffmpeg -i test.mp4 -t 5 -s 640x360 -r 15 frame%03d.jpg

圖片轉換為視頻
ffmpeg -f image2 -i frame%03d.jpg -r 25 video.mp4

從視頻中生成 GIF 圖片
ffmpeg -i test.mp4 -t 5 -r 1 image1.gif
ffmpeg -i test.mp4 -t 5 -r 25 -s 640x360 image2.gif

將 GIF 轉化為 視頻
ffmpeg -f gif -i image2.gif image2.mp4


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM