Showing posts with label 自媒体工具. Show all posts
Showing posts with label 自媒体工具. Show all posts

Monday, 30 December 2024

视频处理神器FFmpeg,超简单三招,告别模糊卡顿 - FFmpeg: Three Super Easy Tricks to Say Goodbye to Blurry Videos

自媒体、剪辑党福音!FFmpeg 超神助力,难题‘秒’解决,还不赶紧上车! - Good news for self-media and video editors! FFmpeg supercharges your work, solving problems in a flash. Jump on board!

嘿,做自媒体或是搞视频剪辑的小伙伴们,咱是不是都有过这些崩溃瞬间:辛辛苦苦压缩个视频,结果画面糊得像打了马赛克,美感全无;听到一段超赞的背景音乐,心痒痒想拿来当自己作品的 BGM 或者设成个性铃声,却死活找不到提取的门道;还有想快速截个视频片段,用软件操作一番后,得到的却是个画质惨不忍睹的 “残次品”。别愁啦,今天就给大伙介绍个超给力的神器 ——FFmpeg,保准让这些难题统统 “退下”!


FFmpeg,这个听起来就很有技术感的名字,其实比你想象的要亲民得多。它就像是一位隐身的视频专家,随时准备帮你解决那些看似复杂的问题。而且,安装FFmpeg简直不能再简单了。如果你是Mac用户,而且已经安装了Homebrew,那么只需在终端里输入一行命令,FFmpeg就能轻松成为你的囊中之物。或者Github手动安装。如果你更习惯于Windows系统,那么去FFmpeg的官方网站下载安装包,然后添加到环境变量,就能愉快地使用了。FFmpeg支持多平台,无论你是Mac、Windows还是Linux用户,都能轻松驾驭。它的帮助命令是”ffmpeg -h”。

好了,让我们来揭开FFmpeg的神秘面纱,看看它是如何用三个简单的命令,帮你解决视频压缩、音频提取和视频截取的问题。


首先,我们来看压缩视频的命令。你是否遇到过视频文件太大,想要压缩但又担心画质受损的问题?FFmpeg的这个命令能帮你在压缩的同时保持画质:


```

ffmpeg -i input.mp4 -c:v libx264 -r 25 -crf 21 -c:a aac output.mp4

```


这里的`-c:v libx264`指定了视频编码器为H264,`-r 25`设置了帧率为25,而`-crf 21`则是设置了码率,数值越小,质量越高。`-c:a aac`则是指定音频编码为AAC。是的,所谓压缩就是重新设置音频格式,视频格式,帧率和码率。


接下来,如果你听到了一段喜欢的背景音乐,想要提取出来做铃声或者提示音,FFmpeg也能轻松帮你实现:


```

ffmpeg -i input.mp4 -c:v libx264 -crf 21 -an output-v.mp4 -c:a aac -vn output-a.mp4

```


这里的`-an`是用来去掉音频的,而`-vn`则是去掉视频,让你只提取出音频文件(output-a.mp4)。


最后,如果你需要截取视频中的某一段,FFmpeg同样能帮你做到,而且避免了重新编码导致的画质损失:

```
ffmpeg -i input.mp4 -ss 00:00:01 -t 00:00:09 -c:v libx264 -crf 21 -c:a aac output.mp4
```

`-ss 00:00:01`表示从视频的第1秒开始截取,`-t 00:00:09`则是截取9秒的视频。


当你需要检查视频是否正常播放时,可以使用`ffplay output.mp4`命令,而如果你想要获取视频或音频的信息,`ffprobe output.mp4`则是你的好帮手。


FFmpeg就是这样一个简单易用的工具,它不仅能帮你告别视频模糊和卡顿,还能让你在视频处理的道路上越走越远。所以,亲爱的小伙伴们,不要再为视频处理的问题烦恼了,赶紧试试FFmpeg,让它成为你视频剪辑的好伙伴吧!



Hey, friends who are engaged in self-media or video editing. Haven't we all had these frustrating moments? After painstakingly compressing a video, the picture turns out to be as blurry as a mosaic, completely ruining the beauty. When hearing a wonderful background music, we itch to use it as the BGM of our own works or set it as a personalized ringtone, but we just can't find a way to extract it. And when we want to quickly clip a video segment, after using software to operate, what we get is a "defective product" with horrible picture quality. Don't worry. Today, I'm going to introduce you to a super powerful tool - FFmpeg, which will surely make these problems disappear!


FFmpeg, a name that sounds very technical, is actually much more approachable than you think. It's like an invisible video expert, ready to help you solve those seemingly complex problems at any time. And installing FFmpeg is as simple as it gets. If you're a Mac user and have Homebrew installed, you can easily get FFmpeg by typing a command in the terminal. Or Github to install it manually. If you're more accustomed to Windows, just download the installation package from FFmpeg's official website and add it to your environment variables, and you're good to go. FFmpeg supports multiple platforms, so whether you're a Mac, Windows, or Linux user, you can easily master it. Its help command is ‘ffmpeg -h’.


Now, let's unveil the mystery of FFmpeg and see how it uses three simple commands to solve the problems of video compression, audio extraction, and video trimming.


First, let's look at the command for compressing videos. Have you ever encountered the problem of video files being too large and wanting to compress them but worrying about the loss of picture quality? This FFmpeg command can help you compress while maintaining picture quality:


```

ffmpeg -i input.mp4 -c:v libx264 -r 25 -crf 21 -c:a aac output.mp4

```


Here, `-c:v libx264` specifies the video encoder as H264, `-r 25` sets the frame rate to 25, and `-crf 21` sets the bitrate, the smaller the value, the higher the quality. `-c:a aac` specifies the audio encoding as AAC. Yes, compression means resetting the audio format, video format, frame rate and bit rate.


Next, if you hear a piece of background music you like and want to extract it as a ringtone or notification sound, FFmpeg can easily help you achieve this:


```

ffmpeg -i input.mp4 -c:v libx264 -crf 21 -an output-v.mp4 -c:a aac -vn output-a.mp4

```


Here, `-an` is used to remove the audio, and `-vn` is to remove the video, allowing you to extract only the audio file(output-a.mp4).


Finally, if you need to trim a part of a video, FFmpeg can also help you do this while avoiding the blurriness caused by re-encoding:


```

ffmpeg -i input.mp4 -ss 00:00:01 -t 00:00:09 -c:v libx264 -crf 21 -c:a aac output.mp4

```


`-ss 00:00:01` means to start trimming from the 1st second of the video, and `-t 00:00:09` is to trim a 9-second video.


When you need to check if the video plays correctly, you can use the `ffplay output.mp4` command, and if you want to get information about the video or audio, `ffprobe output.mp4` is your good helper.


FFmpeg is such a simple and easy-to-use tool that not only helps you bid farewell to blurry and choppy videos but also allows you to go further on the road of video processing. So, dear friends, don't worry about video processing problems anymore, try FFmpeg, and let it become your good partner in video editing!