Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am generating a bunch of jpgs from a movie, and want the watermark to be applied to all the jpgs. This works fine for all frames, but the first one, and I cannot figure out why.

This is the command I use

ffmpeg -vframes 16 -ss 00:00:01 -i a.mov -t 00:00:17 -r 1 -s 1280x720 -vf "movie=watermark.png,scale=1280:720 [wm];[in][wm] overlay=0:0 [out]" '/tmp/output%d.jpg'

which will give me these files:

output1.jpg
output2.jpg
output3.jpg
output4.jpg
output5.jpg
output6.jpg
output7.jpg
output8.jpg
output9.jpg
output10.jpg

where they all BUT output1.jpg has got watermark applied.

I cannot figure out why ffmpeg does not apply the watermark on the first one.

I am using ffmpeg 1.2 on debian

share|improve this question
    
Unrelated: You can add -i watermark.png and eliminate the movie multimedia source filter if you use -filter_complex instead of -vf. –  LordNeckbeard Jul 3 '13 at 21:30
add comment

1 Answer

up vote 2 down vote accepted

If you use -ss before -i, it will seek to a keyframe. This is quick, but if there is not a keyframe at the specified time then it is not frame-accurate and you may end up with some frames before the seek time, which will effectively have negative timestamps. Since your watermark movie overlay starts at time 0, the frames with negative timestamps will not have a watermark.

If you move the -ss option after the input file, this is slower because it must process and discard all of the frames up to that point, but it will seek to the precise timestamp that you specify and not leave you with frames before the specified time.

Another option is to stick to the fast keyframe-based seeking and then use the select filter to eliminate any undesired frames. For example:

ffmpeg -ss 00:00:01 -i a.mov -t 00:00:17 -r 1 -s 1280x720 -vf "[in] select=gte(t\,0) [sel];movie=watermark.png,scale=1280:720 [wm];[sel][wm] overlay=0:0 [out]" '/tmp/output%d.jpg'
share|improve this answer
    
ah, very interesting! One question "Since your watermark movie overlay starts at time 0" is it possible to tell ffpmeg to take all, also the negative timestamps? –  JohnSmith Jul 3 '13 at 22:50
    
@JohnSmith: In general, movie= provides multiple frames. It has to start at some time. You could use the setpts filter to shift the movie= to start earlier, if you knew how much to shift. But removing the negative portions with select is better since the start frame will then be closer to what was requested. –  mark4o Jul 4 '13 at 6:42
    
thanks for clarifying! –  JohnSmith Jul 4 '13 at 15:01
add comment

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.