directory
preface
The body of the
party 1
Pay for your girlfriend’s blow
party 2
The tiktok effects aren’t enough. Add them yourself
party 3
Get your girlfriend to break wechat’s limits
The last
preface
Really! Programmers also have their own romance 🌹.
The body of the
Often hear female students and female colleagues complain, said the program ape does not understand romance, as if we program ape also slowly accepted such a label. In fact, as long as we have a thinking heart, we can create the romance of our programming ape. This kind of romance does not have to be amazing, do not have to be vigorous, but it is real, meticulous. So what can we programmers do for our girlfriends or girls? Here are a few of my personal stories to introduce you. Don’t spray if you don’t like it!
party 1
Pay for your girlfriend’s blow
Once, girlfriend and bestie boast, said that he often exercise recently, jump rope per minute can jump 200 (just heard, I first instinct of a surprise, then want to stop, but not enough to hold). For this kind of sport level, bestie certainly does not believe, so two people began to bet, bet is a big meal. (At that time, I felt that this meal is booked.)
We all know about rope skipping, which is the following:
​
Her best friend asked her to take a video on her phone and send it to her (thankfully it wasn’t live, giving me room to cheat). Now that we’ve said we’re going to send video, we’re going to have to fiddle with the phone video.
First, copy the video shot in the phone and put it on the computer, and take out our audio and video artifact — FFmpeg.
Now, what we do is we cheat — we speed up the video.
For details, please refer to the following (Golang) code.
func (e *Encoder) getVideoHandle(input, output string) (string, *exec.Cmd) { if input == "" || output == ""{ return "parameters is wrong", nil } arg := []string{ e.config.FFMPEG, "V", "16" and "-i", input "- filter_complex", ", '[0: v] setpts = 0.5 * PTS [v]; [0: a] atempo = 2.0 [a] '", "- the map", "[v]", "- the map", "[a]",} arg = append (arg, the output) return strings. Join (arg, ""), exec.Command(arg[0], arg[1:]...) }Copy the code
Before introducing the purpose of the above code, I will give people who have no experience of audio and video popularization. Generally, a video file contains two parts of media data: video and audio. Logically, the two parts are separated, and only the audio and video synchronization logic is performed when the video is played. The synchronization process relies mainly on the time reference clock, which I won’t expand here, but that’s all I need to know.
The effect of this procedure is to double the speed of both the video and the audio, so that the rope skipping results can be easily achieved.
After all, you can’t adjust the speed too much, just over 200 per minute.
But in previewing the video, I found an obvious flaw in the video. The background sound, the chirping of cicadas, had also been speeded up (it was summer), making it sound very suspicious.
So, I needed to speed up the video but not the audio, so I changed the code:
func (e *Encoder) getVideoHandle(input, output string) (string, *exec.Cmd) { if input == "" || output == ""{ return "parameters is wrong", nil } arg := []string{ e.config.FFMPEG, "V", "16" and "-i", input, "- filter_complex", "[0: v] setpts = 0.5 * PTS [v]", "- the map", "[v],"} arg = append (arg, output) return strings.Join(arg, " "), exec.Command(arg[0], arg[1:]...) }Copy the code
Run the program, generate the target video, and there you go! Because the girlfriend itself is also very fast, the video screen is accelerated, with the summer cicada sound, no flaw, secretly happy…
After the girlfriend saw the finished product, a face confused, good real ah, a burst of guffaw… Then gave me a big hug and incense 🔞.
In the end, my girlfriend was the executive producer, and I was officially finished for post-production.
After the video was sent to her bestie, her bestie was very surprised, and praised her without heart, and regretted that she invited the dinner next time, and was convinced.
party 2
The tiktok effects aren’t enough. Add them yourself
It is not supported to add other special effects separately in the earlier function of douyin (recently I haven’t played it for a while, I spent all my time on masturbating). It is not clear whether it is supported now.
​
The picture above is the finished product effect, she is saying: big thick neck!!
This is a special effects video of her taking a selfie on the plane the last time she took her daughter to Macau. She had two complaints about the original video:
First, because she chose to shoot the same style, she could not edit other special effects, which made her depressed. She originally wanted to add a rotating special effect.
Second, when taking a selfie, I didn’t notice that the airplane aisle was messy and wanted to cover it up.
In order to meet these two requirements, I decided to write a program to solve both problems.
To solve the first problem, the video rotation effect, for FFmpeg, is not easy. This video is about six seconds long, so we’re going to do one rotation here, or we can do two or more.
But in that case, the picture changes too quickly and affects the viewing effect.
All right, without further ado, let’s go. Look at the code:
func (e *Encoder) getVideoHandle(input, output string) (string, *exec.Cmd) {
if input == "" || output == ""{
return "parameters is wrong", nil
}
arg := []string{
e.config.FFMPEG,
"-v", "16",
"-i", input,
"-vf", "rotate=PI*2/5*t",
}
arg = append(arg, output)
return strings.Join(arg, " "), exec.Command(arg[0], arg[1:]...)
}
Copy the code
Done! The effect is shown in the image above.
All right, let’s move on to problem number two — blocking the aisle. In order to show my formal and rigorous attitude (however, the effect is not rigorous), I decided to use my CSDN account profile picture as the texture to cover the corridor, so cute profile picture, who does not love?
Calculate the position, control the size of the map, go, look at the code:
func (e *Encoder) getVideoHandle(input, output string) (string, *exec.Cmd) { if input == "" || output == ""{ return "parameters is wrong", nil } arg := []string{ e.config.FFMPEG, "-v", "16", "-i", input, "-b:v", "600k", "-vf", "movie=touxiang.jpg[watermark]; [in][watermark]overlay=5:190", } arg = append(arg, output) return strings.Join(arg, " "), exec.Command(arg[0], arg[1:]...) }Copy the code
party 3
Get your girlfriend to break wechat’s limits
As you all know, wechat has a maximum size of 100MB when sending files. A new movie came out in front of time, she wanted to send the movie to her friend, said let me help, see if there is a way, because the other side wants to use wechat to see.
So, I thought of a method: this movie a total of more than 900 megabytes, the movie will be cut into about 10 sub-clips, and then sent out separately can’t it?
So let’s get started. First, use the tool Mediainfo to check the video bit rate and total duration of the movie, which is 115 minutes, so cut it to a 20-minute clip.
Code to go:
func (e *Encoder) getVideoHandle(input, output string) (string, *exec.Cmd) {
if input == "" || output == ""{
return "parameters is wrong", nil
}
arg := []string{
e.config.FFMPEG,
"-v", "16",
"-i", input,
"-c", "copy",
"-map", "0",
"-segment_time", "00:20:00",
"-f", "segment"
}
arg = append(arg, output)
return strings.Join(arg, " "), exec.Command(arg[0], arg[1:]...)
}
Copy the code
Let’s see how it works:
​
Good, this time successfully completed the task assigned by the girlfriend. Reward or little, hey hey.
The last
Read a few small stories above, is not to some extent inspired you. Do you want to do something with your current technology? Let’s do it! Because I am engaged in audio and video related work, very familiar with FFmpeg, so it is handy to use it. We can also rely on their own technical advantages, clever application of their own work and life. Finally, I wish no girlfriend of partners as soon as possible in hand success (showoff skills must be indispensable, otherwise how to attract the family girl), have a girlfriend or married partners, happy life, healthy. Come on, everyone, in 2021!