How to Celebrate Your Code's Birthday
Categories: Creation
Recently XRender turned 3 years old. I had played with gource and ffmpeg before, thinking I could use these two libraries to play the journey of her open source as a story.
Recommended to watch in full screen with headphones. It feels like “watching the clouds clear and seeing the moon”. It feels like watching a movie and listening to a story for technical students.
Very simple, you can also try
- Preparation work, install gource and ffmpeg. The former is used for visualizing commit logs, and the latter is used for video processing. To make gource support Chinese fonts, Homebrew installation may be very slow. Try this acceleration address for domestic mirroring.
// Install
brew install gource
brew install ffmpeg
// Let gource support Chinese fonts
rm /usr/local/var/homebrew/linked/gource/share/gource/fonts/FreeSans.ttf
ln -s /System/Library/Fonts/Hiragino\ Sans\ GB.ttc /usr/local/var/homebrew/linked/gource/share/gource/fonts/FreeSans.ttf
- Find a git-managed project you like the most, enter the root directory of the local folder via command line, copy the following command and press Enter, and you can see the effect and generate the video.
gource \
--title "Title" \
--seconds-per-day 0.1 \
-1200x675 \
--high-dpi \
--multi-sampling \
--background-colour 000000 \
--dir-colour 62C454 \
--file-font-size 12 \
--font-size 24 \
--dir-font-size 14 \
--user-font-size 18 \
--auto-skip-seconds 0.2 \
--stop-at-end \
--highlight-users \
--highlight-dirs \
--file-extension-fallback \
--file-idle-time 0 \
--max-user-speed 200 \
--filename-time 2 \
--highlight-colour F5BE4F \
--date-format "%Y-%m-%d" \
--output-framerate 30 \
--output-ppm-stream - \
| ffmpeg -y -r 30 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -crf 1 -threads 0 -bf 0 movie.mp4
- Trendy videos need to be accompanied by a sensational background music, such as sound.mp3. Download it to the root directory of the project, and you can use avconv to add the audio track to the video to achieve the above effect.
ffmpeg -i movie.mp4 -i sound.mp3 -map 0 -map 1:a -c:v copy -shortest -vcodec libx264 -crf 24 output.mp4
- As long as it is managed by git, so not just open source projects, because it runs purely locally, your work code is also supported. You can try it.
```