Video ffmpeg,带有-i concat filelist.txt中不同文件的drawtext文件名

Video ffmpeg,带有-i concat filelist.txt中不同文件的drawtext文件名,video,ffmpeg,drawtext,Video,Ffmpeg,Drawtext,使用下面的脚本,我能够将文本文件中的多个视频文件连接到单个视频 现在我想在输出视频中显示每个源视频文件的单独名称 下面是我的源videoList.txt文件的一个示例,其中包含文件名和文件路径 # videoList.txt file 'C:\video_0020.mp4' file 'C:\video_0040.mp4' file '..' 和windows批处理文件: @ECHO off SETLOCAL SET ffmpeg=C:\ffmpeg\bin SET inFile=-f

使用下面的脚本,我能够将文本文件中的多个视频文件连接到单个视频

现在我想在输出视频中显示每个源视频文件的单独名称

下面是我的源videoList.txt文件的一个示例,其中包含文件名和文件路径

# videoList.txt
file 'C:\video_0020.mp4' 
file 'C:\video_0040.mp4' 
file '..'
和windows批处理文件:

@ECHO off
SETLOCAL

SET ffmpeg=C:\ffmpeg\bin
SET inFile=-f concat -i C:\videoList.txt
SET outFile=C:\output.mov

SET codec=-r 24 -vcodec mjpeg -q:v 6
REM videoFilter/filterComplex
SET filterComplex=drawtext=fontfile='C\:\\Windows\\Fonts\\arial.ttf': text='%%{filenameOfEachVideo}'

REM bring it all together
SET commandline=%ffmpeg%\ffmpeg.exe %inFile% -filter_complex "%filterComplex%" %codec% %outFile%

REM execute command
%commandline%

下面是一个工作示例。使用前请检查路径和文件扩展名。 我添加了很多注释,以使脚本的功能更加清晰。请随意使用和修改

@ECHO off
SETLOCAL
SETLOCAL EnableDelayedExpansion

REM path to ffmpeg
SET ffmpeg=C:\path\to\ffmpeg\bin
REM source movies from
SET movieSource=C:\path\to\your\mp4\movies
REM tmp dir
SET tmpDir=C:\path\for\tmp\files\and\final\output


REM setup positon, color, background, font for the text overlays
REM filterComplex, quotes have to be escaped! -> \"
REM BITC - Burned In Time Code
SET filterComplexTimecode=drawtext=fontfile='C\:\\Windows\\Fonts\\arial.ttf': timecode='10\:00\:00\:00': timecode_rate=24: x=(w-tw)/2: y=h-(1*lh)-3: fontsize=20: fontcolor=white@0.4: box=1: boxcolor=0x00000000@0.4: boxborderw=4
REM Date
SET filterComplexDate=drawtext=fontfile='C\:\\Windows\\Fonts\\arial.ttf': text='%%{localtime\: %%d.%%m.%%Y %%H\\\:%%M}': x=(w-tw-3): y=h-(1*lh)-3: fontsize=20: fontcolor=white@0.4: box=1: boxcolor=0x00000000@0.4: boxborderw=4
REM Shotname
SET filterComplexShotname=drawtext=fontfile='C\:\\Windows\\Fonts\\arial.ttf': x=0: y=h-(1*lh)+1: fontsize=20: fontcolor=white@0.4: box=1: boxcolor=0x00000000@0.4: boxborderw=4:



REM create a list of all files
FOR /F "tokens=*" %%F IN ('dir %movieSource%\*.mp4 /b  ^| sort') DO ECHO file '%movieSource%\%%F' >> %tmpDir%\filelist.txt

REM gather more informations for each file
ECHO ; filename, durationInSeconds > %tmpDir%\fileNameDuration.txt

FOR /R %movieSource%\ %%F IN (*.mp4) DO (
  REM Reset current duration to 0 (zero) for each loop
  SET curDuration=0

  REM get the filename without file extenion
  SET fileName=%%~nF

  REM get the duration of a single clip
  REM and write it to a tmp textfile
  %ffmpeg%\ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 %%~fF > %tmpDir%\fileTempDuration.txt
  REM read the textfile again into a variable
  SET /p curDuration=<%tmpDir%\fileTempDuration.txt

  REM write the filename and the duration to a new list of all files
  ECHO !fileName!,!curDuration! >> %tmpDir%\fileNameDuration.txt
)

REM concate a filter complex string for ffmpeg with all clipnames as textlayer with a inpoint and outpoint
SET filterComplexShotnameCombined=
REM floating numbers are not supported by batch, so we need to work-around that
CALL :IntAsFP b=0.000000
FOR /F "eol=; tokens=1,2* delims=," %%i IN (%tmpDir%\fileNameDuration.txt) DO (
  CALL :IntAsFP a=%%j
  CALL :IntToFP inPoint=!b! 6
  SET /A c=a+b
  SET /A b=c
  CALL :IntToFP outPoint=!c! 6
  REM just to check whats going on...
  ECHO name: %%i   duration: %%j   inPoint: !inPoint!   outPoint: !outPoint!
  SET filterComplexShotnameCombined=!filterComplexShotnameCombined!, !filterComplexShotname! text=%%i: enable=between(t\,!inPoint!\,!outPoint!^^^)
)

REM bringing all together. filter complex for current date, one for the normal timecode, and the actual shotnames.
SET filterComplexCombined=-filter_complex "%filterComplexDate%, %filterComplexTimecode% %filterComplexShotnameCombined%"

REM just to check...
ECHO %filterComplexCombined%
%ffmpeg%\ffmpeg.exe %async% -f concat -i %tmpDir%\filelist.txt %filterComplexCombined% %fps% %codec% %loglevel% %tmpDir%\output.mov


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

REM Integer to FloatingPoint

:IntAsFP Int=FP
set FP=%2
set %1=%FP:.=%
exit /B


:IntToFP FP=Int digits
set Int=%2
set %1=!Int:~0,-%3!.!Int:~-%3!
exit /B

你想将其编码到视频中,还是SoftSub就足够了?我想将文件名烧录到视频中。