Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I need to find a way to playback a number of .dv4 files on Ubuntu 12.04 and Fedora 20, possibly after having converted them to a more conventional format. So far I have managed to convert the files with

mencoder -fps 25 ./input.dv4 -ovc copy -oac copy -o ./output.avi

which does a decent job, as does going the mplayer way:

mplayer -fps input.dv4

The problem I'm facing is that the output video in both cases has no timestamp characteristic of most CCTV videos, having which is crucial for my purposes. The question, then, is how to get that timestamp in the output file.

EDIT: I'm not, by the way, completely certain that I'm using the term "timestamp" correctly: what I mean is the date-and-time line, depicted in the running video, of the recorded event(s). I'm including a link to a sample file.

https://dl.dropboxusercontent.com/u/37327335/input.dv4

share|improve this question
2  
Do you have sample dv4 files for people that don't have them laying around to play with? Someone might give you an "I figured out how to do it" style answer if you did. –  hbdgaf Feb 17 '14 at 14:41
1  
Are you saying mencoder removed the timestamp? You might try ffmpeg instead, I know it can be built to support .avi and .dv, don't know about .dv4. –  goldilocks Feb 17 '14 at 15:02
    
@hbdgaf i'll see if that can be arranged. –  Pavel Rudnev Feb 17 '14 at 19:33
    
@goldilocks not sure this paraphrase is accurate (nor that it is inaccurate), the only observation being that when i use mencoder the output has no time code/stamp/whatever. in re of the ffmpeg option, i'm yet to get acquainted with how ffmpeg works. –  Pavel Rudnev Feb 17 '14 at 19:43
    
@hbdgaf link to a sample file added, as per your suggestion. –  Pavel Rudnev Feb 17 '14 at 20:21

1 Answer 1

I'm not sure you can use mencoder to annotate video in this manner.You could however use ffmpeg to do so. Assuming your version of ffmpeg supports "drawtext" you can add timestamps to your video like so.

Confirm drawtext is enabled:

$ ./ffmpeg -filters|& grep drawtext
 T.C drawtext         V->V       Draw text on top of video frames using libfreetype library.

Example #1 - using timecode

This will overlay the time using the timecode format specified, "00:00:00;00". The time will start at "09:57:00;00".

$ ffmpeg -i in.mp4 -vf                                                 \
"drawtext=fontfile=/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf:        \
timecode='09\:57\:00\;00': r=30:                                       \
x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1" \
-an -y out1.mp4

Will results in putting the overlaid timecode towards the bottom of the video, centered horizontally (X).

                             ss of sample timecode

Example #2 - date command

If you know when the video started you can manufacture timecodes by calculating the initial date using the date command. This will form the basetime.

$ newline=$'\r'
$ font="/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf"
$ ffmpeg -i in.mp4 -vf                                             \
   "drawtext=fontfile=$font:                                       \
    expansion=strftime:                                            \
    basetime=$(date +%s -d'2013-12-01 12:00:00')000000:            \
    text='$newline %H\\:%M\\:%S                                    \
    $newline':fontcolor=white:box=1:boxcolor=black,                \
    drawtext=fontfile=$font:text='$newline %{pts} $newline':       \
    y=2*th/3:box=1:fontcolor=white:boxcolor=black:" out2.mp4

                             ss #2

References

Filtering Guide FFmpeg Wiki

share|improve this answer
    
right. but doesn't this presuppose me knowing in advance what the actual timecode is? what i need to do is find a way of getting that same time code from the original .dv4 file –  Pavel Rudnev Feb 17 '14 at 15:49
    
Where is that timecode in the .dv4? –  slm Feb 17 '14 at 15:51
    
haven't the foggiest -- don't actually know where to even start looking. –  Pavel Rudnev Feb 17 '14 at 15:52
    
If you use mplayer to play a .dv4 does it include the timecodes within the video being played back? –  slm Feb 17 '14 at 15:54
    
do you mean the actual video or the console output? if the former, then no it doesn't. if the latter then i'm not sure. i've tried it with the -fps 25 option only. –  Pavel Rudnev Feb 17 '14 at 15:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.