Announcement

Collapse
No announcement yet.

Sequence of bitmaps ---> AVI video

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sequence of bitmaps ---> AVI video

    Problem: create an AVI video file from a sequence of graphic bitmaps, or bitmap files.

    Each bitmap would be a frame of the video. The only other input besides the bitmaps is an integer: the number of frames per second.

    Politically incorrect signatures about immigration patriots are forbidden. Googling “immigration patriots” is forbidden. Thinking about Googling ... well, don’t even think about it.

  • #2
    I'm looking for a bmp-avi converter, too. I tried some tools, but the only working method seems to combine bmp's with CorelPaint frame by frame painfully.

    Comment


    • #3
      There are several free programs that can convert a series of bmp image files to one avi movie file.

      Images To Video – 11 MB – has a command line interface (besides a GUI), so you could put Images To Video in the same folder as a PowerBasic program and have the PowerBasic program write its bitmaps to bmp files in a temporary folder then shell to Images To Video which would create the avi from the bmp files, then the PowerBasic program could delete the bmp files leaving just the avi file.

      But of course it would be neater to do it all in a PowerBasic program. Also you could sell it for money which you couldn’t do if you included freeware.

      FFmpeg also has a command line interface besides a GUI but I haven’t tried it. The exe is probably large considering its many features. The download is in tar format.

      Here are some free GUI-only programs (I’ve only tried the first one):
      MakeAVI (only 700 KB)
      Imagej
      Easy Video Maker

      Politically incorrect signatures about immigration patriots are forbidden. Googling “immigration patriots” is forbidden. Thinking about Googling ... well, don’t even think about it.

      Comment


      • #4
        There this

        https://forum.powerbasic.com/forum/u...-jpeg-avi-code

        I’m am woking on ver 2 with 4gb files and uncompressed frames.
        BASIC shampoo - DO:LATHER:RINSE:LOOP UNTIL CLEAN <>0

        Comment


        • #5
          Ver 2 came about because ver1 uses mjpg compression and works great as is except when you go to re-encode the file to a different compression format; mjpg leave artifacts and reduces the compression in the new format. Solution is uncompressed frames.

          I’m also adding sequences, so when the file size hits a 1,2,3 or 4gb limit it is closed and a new file is started.
          BASIC shampoo - DO:LATHER:RINSE:LOOP UNTIL CLEAN <>0

          Comment


          • #6
            [withdrawn]
            Last edited by Mark Hunter; 4 Dec 2018, 11:10 PM.
            Politically incorrect signatures about immigration patriots are forbidden. Googling “immigration patriots” is forbidden. Thinking about Googling ... well, don’t even think about it.

            Comment


            • #7
              Mark; Seeing how you are working from the source I posted and not the sll here are some hints to help you out

              If you change the long’s in the AVI types to dword you would get instant 4gb files. The AVI specs say 1 gb files but I’ve had no issues with 2,3 or 4gb files. The AVI Specs were written in 1995.

              The source I posted used a fourcc of “MJPG” aka motion jped; for uncompressed DBI’s in the new version I’m working on, I used "DIB " AKA independent bitmap RAW

              Code:
              %MJPG  = &h47504A4D ' "MJPG" Motion Jpeg; just a series of jpg images
              %DIB_  = &H20424944 ' "DIB " Device independent bitmap  RAW
              The BMP must also be rotated & I’m using the example Gary posted; thank you Mr Beene
              here is how i did it; use the output of this in place for the jpeg buffer when writing the image data

              Code:
              TYPE AVIRGB
                r AS BYTE
                g AS BYTE
                b AS BYTE
                a AS BYTE
              END TYPE
              '                             @@@@
              '--------------------------@@@#**#@@@-------------------------
              '                             @@@@         PB dib 2 DIB_ string AKA raw DIB uncompressed
              FUNCTION PbDib2Raw(BYVAL hdl_dbi AS LONG, BYVAL aviWidth AS LONG, BYVAL aviHeight AS LONG) COMMON AS STRING
                  LOCAL buffer1,buffer2 AS STRING
                  LOCAL r,g,b AS BYTE
                  LOCAL i,l,j AS LONG
                  LOCAL lp,lp_orig,fp AS LONG POINTER
                  LOCAL rgbptr AS AVIRGB PTR
                  LOCAL byt AS BYTE PTR
                  l=(aviWidth * aviHeight)
                  GRAPHIC ATTACH hdl_dbi, 0
                  GRAPHIC GET BITS TO buffer1$
              
                  ' Flip Horizontal       ** thank you Gary Beene
                  lp_orig = STRPTR(buffer1$)+8
                  FOR i = 1 TO (aviWidth*aviHeight)*4 STEP aviWidth*4
                     lp = lp_orig + (i-1) : fp = lp + aviWidth*4 - 4
                     FOR j = 1 TO aviWidth\2
                         SWAP @fp, @lp
                         INCR lp : DECR fp
                     NEXT j
                  NEXT i
              
                  Buffer2$=STRING$((3*l),0)
                  rgbptr=STRPTR(Buffer1$)
                  byt=STRPTR(Buffer2$)
                  FOR i=l TO 8 STEP -1
                      @byt=@rgbptr[i].r
                      INCR byt
                      @byt=@rgbptr[i].g
                      INCR byt
                      @byt=@rgbptr[i].b
                      INCR byt
                  NEXT
                  FUNCTION=Buffer2$
              END FUNCTION

              For uncompressed AVI you will also need to change the index FOURCC from

              Code:
              %nndc  = &H63643030 ' "00dc" Stream 00 DIB compressed
              to
              Code:
              %nndb  = &H62643030 ' "00db" Stream 00 DIB bytes
              Last edited by Frank Fenti; 4 Dec 2018, 09:46 PM. Reason: fat fingers
              BASIC shampoo - DO:LATHER:RINSE:LOOP UNTIL CLEAN <>0

              Comment


              • #8
                The SLL code is not posted. The non-SLL version doesn’t seem to be what Frank got to work because some of the subroutines (names and parameter types) do not match those used in the PBMain caller.

                Anyway, like Frank now, I’m interested in making the avi out of bmp’s rather than jpg’s. Ideally – because my frames are “cartoon-like”, that is, made of areas of one color delimited by a thin boundary – png (run-length encoded) frames would be the most efficient.

                Politically incorrect signatures about immigration patriots are forbidden. Googling “immigration patriots” is forbidden. Thinking about Googling ... well, don’t even think about it.

                Comment


                • #9
                  Interesting tutorial here (VB6) with code. Might be of some value to you.

                  ... and possible info here too.

                  Comment


                  • #10
                    Mark did you try out FFmpeg? I used it for a few things in the past - thought it pretty useful. Some discussion on that here. Looks like there are lots of links on that topic.

                    Comment


                    • #11
                      Thanks for the links. They made me feel ignorant, there’s a lot not to know about avi files.

                      For now I’m going to use ImagesToVideo as described in my second post above.
                      Politically incorrect signatures about immigration patriots are forbidden. Googling “immigration patriots” is forbidden. Thinking about Googling ... well, don’t even think about it.

                      Comment

                      Working...
                      X