当前位置:网站首页>Memo list: useful commands for ffmpeg command line tools
Memo list: useful commands for ffmpeg command line tools
2022-06-24 16:20:00 【mariolu】
FFmpeg Memo list
ffmpeg A list of useful commands for command line tools .
download FFmpeg: https://www.ffmpeg.org/download.html
Complete documentation : https://www.ffmpeg.org/ffmpeg.html
Basic conversion
ffmpeg -i in.mp4 out.avi
take MKV File remixing MP4
ffmpeg -i in.mkv -c:v copy -c:a copy out.mp4
High quality coding
Use crf( Constant rate factor ) Parameters to control the output quality .crf The lower the , The higher the quality ( Range :0-51). The default value is 23, And visual lossless compression corresponds to -crf 18. Use preset The parameter controls the speed of the compression process . Additional information : https://trac.ffmpeg.org/wiki/Encode/H.264
ffmpeg -i in.mp4 -preset slower -crf 18 out.mp4
Trim
No need to recode :
ffmpeg -ss [start] -i in.mp4 -t [duration] -c copy out.mp4
- -ss Specify the start time , for example 00:01:23.000 or 83( In seconds )
- -t Specify the duration of the clip ( Same format ).
- Latest version ffmpeg There is also a flag to provide the end time -to.
- -c Copy the first video , Audio and caption bitstreams are copied from the input to the output file , Without having to recode it . This does not compromise quality and makes the command run in seconds .
Use recoding :
If you don't specify -c copy This option ,ffmpeg The output video and audio will be automatically re encoded according to the format you select . To get high quality video and audio , Please read separately 《x264 Coding guide 》 and 《AAC Coding guide 》.
https://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide
http://ffmpeg.org/trac/ffmpeg/wiki/AACEncodingGuide
for example :
ffmpeg -ss [start] -i in.mp4 -t [duration] -c:v libx264 -c:a aac -strict experimental -b:a 128k out.mp4
Mix audio from video and other videos
From you to in0.mp4 Copy the video and from in1.mp4 Copy audio , Do the following :
ffmpeg -i in0.mp4 -i in1.mp4 -c copy -map 0:0 -map 1:1 -shortest out.mp4
- Use -c Copy , Carry out convection stream copied Recode , Without recoding it , Therefore, it will not cause quality loss . If you want to recode , Please see the FFmpeg Wiki:H.264 Coding guide .
- The -shortest Option will match the output duration to the duration of the shortest input stream .
- For more information , see also -map file .
Merge video
First , Make a text file
file 'in1.mp4' file 'in2.mp4' file 'in3.mp4' file 'in4.mp4'
then , function ffmpeg:
ffmpeg -f concat -i list.txt -c copy out.mp4
Delayed audio / video
Delay movie 3.84 second :
ffmpeg -i in.mp4 -itsoffset 3.84 -i in.mp4 -map 1:v -map 0:a -vcodec copy -acodec copy out.mp4
Delayed audio 3.84 second :
ffmpeg -i in.mp4 -itsoffset 3.84 -i in.mp4 -map 0:v -map 1:a -vcodec copy -acodec copy out.mp4
Burn subtitles
Use libass library ( Make sure ffmpeg The installation has this library in the configuration --enable-libass).
First convert the subtitle to .ass Format :
ffmpeg -i sub.srt sub.ass
Then add them using video filters :
ffmpeg -i in.mp4 -vf ass=sub.ass out.mp4
Extract frames from video
To extract 1 To 5 Seconds and 11 To 15 All frames between seconds , Do the following :
ffmpeg -i in.mp4 -vf select='between(t,1,5)+between(t,11,15)' -vsync 0 out%d.png
Only one frame per second is extracted :
ffmpeg -i in.mp4 -fps=1 -vsync 0 out%d.png
Rotate video
Clockwise rotation 90:
ffmpeg -i in.mov -vf "transpose=1" out.mov
about transpose Parameters , You can deliver :
0 = 90CounterCLockwise and Vertical Flip (default) 1 = 90Clockwise 2 = 90CounterClockwise 3 = 90Clockwise and Vertical Flip
Use -vf "transpose=2,transpose=2"180 degree .
download “ Transport stream ” Video streaming
- Find the playlist file , For example, using Chrome> F12> The Internet > filter :m3u8
- Download and connect video clips :
ffmpeg -i "path_to_playlist.m3u8" -c copy -bsf:a aac_adtstoasc out.mp4
If you receive “ agreement 'https Not on the white list ' file , password ' On !” error , Please add protocol_whitelist Options :
ffmpeg -protocol_whitelist "file,http,https,tcp,tls" -i "path_to_playlist.m3u8" -c copy -bsf:a aac_adtstoasc out.mp4
Mute some audio clips
To set the front of the audio 90 Seconds is replaced by mute , Do the following :
ffmpeg -i in.mp4 -vcodec copy -af "volume=enable='lte(t,90)':volume=0" out.mp4
To put 1'20“ and 1'30” Replace all audio between with mute , Do the following :
ffmpeg -i in.mp4 -vcodec copy -af "volume=enable='between(t,80,90)':volume=0" out.mp4
Deinterlace
ffmpeg -i in.mp4 -vf yadif out.mp4
Create video slides from images
Parameters :-r Mark image frame rate ( Countdown time of each image );-vf fps=25 Mark the real frame rate of the output .
ffmpeg -r 1/5 -i img%03d.png -c:v libx264 -vf fps=25 -pix_fmt yuv420p out.mp4
Extract images from video
- Extract all frames : ffmpeg -i input.mp4 thumb%04d.jpg -hide_banner
- Extract one frame per second : ffmpeg -i input.mp4 -vf fps=1 thumb%04d.jpg -hide_banner
- Only one frame is extracted : ffmpeg -i input.mp4 -ss 00:00:10.000 -vframes 1 thumb.jpg
Metadata : Change the title
ffmpeg -i in.mp4 -map_metadata -1 -metadata title="My Title" -c:v copy -c:a copy out.mp4
边栏推荐
- Global and Chinese markets of natural insect repellents 2022-2028: Research Report on technology, participants, trends, market size and share
- 山金期货安全么?期货开户都是哪些流程?期货手续费怎么降低?
- 打破内存墙的新利器成行业“热搜”!持久内存让打工人也能玩转海量数据+高维模型
- Wechat official account debugging and natapp environment building
- 2021-05-03: given a non negative integer num, how to avoid circular statements,
- Bitwise Operators
- 基于STM32的MD5校验
- [application recommendation] the hands-on experience and model selection suggestions of apifox & apipost in the recent fire
- Istio FAQ: sidecar startup sequence
- Golang+redis reentrant lock
猜你喜欢

60 divine vs Code plug-ins!!

C. Three displays(动态规划)Codeforces Round #485 (Div. 2)

【面试高频题】难度 3/5,可直接构造的序列 DP 题

Applet - use of template

ZOJ——4104 Sequence in the Pocket(思维问题)

B. Terry sequence (thinking + greed) codeforces round 665 (Div. 2)

Cap: multiple attention mechanism, interesting fine-grained classification scheme | AAAI 2021

B. Ternary Sequence(思维+贪心)Codeforces Round #665 (Div. 2)

Logging is not as simple as you think

我与“Apifox”的网络情缘
随机推荐
2021-05-01: given an ordered array arr, it represents the points located on the X axis. Given a positive number k
Global and Chinese market of insect proof clothing 2022-2028: Research Report on technology, participants, trends, market size and share
Fastjson 漏洞利用技巧
Istio FAQ: return 426 status code
Transpose convolution explanation
April 30, 2021: there are residential areas on a straight line, and the post office can only be built on residential areas. Given an ordered positive array arr
Pytorch 转置卷积
2021-04-24: handwriting Code: topology sorting.
【云原生 | Kubernetes篇】Kubernetes基础入门(三)
Logging is not as simple as you think
MD5 verification based on stm32
找出隐形资产--利用Hosts碰撞突破边界
Transpose convolution learning notes
Product level design of a project in SAP mm
Install the imagemagick7.1 library and the imageick extension for PHP
Goby+AWVS 实现攻击面检测
国泰君安期货安全么?期货开户怎么开?期货手续费怎么降低?
April 26, 2021: the length of the integer array arr is n (3 < = n < = 10^4), and each number is
Dismantle the industrial chain of synthetic rubber industry, and the supply chain may become a sharp weapon for breakthrough
Fastjson vulnerability utilization techniques