ffmpeg 加动态时间水印

    技术2022-07-12  74

        sprintf(lpCmdLine, "%s -i %s -f lavfi -i testsrc=duration=5:size=800x600:rate=30 -vf drawtext=\"fontfile=C\\\:/Windows/Fonts/arial.ttf:text='%%{pts\\:gmtime\\:%lld\\:%%Y-%%m-%%d\\ %%H\\\\\\:%%M\\\\\\:%%S\\\}':x=50:y=50:fontsize=24:fontcolor=white:shadowy=2\""  " -preset ultrafast -vcodec libx264 -acodec copy  -f mp4 %s ",

    szFFmpegPath, szInputPath, (long long)timet, szOutputPath);

        cout << lpCmdLine << endl;

     

    1> timet 时间转完豪秒的. 注意 utc时间与local 时间差了8个时区.

     输入视频起始时间,  转了下毫秒,

    2> ttf 可能找不到。就换个找到的.

    3> 注意转义字符...   多加\\\\\\ 试一试  

    Processed: 0.014, SQL: 9