Re: [FFmpeg-user] Float formatting in drawtext (Stop watch)
With a little more research (and somewhat more knowledge about ffmpeg) I came to the following solution for a stopwatch with a defined decimal precision: * get the framerate via ffprobe and store it in a variable (i.e. !W!) * divide the frame number by this rate * display the result in two parts via text=%%{eif\\:n/!W!\\:d}"."%%{eif\\:n/!W!*100\\:d\\:2} NOTE: I am working under Windows, therefore somewhat exotic escaping in batch files. An offset could easily be accounted for by subtracting a user-provided integer from 'n'. Allowing for printf-style formatting of decimals in drawtext would still be easier ... The whole Windows batch code thus looks like: SETLOCAL EnableDelayedExpansion for /f "tokens=2 delims==/" %%i in ('C:\programme\ffmpeg\bin\ffprobe.exe -v error -of flat^=s^=_ -select_streams v:0 -show_entries stream^=r_frame_rate %1') do set W=%%~i c:\Programme\ffmpeg\bin\ffmpeg -i %1 -y -filter:v "drawtext=fontfile=/Windows/Fonts/arial.ttf:fontcolor=yellow:fontsize=42:text=%%{eif\\:n/!W!\\:d}"."%%{eif\\:n/!W!*100\\:d\\:2}:x=15:y=50" -q 8 -vcodec libxvid %~dpn1_sw%~x1 Wolfgang Hugemann ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Float formatting in drawtext
I have just had a look at the solution via subtitles: Pro: * It works and the SRT format is simple enough to be written by a script. Cons: * SRT subtitles are written time-based and not frame-based, which takes some calculations, starting the subtitles shortly before the frame and ending it within the frame. * This does not seem to work at the start of the video (frames 1, 2). * I seem to have no influence on where the subtitle is placed. It appears at the middle of the bottom. ... The drawtext filter has an option to read text from a file, but I guess this cannot easily be used to read lines on a per-frame basis (?). Wolfgang Hugemann ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Float formatting in drawtext
On Fri, Jan 27, 2017 at 11:05:04 +0100, Wolfgang Hugemann wrote: > So possibly there is another way to acchieve this? Could I for example > store a string in a user-defined frame-wise variable and display its > value by drawtext as is done when deciphering the VITC: I didn't take much of a look at your original issue, but: You could create a subtitle file, even with formatting/styling. The subtitle formats are trivial enough to create them manually or in a scripted manner. Then you would burn the subtitle (from the separate file) onto the video, as described here: https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo You would want look at SRT format first, but go for something like ASS if you want fancier formatting. You suggestion of metadata might also work, by inserting custom metadata with the metadata demuxer: https://www.ffmpeg.org/ffmpeg-formats.html#Metadata-1 Cheers, Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Float formatting in drawtext
OK, maybe I put my question the wrong way: I would like to display a stop watch starting at an arbitrary time in the video (usually the collision of two cars for accident reconstruction purposes). This can obviously be done via drawtext and pts, but the result looks nasty, and I seem to have no control on the formatting of the string displayed. So possibly there is another way to acchieve this? Could I for example store a string in a user-defined frame-wise variable and display its value by drawtext as is done when deciphering the VITC: ffmpeg -i sample-vitc.avi -filter:v "readvitc,drawtext=fontfile=FreeMono.ttf:fontcolor=white:text=%{metadata\\:lavfi.readvitc.tc_str}:x=(w-tw)/2:y=400-ascent" -f avi -codec:v huffyuv test.avi (Code by Tobias Rapp) Any help would be appreciated. Wolfgang Hugemann Am 23.01.2017 um 16:13 schrieb Wolfgang Hugemann: Hey, seems to be an easy question, but I have been searching for the answer quite a while without success: If I perform a float calculation via text=%{expr\:whatever} is there any way to format the output the printf way? I know, the result could be converted to integer and be formatted via text=%{eif\:whatever\:d} but this is restricted to integer results. Wolfgang Hugemann ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-user] Float formatting in drawtext
Hey, seems to be an easy question, but I have been searching for the answer quite a while without success: If I perform a float calculation via text=%{expr\:whatever} is there any way to format the output the printf way? I know, the result could be converted to integer and be formatted via text=%{eif\:whatever\:d} but this is restricted to integer results. Wolfgang Hugemann ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".