timecode option for drawtext not working as expected.
Describe the bug Attempting to use the 'timecode' or 'timestamp' option of the drawtext filter does not seem to work. ffmpeg WASM indicates the following errors:
[fferr] [drawtext @ 0x32c7540] Invalid 0xRRGGBB[AA] color string: '07'
[fferr] [drawtext @ 0x32c7540] Unable to parse option value "07" as color
[fferr] [Parsed_drawtext_0 @ 0x1a6e7c0] Both text and text file provided. Please provide only one
[fferr] [AVFilterGraph @ 0x32c9440] Error initializing filter 'drawtext' with args 'timecode=17:02:25:07:fontfile=font.ttf:r=24000/1001:fontcolor=white:fontsize=36:x=(w-tw)/2:y=h/2-18'
It does not like the "drawtext=timecode=17:02:25:07" as input for the filter. Note that is seems to be interpreting the 'frames' position of ":07" as a color (??). I suspect there's some issue with parsing the drawfilter argument that relates to the colons not being handled correctly
I have tried passing all of the following:
timecode='17\:02\:25\:07'
timecode=17\:02\:25\:07
timecode=\"17\:02\:25\:07\"
timecode='17:02:25:07'
timecode=17:02:25:07
timecode=\"17:02:25:07\"
Without any luck. On the command line, escaping the Colons is required, so I assume it is necessary on the WASM as well. All variants give the same error above.
if I change it to:
drawtext=timecode='0':
instead, I get:
[fferr] [Parsed_drawtext_0 @ 0x3335c80] Unable to parse timecode, syntax: hh:mm:ss[:;.]ff
instead of the error above.
If I modify the input timecode string to timecode='17\:02\:25\;07' I no longer get the invalid color string error, but I still get the Both text and text file provided. Please provide only one error. Removing the trailing ";07" entirely also give the Both Provided error.
To me it appears there might be two bugs that are related. One for parsing the Frames with Colon option and another related to the WASM seeming to think both 'text' and a 'text file' are being passed to the timecode filter.
To Reproduce
// font.ttf, test.mp3 and background.png are correctly loaded into the ffmpeg FS at time of run.
await ffmpeg.run(
'-loop', '1',
'-r', '24000/1001',
'-i', 'background.png',
'-i', 'test.mp3',
'-vf',
"drawtext=timecode='17\:02\:25\:07':fontfile=font.ttf:r=24000/1001:fontcolor=white:fontsize=36:x=(w-tw)/2:y=h/2-18," +
"drawtext=text='23.976 fps':fontfile=font.ttf:r=24000/1001:fontcolor=white:fontsize=20:x=(w-tw)/2:y=h/2+20,format=yuv420p",
'-r', '24000/1001',
'-b:v', '150000',
'-c:v', 'libx264',
'-c:a', 'aac',
'-b:a', '128k',
'-shortest', 'out.mp4');
Expected behavior I would expect the timecode to be burned onto the PNG background file and run continuously throughout rendered file. The same command run on the ffmpeg cli works correctly.
If I remove the 'timecode' filter and run only the static drawtext=text filter, it works as expected.
Screenshots Successful render from cli look like this and what I would expect from the timecode filter:
If I run just the static 'drawtext=text='23.976_fps' filter without the timecode filter, the WASM renders the file as follows (which is expected, but without the desired timecode).
Desktop (please complete the following information):
- OS: Mac OS Catalina for Dev Machine
- Browser: Chrome v103
Additional context Using React 17.x and
"@ffmpeg/core": "^0.10.0",
"@ffmpeg/ffmpeg": "^0.10.1",
On the CLI I can run the equivalent and it works:
ffmpeg -loop 1 -r 24000/1001 -i 'background.png' -i 'test.mp3' -vf "drawtext=timecode='17\:02\:25\:00' :fontfile=font.ttf:r=24000/1001:fontcolor=white:fontsize=36:x=(w-tw)/2:y=h/2-18:box=1: [email protected]:boxborderw=4,drawtext=text='23.976 fps':fontfile=font.ttf:r=24000/1001:fontcolor=white:fontsize=20:x=(w-tw)/2:y=h/2+20, format=yuv420p" -r 24000/1001 -b:v 150000 -c:v libx264 -c:a aac -b:a 128k -shortest out_bwf.mp4