FFmpeg adding timestamps to video-manually compiling FFmpeg

Source: Internet
Author: User
Tags drawtext

FFmpeg Video and timestamp watermark

The project needs to add a timestamp to the video, which is of course the best way to ffmpeg. Before finding the right approach, the answer timecode the Internet (water is not light, 2 days here), presumably this is written:

Ffmpeg-i wildlife.wmv-vf "drawtext=fontfile=arial.ttf:text= ' fuck ': timecode= ' 09\:57\:00\:00 ': r=25: \x= ( W-TW)/1.5:y=h-(20*LH): fontcolor=white:box=1: [email protected] "-an-y out.wmv

Turned a big circle, finally found the answer, in the ubuntu14.04lts below the use process:

#安装官方库提供的版本,2. Version of x sudoinstall"/input/input-video.mp4"" drawtext=expansion=strftime:  basetime=$ (Date +%s-d ' 2016-12-19 16:27:50 ') 000000:text= '%y-%m-%d%H\\:%M\\: %s ': Fontsize=11:fontcolor=white:box=1:x=10:y=10:[email protected]:" -strict-2"  /output/output-video.mp4"

which

-I: Specifies the input file, the video encoding used here is H264, the audio encoding is AAC

-VF: Video filter, using the DrawText filter, Basetime is the initial value of the video timestamp, text is the format of the display time, fontsize behind a string is about the watermark color, font, background and other settings

-STRICT-2:AAC decoding in the 2.x version is the experimental function, need to add this parameter

-y: Overwrite an already existing output file

The last paragraph is the output file

Here's the problem: source video parameter changes stuck ffmpeg process

This kind of peaceful use for a period of time, until one day found that the FFmpeg card on the server is not moving, CPU occupancy rate of more than 90%. Asked, the video recording client did change something, mainly video bitrate and screen size, audio parameters have not changed. First look at what caused the card to die, by adjusting some parameters of the method, to locate the audio is the result of the card (audio parameters have not moved, so can not explain why, only guess is the video changes affect the audio, anyway MP4 container inside the thing is not clear).

" /input/input-video.mp4 " " drawtext=expansion=strftime:  basetime=$ (Date +%s-d ' 2016-12-19 16:27:50 ') 000000:text= '%y-%m-%d%H\\:%M\\:% S ': Fontsize=11:fontcolor=white:box=1:x=10:y=10:[email protected]:""/output/ Output-video.mp4"

Unlike the original command,-strict-2 is replaced with-an, and-an indicates that the audio is not processed. This time the video can be properly processed (just no sound). The problem was found, and there was no solution to finding it.

No, upgrade the version, try it.

First went to the Ubuntu16.04 system to try, using the System repository version is 2.8, also have the same problem.

To look at the official website, the official website is 3.2. Decisive to find the version of the 3.2, in the official website to find the UBUNTU14 PPA version, according to their steps to install a try, error: Probably mean that DrawText filter does not exist, delete some parameters, found AAC decoder also did not. The general meaning is that some dependent libraries are not installed automatically. Look not to find how to pretend, do not know the specific dependencies of the library, give up.

No way, only try to manually compile.

#安装文档的步骤删了一些不要的库sudoapt-Get updatesudoApt-get-yInstallautoconf automake build-essential Libass-dev libfreetype6-Dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-Dev LIBXCB-xfixes0-devPkg-configTexinfo zlib1g-dev# to h264 the librarysudoApt-getInstalllibx264-dev# to AAC's librarysudoApt-getInstalllibfdk-aac-Dev#configure, compiling the destination path is too lazy to change, it is better to change, otherwise ffmpeg installed to the~/Bin directory under Path="$HOME/bin: $PATH"Pkg_config_path="$HOME/ffmpeg_build/lib/pkgconfig"./Configure--prefix="$HOME/ffmpeg_build"   --Pkg-config-flags="--static"   --extra-cflags="-i$home/ffmpeg_build/include"   --extra-ldflags="-l$home/ffmpeg_build/lib"   --bindir="$HOME/bin"   --enable-GPL--enable-Libass--enable-libfdk-AAC--enable-Libfreetype--enable-Libtheora--enable-Libvorbis--enable-libx264--enable-Nonfreepath="$HOME/bin: $PATH"  Make Make Install MakeDistclean

#更新一下profile, FFmpeg joins the path
SOURCE ~/.profile

Re-run the watermark command, FFmpeg again can work properly.

Full compilation process: Http://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu#CompilationInstallation

FFmpeg adding timestamps to video-manually compiling FFmpeg

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.