- # ffmpeg -i "冰雪奇緣BD雙語雙字.mkv"
-
ffmpeg -i "冰雪奇緣BD雙語雙字.mkv"
ffmpeg version 3.4.2-2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu2)
configuration: --prefix=/usr --extra-version=2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, matroska,webm, from '冰雪奇緣BD雙語雙字.mkv':
Metadata:
encoder : libebml v1.3.0 + libmatroska v1.4.0
creation_time : 2014-03-03T11:32:36.000000Z
Duration: 01:42:13.06, start: 0.000000, bitrate: 2691 kb/s
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 448 kb/s (default)
Metadata:
title : 英語
Stream #0:2(chi): Audio: ac3, 48000 Hz, stereo, fltp, 448 kb/s
Metadata:
title : 國語
- ffmpeg -i 冰雪奇緣BD雙語雙字.mkv -map 0:1 -b:a 64k -f mp3 -vn a.1.mp3
- ffmpeg -i 冰雪奇緣BD雙語雙字.mkv -map 0:2 -b:a 64k -f mp3 -vn a.2.mp3
順時針旋轉畫面90度
ffmpeg -i test.mp4 -vf "transpose=1" out.mp4
逆時針旋轉畫面90度
ffmpeg -i test.mp4 -vf "transpose=2" out.mp4
順時針旋轉畫面90度再水平翻轉
ffmpeg -i test.mp4 -vf "transpose=3" out.mp4
逆時針旋轉畫面90度水平翻轉
ffmpeg -i test.mp4 -vf "transpose=0" out.mp4
水平翻轉視頻畫面
ffmpeg -i test.mp4 -vf hflip out.mp4
垂直翻轉視頻畫面
ffmpeg -i test.mp4 -vf vflip out.mp4
###########################視頻切割
1. 導言
ffmepg剪切視頻,很方便,但是也有很大缺陷:
(1)剪切時間點不精確
(2)有時剪切的視頻開頭有黑屏
造成這些問題的原因是ffmpeg無法seek到非關鍵幀上。
一下本文通過一些參數配置盡可能地減輕以上問題
2. 基本剪切方法
ffmpeg -i test.mp4 -ss 10 -t 15 -codec copy cut.mp4
- 1
參數分析:
-i : source
-ss:start time
-t :duration
-c :video,audio codec
時間格式:
- x秒
- HOURS:MM:SS.MICROSECONDS
可以設置輸出視頻的編碼格式
-vcodec xxx
-acodec xxx
把-ss, -t參數放在-i參數之后,是對輸出文件執行的seek操作
輸入文件會逐幀解碼,直到-ss設置的時間點為止,這么操作會很慢,雖然時間點是准確的,但是很容易出現黑屏問題。
3. 參數優化
(1)將-ss, -t 參數放在-i參數之前
ffmpeg -ss 10 -t 15 -i test.mp4 -codec copy cut.mp4
- 1
對輸入文件執行seek操作,會seek到-ss設置的時間點前面的關鍵幀上。
時間不精確,但是不會出現黑屏
(2)accurate_seek
剪切時間更加精確
ffmpeg -ss 10 -t 15 -accurate_seek -i test.mp4 -codec copy cut.mp4
- 1
PS:accurate_seek必須放在-i參數之前
(3)avoid_negative_ts
如果編碼格式采用的copy 最好加上 -avoid_negative_ts 1參數
ffmpeg -ss 10 -t 15 -accurate_seek -i test.mp4 -codec copy -avoid_negative_ts 1 cut.mp4
- 1
4. 參考文獻
ffmpeg -i S1E01_踏水坑.avi -r 1 -ss 00:00:00 -t 20 %03d.jpg
意思是給 ffmpeg 輸入一個叫 S1E01_踏水坑.avi 的文件,讓它以每秒一幀的速度,從第0秒開始一直截取 20 秒長的時間,截取到的每一幅圖像,都用 3 位數字自動生成從小到大的文件名。
####################
合並視頻的一種方法
ffmpeg -f concat -i merge_list.txt -c copy output.mp4
其中merge_list.txt格式:
file 'file1.mp4'
file 'file2.mp4'
.
file 'filen.mp4'