Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ Video encoder ?

Video encoder ?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Yazhgar   France  (1 post)  Bio
Date Wed 22 Aug 2018 07:49 AM (UTC)
Message
Hi there,

I'd like to know if it's possible to encode a video into a miniwindows inside of mush ?

Thanks in advance for your help.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 23 Aug 2018 05:48 AM (UTC)

Amended on Thu 23 Aug 2018 06:06 AM (UTC) by Nick Gammon

Message
It's not really designed for that, however I once played a short video clip using the technique here:



-- --------------------------------------------------------------------
-- PlayMovie (info)
--  info.filename (eg. "/frames/my_movie_%03i.png" )
--  info.frames   (eg. 10, if the movie consists of 10 files)
--  info.x   - X position on screen
--  info.y   - Y position on screen

--  Suggested conversion:
--    ffmpeg -ss "00:30" -i INPUTFILE.mp4 -t 1     -r 10 -s 720x404 frames/my_movie_%03i.png
--                ^^^^          ^^^       ^^^^     ^^^^^    ^^^^^^^    ^^^^^^^^^^
--           Start time      input file  how long   FPS       size      output files
-- --------------------------------------------------------------------
function PlayMovie (info)
  movieInfo = info

  if not info then
    return
  end -- if

  assert (type (movieInfo) == "table",
          "Argument to PlayMovie should be a table")

  local gotErrors = false

  -- load each movie frame into memory, if not already done
  for i = 1, movieInfo.frames do
    local filename = string.format (movieInfo.filename, i)
    if not WindowImageInfo(win, filename, 2) then
       local result = WindowLoadImage(win, filename, filename)
       if result ~= error_code.eOK then
         ColourNote ("Red", "", "Could not open move frame file:")
         ColourNote ("Red", "", "   -> " .. filename)
         ColourNote ("Red", "", "   Reason: " .. error_desc [result])
         gotErrors = true
       end -- if
    end -- if
  end -- for each frame

  -- if couldn't do it, discard the movie info
  if gotErrors then
    movieInfo = nil
    return
  end -- if

  -- otherwise, start at frame 1
  movieInfo.currentFrame = 1

end -- PlayMovie

-- --------------------------------------------------------------------
-- PlayMovieFrame - called by a timer every 1/10 second - show current frame, advance count
-- --------------------------------------------------------------------
function PlayMovieFrame (timerName)

  -- if no current movie, do nothing
  if not movieInfo then
    return
  end -- if

  -- timing stuff
  timeTaken = timeTaken or 0
  frameCount = frameCount or 0

  local startTime = utils.timer ()
  local filename = string.format (movieInfo.filename, movieInfo.currentFrame)
  if WindowDrawImage (win, filename, movieInfo.x, movieInfo.y, 0, 0,
                      miniwin.image_copy) ~= error_code.eOK then
     ColourNote ("Orange", "", "Could not draw image: " .. imageName)
  end -- if
  Redraw () -- force screen update

  -- next frame
  movieInfo.currentFrame = movieInfo.currentFrame + 1
  -- wrap
  if movieInfo.currentFrame > movieInfo.frames then
    movieInfo.currentFrame = 1
  end -- if

  -- add up how long we took doing this
  timeTaken = timeTaken + utils.timer () - startTime
  -- and how many times
  frameCount = frameCount + 1
end -- PlayMovieFrame



Timer:


<timers>
  <timer
    script="PlayMovieFrame"
    enabled="y"
    second="0.1"
    active_closed="y"
  >

  </timer>
</timers>


Calling the above functions:



  PlayMovie {
            filename = "frames\\my_movie_%03i.png",
            frames = 30,
            x = 10,
            y = 10,
            }



First you take a (short) movie and convert it into PNG files (see the suggested ffmpeg command above) with a frame rate of 10 FPS.

Then we set up a timer that is called every 1/10th of a second to play the next frame.

The function PlayMovie is called which scans the supplied directory for all of the files matching the supplied file name. It loads them all into miniwindow "images". Then the timer is called which replaces the current frame with the next one.

This is hardly going to play a full-length video, but it worked OK for me to play a short animation.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,555 posts)  Bio   Global Moderator
Date Reply #2 on Thu 23 Aug 2018 09:50 PM (UTC)

Amended on Thu 23 Aug 2018 09:57 PM (UTC) by Fiendish

Message
Quote:
I'd like to know if it's possible to encode a video into a miniwindows inside of mush ?

All things are possible with sufficient effort. If you're not satisfied with Nick's png frames method, you can always try to convert frames on the fly with something like https://github.com/daurnimator/ffmpeg-lua-ffi or https://github.com/e-lab/torch-toolbox/tree/master/Video-decoder

https://github.com/fiendish/aardwolfclientpackage
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,896 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.