Videos small issue (lags)

  • #1, by Simon_ASAMonday, 03. August 2015, 19:34 9 years ago
    Hi everyone, I have a small problem with videos and the VS player. Let me explain:

    My game is a 1st person adventure game. The moves (walk, run) between each scene are symbolized by video transitions. So the videos take us from a point A to a point B (which means I have: scene A --> video (walk) --> scene B - etc). This process needs to be smooth. For those who know that game, it's a bit like Shizm.

    However, for an unknown reason, the videos often play slowly and lag. From point A to the video, it works well (VS quits the current scene and plays the video perfectly fullscreen). Then while playing the video, it is sometimes (rarely) slow, but very often it lags at the very end. And usually it lags so much that the very very end of the video is not played (only a very few frames, but still it's suddenly cut). And then we arrive on point B and we can keep playing.

    So I was wondering if anyone else has ever had the same kind of issue?
    It's not a big issue but it would be much better if I could fix it. I insist that it doesn't prevent from playing the game.

    I use the recommended settings for the videos: MKV, VP8 and OGG.
    In the doubt, I have also tried other codecs: AVI/Xvid/Mp3, MKV/H264/AAC
    The videos are 1920x1080, bitrate 5000.
    With Avi+Xvid it is the worst, because all the videos will freeze.

    It's as if the VS player was sometimes overloaded by the rest of the game in the background and the next scenes to load in memory. The game itself has been optimized as much as possible, but it is true that I have a "rain" animation playing all the time (PNG, 480x300, 90ms between each frame, and the whole thing upscaled to 1920x1080 with a script), along with hotspot "snoop" animations, music (ogg), sound effects and various pics (webp).

    Honestly I don't know if there's a solution to prevent the lags in the videos (they usually happen when there used to be a black screen in VS 3.x, for those who remember old versions).

    Just want to know if someone else has the same problem. Thanks!

    PS: oh and my PC is more than powerful enough, and my drivers are up to date. No problem here wink

    Great Poster

    321 Posts


  • #2, by gustyMonday, 03. August 2015, 20:50 9 years ago
    Possible solutions:

    1) rain animation - instead of .png why don't you use .webp?

    2) do you really need 1920x1080 videos? Maybe upscaled 1280x720 would be sufficient enough?

    Forum Fan

    159 Posts

  • #3, by gustyMonday, 03. August 2015, 20:54 9 years ago
    btw you can always try to deactive rain animations just for sake of testing - just to see if videos are not lagging anymore

    Forum Fan

    159 Posts

  • #4, by BigStansMonday, 03. August 2015, 21:29 9 years ago
    Encode movies to VP8.
    And, yes not every CPU has enough "power" to decode FullHD movies (without acceleration), it's better to use 720p.
    Or make an "Choiser" in your game (like the menu) which has an option for "HD" movies. and encode it to 720 and 1080p.

    Great Poster

    361 Posts

  • #5, by Simon_ASAMonday, 03. August 2015, 21:47 9 years ago
    Many thanks for your replies everyone!

    rain animation - instead of .png why don't you use .webp?

    I need alpha, the rain is playing in an interface over the backgrounds, and I don't know if webp has transparency. I don't see this option - I'm using IrfanView to convert Jpg to Webp.

    you can always try to deactive rain animations

    In fact I had already tried but the problem is the same...

    do you really need 1920x1080 videos?

    Yes in this case I have no other choice.

    Encode movies to VP8.

    Already tried VP8, Xvid and H264. Same result.
    Currently I use VP8.

    not every CPU has enough "power" to decode FullHD movies

    Well, my CPU does have enough power smile So it should run smoothly!

    @BigStans:
    I have sent you a private message some time ago asking questions about video encoding. I had joined a private link with a preview VED of my project. If you have the time and possibility, could you please try to run it to see the video transitions in the game? It would be much better than long explanations. Lee has already given me some valuable tips on other subjects after looking at my file. Thanks a lot.

    Great Poster

    321 Posts

  • #6, by gustyTuesday, 04. August 2015, 00:41 9 years ago
    is there really that big difference between 1080p and 720p?

    you can try one more thing. You can create completely new clean project just to run those videos in it. Then you will know it's either technical bug or it's something unknown that interfere in your current project (rain animation, preloading/loading of other graphics...)

    Forum Fan

    159 Posts

  • #7, by afrlmeTuesday, 04. August 2015, 02:49 9 years ago
    @ Simon: webp has alpha / transparency support just like png - actually it even has a lossless export option too but unlike png it also has options that allow you to compress it to a lossy quality format.

    I recommend XnConvert for batch converting your png files to webp format. Check out the wiki page I wrote for image encoding which can be found in the manual section as it contains a link to the program & a mini guide on how to use the program.

    @ Gusty: I suppose it depends. @ 720p the videos will not be quite as seamless as 1080p as the video quality will not be as good when scaling up. I think the general idea is that the videos are used as a transition between each scene / view change while navigating around the environment, so they should look more like part of the game itself as opposed to a cut-scene video. @ 720p it will be more noticeable that it will be a video than at 1080p. I think the suggestion David offered about giving the player an option to determine video quality then deciding which version in game should play based on a condition or value that has been set is a nice idea, however it would increase the required hd space total due to having multiple versions of each video file.

    Imperator

    7278 Posts

  • #8, by Simon_ASATuesday, 04. August 2015, 12:12 9 years ago
    Thanks for your suggestions.

    is there really that big difference between 1080p and 720p?

    Yes, a video in 1280x720 is more blurry than a video in 1920x1080. If you watch a movie, you won't see a big difference, but when you play a 1st person adventure game, it is obvious.
    When the player moves from A to B, the video makes the transition. It means that the first frame of the video is the same as scene A, and the last frame of the video is the same as scene B. As a result, when you play in HD 1080 with a sharp image, and suddenly see the videos in 720, it makes a difference.

    webp has alpha / transparency support just like png

    Ok, good to know. This is something I will probably check in the very end of the project, in order to convert all the PNG files to Webp with transparency.


    ------------------------------------------
    So to come back to my problem, I have made a simple test:

    I have taken a video in 720p that I have converted to VP8 (no sound) and MKV. I have saved the very first frame of this video to a Webp picture, and also the very last frame.
    Then I have created a new empty project in VS, imported the first and last frames (the webp). I have created a Left click action on the first frame which plays the video and, at the very end, displays the last frame.

    With this test scene, the result is the same... The video lags at the very very end, and the very last frames (let's say 1 or 2) are not played at all, which gives the impression of a sudden "jump" to the final webp picture.
    Honestly I don't know if it is my computer or not. I didn't have this problem with VS 3 (except for the black frame issue).

    Another test: the video will freeze if I try the same test with Xvid codec at the very end,a nd I have to press Escape in order to see the webp picture. I know that Xvid is not recommended, but in my opinion it proves that something happens with the player (on my PC or in VS, I don't know).

    Update:

    I have just found the option ShowBlackScreenAfterVideoIsPlayed in the Explorer/eGame
    If I activate it, of course the black screen is back (which I don't want), but the videos don't lag anymore. Weird!

    Great Poster

    321 Posts

  • #9, by derOesiTuesday, 04. August 2015, 22:25 9 years ago
    just to add, 1080p has 3 times the pixel density than 720p.. so yes there is a significant difference in quality.

    Newbie

    48 Posts

  • #10, by BigStansTuesday, 04. August 2015, 23:12 9 years ago
    Well, i optimized the "movie player" part yesterday a little bit.
    It decodes now a little bit faster and the quality was much better, because we're up and downsizing now bicubic and bilinear (detect the video frame width and player width).

    @ Simon_ASA: "ShowBlackScreenAfterVideoIsPlayed" was called 1 time after the movie was playing (on finishing).

    @ derOesi: Yes, but the most users did not see an difference.

    Decoding speed and quality has to do with: codec type, frame rate, data rate and resolution

    Here an example using ffmpeg 2.7 to re-encode an movie to 720p with an "medium bitrate" with 2 pass encoding (ogg 192Kb/s - 44100)

    ffmpeg -i test.avi -pass 2 -passlogfile tmpmovie -map 0:0 -map 0:1 -c:a libvorbis -ab 192k -ar 44100 -ac 2 -metadata:s:a:0 language= -async 1 -c:v libvpx -b:v 3538.944k -maxrate 7077.888k -bufsize 7077.888k -r 24 -s 1280x720 -aspect 16:9 -pix_fmt yuv420p -coder ac -trellis 0 -speed 0 -subq 6 -me_range 16 -b_strategy 1 -refs 3 -sws_flags fast_bilinear -direct-pred 1 -sc_threshold 40 -qmin 3 -qmax 51 -threads 4 -sn -y out.mkv
    


    and now the same with just an extreme high bitrate (i think most CPU's are too slow to decode this)
    ffmpeg -i test.avi -pass 2 -passlogfile tmpmovie -map 0:0 -map 0:1 -c:a libvorbis -ab 192k -ar 44100 -ac 2 -metadata:s:a:0 language= -async 1 -c:v libvpx -b:v 22118.4k -maxrate 44236.8k -bufsize 44236.8k -r 24 -s 1280x720 -aspect 16:9 -pix_fmt yuv420p -coder ac -trellis 0 -speed 0 -subq 6 -me_range 16 -b_strategy 1 -refs 3 -sws_flags fast_bilinear -direct-pred 1 -sc_threshold 40 -qmin 3 -qmax 51 -threads 4 -sn -y out.mkv
    


    And for an other example. VP9 and H.265 has an lower bitrate than VP8 and H.264 so, it's possible with these to play 4K movies.

    Increase the quality with 720p has to to with the bitrate too.

    Yes, i am an console freak, but it gives so many good gui's for converting movies with ffmpeg smile Try to play around with these settings. An little reference was: http://wiki.visionaire-tracker.net/wiki/Video_Encoding

    Great Poster

    361 Posts

  • #11, by Simon_ASAWednesday, 05. August 2015, 12:29 9 years ago
    Thanks for the infos BigStans, it's very interesting for everyone I think smile

    i optimized the "movie player" part yesterday a little bit.

    Do you know when it will be available? I plan to release my game by the end of the year, so can it benefit of your optimizations?

    "ShowBlackScreenAfterVideoIsPlayed" was called 1 time after the movie was playing (on finishing).

    Ok, thanks. What is the purpose of this black screen in fact?

    Great Poster

    321 Posts