Hello. this is my first post. Can you guys help me?. I am trying to insert a time stamp below the screen capture of a video using ffmpeg. I was only able to produce a screenshot at an specified time using vframes example from their documentation page using the code below
However I dont know how to add that '00:00:14.435' time which was specified with the seek command in a black box positioned below the screencapture. I need the fontface to be arial and yellow color. I've also tried other examples like the one using this code:Code:ffmpeg -i input.flv -ss 00:00:14.435 -vframes 1 out.png
but the problem with that approach it is that it generates a sequence of images (which also lack the timecode in a black frame) and not a desired time. Can this procedure be done using ffmpeg?.Code:ffmpeg -i input -vf "drawtext=fontfile=/usr/share/fonts/TTF/Vera.ttf: timecode='00\:00\:00\:00': r=25: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" image%03d.pn
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 12 of 12
Thread
-
-
Is what you want , a black, 640x60 area under a 640x480 screen capture, with time in yellow arial letters? Or do you want the black area posted over ther bottom of te screen capture so the pictue remains the same 640x480 size.
I just used 640 x 480 as a possible but any size can be substituted in the questions. -
What i'm trying to do is to reproduce something like this picture.
In similar fashion to that of a contact print. I am not trying to create one, what i need is to make just a single capture but with the time that i specified at the input. In other words to tell ffmpeg to find that 00:00:04:04 (as in the example or any other desired time) and label it like the picture such the output be yellowcolor fontface instead of white as in the picture and that the fontface to be courier new. -
combine both your lines; ie. add both -vf drawtext and -ss
%03d is sprintif notation and will give an image sequence. Use -vframes 1 and don't use the "%" notation in the output filename
eg. arial, yellow
Code:ffmpeg -i input.ext -vf "drawtext=fontfile=arial.ttf:fontsize=28:fontcolor=yellow:box=1:boxcolor=0x000000CC:x=(w-tw)/2:y=h-(2*lh):timecode='00\:00\:00\:00:rate=30'" -c:v png -ss 00:00:14.435 -vframes 1 -an output.png
Note the drawtext notation is hours:minec:frames ; not ms , but your seek notation is in ms. -
If you already have the Image , an alternate method is:
Code:ffmpeg -i C:\PathToVideo\Video.jpg -vf "drawtext=fontfile=c:\windows\fonts\arial.ttf:text='00\:00\:14,140':fontsize=30:fontcolor=yellow:box=1:boxcolor=black@0.7:x=232: y=400" C:\PathToVideo\000Video.jpg
Bear in mind, Timecode useage results in SMPTE time with a format of HH:MM:SS:frame, so the 14:12 is the 12th frame of the 14th second. Using poisondeathray excellent script gives the following image:
This corresponds exactly with the First 'B' Frame after 14:435 (14:400)
Last edited by Budman1; 31st May 2017 at 23:42. Reason: Clarification
-
I followed the code that you posted with some minor modifications as requested in the initial question, however as you mentioned the result i got is not exactly what i expected as there is an offset between the time that is used with the seek command and the one which appears in the box.
How do I know what is the framerate of my video with ffmpeg?. In your code i see you use CC at the end of the zeros for the black colour (boxcolor=0x000000CC). Is this setting for transparency?, overall how do i get accuracy in the resulting screenshot? -
You can use ffmpeg -i input.ext and read the console, that will tell you what ffmpeg "thinks" the framerate is. It might be correct, or not
In your code i see you use CC at the end of the zeros for the black colour (boxcolor=0x000000CC). Is this setting for transparency?,
eg. boxcolor=0x000000@0.25 would be 25% opaque, 75% transparent
overall how do i get accuracy in the resulting screenshot?
Seeking is not necessarily frame accurate in ffmpeg . It's worse with some filetypes and compressions. It's usually worse with long gop compression and large gop intervals
The timebase might not allow for your selected seekpoint representation . For example if a certain video had 29.97 framerate, each frame only 0.03336 s accuracy. You wouldn't be able to get a "0.5" represented
There can be "jitter" in time base and rounding issues resulting in differences. For example "29.97" is really rounded from 30000/1001, and some containers have a different timebase
flv is often variable frame rate , this adds an additional layer of complexity because the presentation timestamps might be slightly off -
If i may add to poisondeathrays descriptive explaination. The cc when used as the 4th byte of the color (after 0x) is used as the alpha or transparencg setting, 0-255. Cc in hexadecimal=204 in decimal or almost opaque (255). If you use only 3 bytes instead of 4 then you should use poisondeathrays method.
The only safe way of knowing the correct time or nearly correct time in hh:mms.ms, is to play the video with the time frame displayed ( above with avisynth "showtime" ) extract your image and then place the correct time as in the the image of my niece violin previously. This would also help if your movie is in VFR variable frame rate mentioned earlier but may still not be exact.
Having explained how the time may be off due to many reasons, If you want to extract an image with the Frame time instead of Timecode, you can use the following script. It is a little overkill but it contains everything you might want to change.
Code:"c:\PathToFFmpeg\ffmpeg" -ss 00:00:02.293 -i "C:\PathToVideo\004 NO subs.mp4" -vf drawtext=fontfile=Lucida.ttf:fontsize=30:fontcolor=white:box=1:boxcolor=black:x=(W-tw)/2:y=H-th-10:text=%{'pts\:hms'} -vframes 1 -s 640:264 -vsync vfr out%02d.jpg
Notice the time is off but by 20 seconds it is back in sync. That is as close as I know how to get 'Frame Time' embedded in an extracted image. The other methods work great for 'Timecode' also. You will have to decide which is best for you.Last edited by Budman1; 2nd Jun 2017 at 01:46.
-
Here's what I did, I used ffprobe command from ffmpeg
Code:ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1 "kbs_u20_extras.mp4"
This was for the -ss 00:00:14.435 as requested.
So, from what i understand seeking is not too precise. I have also found that it takes sometime until ffmpeg find the specified time but from their documentation ss is faster than other methods.
By the way, is it possible to modify the code so i do not have to use the command as many times for each frame i want?. In other words to expand it to be like this:
Code:ffmpeg -i video1.mp4 -vf "drawtext=fontfile=/windows/fonts/courbd.ttf:fontsize=80:fontcolor=yellow:box =1:boxcolor=black:x=(w-tw)/2:y=h-(2*lh):timecode='00\:00\:00\:00:rate=140970000/5875441'"-c:v png -ss 00:0:00.435, 00:00:50.000, 00:01:20.000 -vframes 1 -an image1.jpg, image2.jpg, image3.jpg
-
I don't think it's possible with ffmpeg, each instance will require "re-seeking" and take a long time. It doesn't start from where it left off
Another option mentioned earlier is avisynth . It is possible to get more accurate times , even from VFR sources, by converting to CFR. A GUI of sorts is avspmod and you "see" the preview , and can drag the slider and find the time without the delay or having extra time to re-seek from the beginning. You have to option to show STMPE time (hh:mms:frames) or ms time (hh:mms.ms). You can take screenshots directly from avspmod. That's the way I would do it -
Thanks i had a hunch that it was related to the transparency. In my example i replaced the hex values by the word 'black' however i will try doing so with FF if i am correct.
I have vlc i am not sure if it has the same capabilities of avisynth but ill look into that. For the rest of what you mentioned it might be too long or some problematic to find as the code will result into a long list of captured images, however i acknowledge that's another option but too much to process. -
For the rest of what you mentioned it might be too long or some problematic to find as the code will result into a long list of captured images,
Similar Threads
-
Change Time Stamp on .mp4 video
By threehappypenguins in forum Newbie / General discussionsReplies: 51Last Post: 24th Apr 2021, 19:05 -
“ No NVENC capable devices found” with ffmpeg for screen capture and RTP
By ThadeuMelo in forum CapturingReplies: 1Last Post: 22nd May 2017, 18:43 -
Yahoo Screen -> ffmpeg garbled video
By nikkar in forum Video Streaming DownloadingReplies: 2Last Post: 24th Jul 2015, 07:48 -
Capturing video with date and time stamp from Sony Handycam - Please Help!
By DaftCrunk in forum CapturingReplies: 5Last Post: 1st Mar 2015, 02:04 -
date/time stamp on AVCHD possible?
By Mike82 in forum Camcorders (DV/HDV/AVCHD/HD)Replies: 26Last Post: 17th Aug 2014, 18:26