Page 2 of 2

Re: Is there an easy way to add text to an mp4 video

Posted: Mon Jan 13, 2014 8:36 pm
by IdeasVacuum

Re: Is there an easy way to add text to an mp4 video

Posted: Mon Jan 13, 2014 9:35 pm
by JHPJHP
Hi IdeasVacuum,

Seems like a great tool, but I don't think it can help in this case... here is some additional information:
- please let me know if I missed something
If you'd like to be able to whip up short videos and post them online but don't quite know where to start, Blueberry's BB FlashBack Express might be the tool for you. It records your screen activity, with sound, and posts finished videos to YouTube and other sites. BB FlashBack Express lets you create instructional videos that record every onscreen step, or narrate a slideshow or series of clips to create your own documentaries and short films.
- Express is free and enables you to record the screen, sound, webcam, share movies online or save them as Flash and AVI files.
- Standard edition adds annotation and WMV, QuickTime exporting
- Professional edition adds powerful audio and video editing, EXE export and effects like zoom and pan.

BB FlashBack Professional Edition: Single licence $199
BB FlashBack Standard Edition: Single licence $89

Re: Is there an easy way to add text to an mp4 video

Posted: Mon Jan 13, 2014 10:04 pm
by normeus
Thanks IdeasVacuum,
Will not work in my case but it looks like a good tool to record all stuff that happens on my screen.


Going back to OpenCV:

when I use "#CV_FOURCC_PROMPT" I am able to choose the right codec and when I use a HEX editor to look at the signature of the AVI file

it shows as "MJPG"

I've tried using CV_FOURCC("F", "F", "V", "1") and also CV_FOURCC("M", "J", "P", "G") but all get is an empty file, is there a way to find out the codec number once it has been picked using "#CV_FOURCC_PROMPT"?

Re: Is there an easy way to add text to an mp4 video

Posted: Mon Jan 13, 2014 10:16 pm
by JHPJHP
Hi normeus,

You can use the following function after calling cvCreateVideoWriter with #CV_FOURCC_PROMPT (-1):
- Debug cvGetCaptureProperty(*capture, #CV_CAP_PROP_FOURCC)
-- #CV_CAP_PROP_FOURCC = 6

Cheers!

Re: Is there an easy way to add text to an mp4 video

Posted: Tue Jan 14, 2014 7:50 am
by normeus
using the following code after a cvCreateVideoWriter

Code: Select all

Debug cvGetCaptureProperty(*capture, #CV_CAP_PROP_FOURCC)
I always get "828601953.0" it does not matter what codec I choose.

let me know if anyone gets a different result.

Re: Is there an easy way to add text to an mp4 video

Posted: Tue Jan 14, 2014 11:42 pm
by JHPJHP
I won't bore you with the number of different things I've tried over the last 4 hours, but you are correct - cvGetCaptureProperty(*capture, #CV_CAP_PROP_FOURCC) is not working as it should.
- http://www.purebasic.fr/english/viewtop ... 86#p434986

On the bright side I did figure out an issue with the syntax for cvCreateVideoWriter, which should help with your current problem.
- you shouldn't need any additional codecs, and can probably remove ffdshow
- size of the new avi file (with text) should be very close to the size of the original file

Code: Select all

cvCreateVideoWriter(filename.p-ascii, fourcc, fps.d, width, height, is_color)

fps.d = cvGetCaptureProperty(*capture, #CV_CAP_PROP_FPS)
FrameWidth = cvGetCaptureProperty(*capture, #CV_CAP_PROP_FRAME_WIDTH)
FrameHeight = cvGetCaptureProperty(*capture, #CV_CAP_PROP_FRAME_HEIGHT)
*writer = cvCreateVideoWriter(sVideo, CV_FOURCC("D", "I", "V", "X"), fps, FrameWidth, FrameHeight, #True)

Re: Is there an easy way to add text to an mp4 video

Posted: Wed Jan 15, 2014 1:49 am
by normeus
Thank you JHPJHP,
( I spent a few hours myself trying to see where that magic number came from )
to findout the code of the codec I endded up using a program from fourcc.org
http://www.fourcc.org/identifier/
download AVIcodec which will give you the four letter code for the codecs installed on your computer


CV_FOURCC("D", "I", "V", "X")

will only work if you have DIVX installed. which I did and the file is almost the same size as the original files.

the divx I downloaded came from:
http://www.fourcc.org/downloads/divx-912-7/

now to fight "cross dissolve" from file to file, I know it should be an xor of some kind ..

Norm.

Re: Is there an easy way to add text to an mp4 video

Posted: Wed Jan 15, 2014 4:09 am
by JHPJHP
CV_FOURCC("D", "I", "V", "X")
will only work if you have DIVX installed. which I did and the file is almost the same size as the original files.
I don't have it installed, at least not directly; I wonder if it's readily accessible because I have VLC installed?
- CV_FOURCC("D", "I", "V", "X") and most other codecs didn't worked until I fixed the Function syntax (different from the OpenCV documentation), codec loaded or otherwise

AVIcodec:
cvid;Enabled;CinepakĀ® Codec;1.10.0.11;Radius Inc.;C:\Windows\system32\iccvid.dll
i420;Enabled;Intel Indeo(R) Video YUV Codec;6.1.7600.16385 (win7Microsoft Corporation;Microsoft Corporation;C:\Windows\system32\iyuv_32.dll
iyuv;Enabled;Intel Indeo(R) Video YUV Codec;6.1.7600.16385 (win7Microsoft Corporation;Microsoft Corporation;C:\Windows\system32\iyuv_32.dll
mrle;Enabled;Microsoft RLE Compressor;6.1.7600.16385 (win7Microsoft Corporation;Microsoft Corporation;C:\Windows\system32\msrle32.dll
msvc;Enabled;Microsoft Video 1 Compressor;6.1.7600.16385 (win7Microsoft Corporation;Microsoft Corporation;C:\Windows\system32\msvidc32.dll
uyvy;Enabled;Microsoft UYVY Video Decompressor;6.1.7601.17514 (win7Microsoft Corporation;Microsoft Corporation;C:\Windows\system32\msyuv.dll
yuy2;Enabled;Microsoft UYVY Video Decompressor;6.1.7601.17514 (win7Microsoft Corporation;Microsoft Corporation;C:\Windows\system32\msyuv.dll
yvu9;Enabled;Toshiba Video Codec;6.1.7601.17514 (win7Microsoft Corporation;Microsoft Corporation;C:\Windows\system32\tsbyuv.dll
yvyu;Enabled;Microsoft UYVY Video Decompressor;6.1.7601.17514 (win7Microsoft Corporation;Microsoft Corporation;C:\Windows\system32\msyuv.dll
I was using "System Information" (nice find with AVIcodec):
All Programs - Accessories - System Tools > System Information -- System Summary -- Components -- Multimedia -- Video Codecs...
now to fight "cross dissolve" from file to file
Choose any one or a combination of effects in the OpenCV package examples:
- currently set for a 3 second (start) blur-in / (end) blur-out effect

Code: Select all

BlurIn = fps * 3 * 2
BlurOut = 1

Repeat
  *image = cvQueryFrame(*capture)

  If *image
    cvPutText(*image, "JHPJHP", 10, 30, @font, 255, 0, 0, 0)
    FramePos.d = cvGetCaptureProperty(*capture, #CV_CAP_PROP_POS_FRAMES)
    FrameCount.d = cvGetCaptureProperty(*capture, #CV_CAP_PROP_FRAME_COUNT)

    If FramePos <= fps * 3
      BlurIn - 2
      cvSmooth(*image, *image, #CV_BLUR, BlurIn, 0, 0, 0)
    ElseIf FrameCount - FramePos <= fps * 3
      BlurOut + 2
      cvSmooth(*image, *image, #CV_BLUR, BlurOut, 0, 0, 0)
    EndIf
    cvWriteFrame(*writer, *image)
    cvShowImage(#CV_WINDOW_NAME, *image)
    keyPressed = cvWaitKey(10)
  Else
    Break
  EndIf
Until keyPressed = 27 Or ExitCV

Re: Is there an easy way to add text to an mp4 video

Posted: Wed Jan 15, 2014 4:43 am
by normeus
I'll give it a try.

Thank you JHPJHP,

Norm.