Yalir / sfeMovie

sfeMovie is a simple C++ library that lets you play movies in SFML based applications. It relies on FFmpeg to read medias and remains consistent with SFML's naming conventions.
http://sfemovie.yalir.org/
GNU Lesser General Public License v2.1
114 stars 37 forks source link

Broken file, keyframe not correctly marked. #45

Closed Sashachan closed 10 years ago

Sashachan commented 10 years ago

Hai. I used https://github.com/Yalir/sfeMovie/commit/11bf8b6c944e2aef75a7d1d929dd8d2ea0400f79 as example. I use ogg file. Audio work just fine, but there is no video. Console show error "[ogg @ 02850060] Broken file, keyframe not correctly marked."

sfml 2.1 newest sfeMovie visual studio 2012

Ceylo commented 10 years ago

Hello Sashachan, Can you post a sample of the movie that reproduces the issue?

Sashachan commented 10 years ago

Hello Ceylo, I tried http://techslides.com/sample-webm-ogg-and-mp4-video-files-for-html5/ and http://commons.wikimedia.org/wiki/File:Pentagon_News_Sample.ogg and one that i converted with "super" converter.

... Actually i have kinda fixed this. I downloaded ffmpeg and converted my file with it. I dont have keyframe error in console now, but still there is only music in program, no video[only black screen].(in media player classic i can see both video and hear music) Sample created with ffmpeg: http://www.speedyshare.com/KrwcW/output.ogv

this is log from ffmpeg

ffmpeg -i input.mp4 -codec:v libtheora -qscale:v 7 -codec:a libvorbis -qscale:a 5 -vf scale=320:240 output.ogv ffmpeg version N-60106-ge6d1c66 Copyright (c) 2000-2014 the FFmpeg developers built on Jan 22 2014 22:01:26 with gcc 4.8.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib libavutil 52. 63.100 / 52. 63.100 libavcodec 55. 49.100 / 55. 49.100 libavformat 55. 25.101 / 55. 25.101 libavdevice 55. 5.102 / 55. 5.102 libavfilter 4. 1.100 / 4. 1.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf53.24.2 Duration: 00:00:17.21, start: 0.000000, bitrate: 1262 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 1065 kb/s, 24 fps, 24 tbr, 48 tbn, 48 tbc (default) Metadata: creation_time : 1970-01-01 00:00:00 handler_name : VideoHandler Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 19 2 kb/s (default) Metadata: creation_time : 1970-01-01 00:00:00 handler_name : SoundHandler Output #0, ogg, to 'output.ogv': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf55.25.101 Stream #0:0(und): Video: theora (libtheora), yuv420p, 320x240, q=2-31, 200 k b/s, 24 tbn, 24 tbc (default) Metadata: creation_time : 1970-01-01 00:00:00 handler_name : VideoHandler major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf55.25.101 Stream #0:1(und): Audio: vorbis (libvorbis), 44100 Hz, stereo, fltp (default ) Metadata: creation_time : 1970-01-01 00:00:00 handler_name : SoundHandler major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf55.25.101 Stream mapping: Stream #0:0 -> #0:0 (h264 -> libtheora) Stream #0:1 -> #0:1 (aac -> libvorbis) Press [q] to stop, [?] for help frame= 9 fps=0.0 q=0.0 size= 4kB time=00:00:00.38 bitrate= 73.8kbits/s frame= 25 fps= 24 q=0.0 size= 51kB time=00:00:01.06 bitrate= 390.6kbits/s frame= 43 fps= 27 q=0.0 size= 51kB time=00:00:01.81 bitrate= 229.6kbits/s frame= 58 fps= 28 q=0.0 size= 117kB time=00:00:02.42 bitrate= 395.1kbits/s frame= 72 fps= 28 q=0.0 size= 117kB time=00:00:03.08 bitrate= 310.6kbits/s frame= 89 fps= 28 q=0.0 size= 184kB time=00:00:03.71 bitrate= 406.1kbits/s frame= 107 fps= 29 q=0.0 size= 247kB time=00:00:04.50 bitrate= 449.7kbits/s frame= 127 fps= 30 q=0.0 size= 313kB time=00:00:05.34 bitrate= 480.5kbits/s frame= 144 fps= 31 q=0.0 size= 320kB time=00:00:06.08 bitrate= 431.5kbits/s frame= 160 fps= 31 q=0.0 size= 385kB time=00:00:06.69 bitrate= 471.1kbits/s frame= 177 fps= 31 q=0.0 size= 476kB time=00:00:07.40 bitrate= 526.7kbits/s frame= 194 fps= 31 q=0.0 size= 483kB time=00:00:08.15 bitrate= 485.1kbits/s frame= 212 fps= 32 q=0.0 size= 548kB time=00:00:08.90 bitrate= 504.6kbits/s frame= 212 fps= 14 q=0.0 size= 548kB time=00:00:08.90 bitrate= 504.5kbits/s frame= 229 fps= 15 q=0.0 size= 617kB time=00:00:09.55 bitrate= 529.3kbits/s frame= 243 fps= 15 q=0.0 size= 674kB time=00:00:10.13 bitrate= 544.8kbits/s frame= 243 fps=4.8 q=0.0 size= 674kB time=00:00:10.21 bitrate= 540.5kbits/s frame= 262 fps=5.1 q=0.0 size= 679kB time=00:00:10.93 bitrate= 509.0kbits/s frame= 282 fps=5.4 q=0.0 size= 743kB time=00:00:11.80 bitrate= 515.7kbits/s frame= 301 fps=5.7 q=0.0 size= 811kB time=00:00:12.55 bitrate= 529.0kbits/s frame= 320 fps=6.0 q=0.0 size= 895kB time=00:00:13.40 bitrate= 547.0kbits/s frame= 339 fps=6.3 q=0.0 size= 900kB time=00:00:14.15 bitrate= 520.7kbits/s frame= 357 fps=6.6 q=0.0 size= 963kB time=00:00:14.90 bitrate= 529.2kbits/s frame= 374 fps=6.8 q=0.0 size= 1037kB time=00:00:15.65 bitrate= 543.0kbits/s frame= 390 fps=7.1 q=0.0 size= 1096kB time=00:00:16.30 bitrate= 550.5kbits/s frame= 407 fps=7.3 q=0.0 size= 1100kB time=00:00:16.98 bitrate= 530.7kbits/s frame= 413 fps=7.4 q=0.0 Lsize= 1180kB time=00:00:17.20 bitrate= 562.0kbits/ s video:835kB audio:330kB subtitle:0 global headers:7kB muxing overhead 0.709836%

program(from https://github.com/Yalir/sfeMovie/commit/11bf8b6c944e2aef75a7d1d929dd8d2ea0400f79)

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <sfeMovie/Movie.hpp>
#include <iostream>

 #ifndef MOVIE_FILE
 #define MOVIE_FILE "output.ogv"
 #endif

  /*
   * Here is a little use sample for sfeMovie.
   * It'll open and display the movie specified by MOVIE_FILE above.
 @@ -19,7 +15,7 @@
   *  - F key to toggle between windowed and fullscreen mode
   */

 int main()
  {
    // Some settings
    const std::string windowTitle = "sfeMovie Player";
    const int windowHeight = 600;
     const int windowWidth = 800;
    bool fullscreen = false;

   std::cout << "Going to open movie file \"" << MOVIE_FILE << "\"" << std::endl;

    // Create window
    sf::RenderWindow window(sf::VideoMode(windowWidth, windowHeight), windowTitle, sf::Style::Close);

    // Create and open movie
    sfe::Movie movie;
   if (!movie.openFromFile(MOVIE_FILE))
      return 1;

    // Scale movie to the window drawing area and enable VSync
      // Scale movie to the window drawing area and enable VSync
   // movie.resizeToFrame(0, 0, window.getSize().x, window.getSize().y);
  //  window.setVerticalSyncEnabled(true);

    // Start movie playback
    movie.play();

    while (window.isOpen())
    {
      sf::Event ev;
      while (window.pollEvent(ev))
      {
        // Window closure
        if (ev.type == sf::Event::Closed ||
          (ev.type == sf::Event::KeyPressed &&
           ev.key.code == sf::Keyboard::Escape))
        {
          window.close();
        }

        // Handle basic controls
        else if (ev.type == sf::Event::KeyPressed)
        {
          // Play/Pause
          if (ev.key.code == sf::Keyboard::Space)
          {
            if (movie.getStatus() != sfe::Movie::Playing)
              movie.play();
            else
              movie.pause();
          }

          // Stop
          if (ev.key.code == sf::Keyboard::S)
            movie.stop();

          // Restart playback
          if (ev.key.code == sf::Keyboard::R)
          {
            movie.stop();
            movie.play();
          }

          // Toggle fullscreen mode
          if (ev.key.code == sf::Keyboard::F)
          {
            fullscreen = !fullscreen;

            // We want to switch to the full screen mode
            if (fullscreen)
            {
              window.create(sf::VideoMode::getDesktopMode(), windowTitle, sf::Style::Fullscreen);
              window.setVerticalSyncEnabled(true);
              movie.resizeToFrame(0, 0, window.getSize().x, window.getSize().y);
            }

            // We want to switch back to the windowed mode
            else
            {
              window.create(sf::VideoMode(windowWidth, windowHeight), windowTitle, sf::Style::Close);
              window.setVerticalSyncEnabled(true);
              movie.resizeToFrame(0, 0, window.getSize().x, window.getSize().y);
            }
          }
        }
      }

      // Render movie
      window.clear();
      window.draw(movie);
      window.display();
    }

    return 0;
  }
Ceylo commented 10 years ago

I'll give it a try with Visual Studio 2012. Here on OS X I'm able to play all of the movies available from the websites you stated. I've no video issue, and only incorrect audio with the 3GP file.

When you say you use the newest sfeMovie, I suppose you built the binaries from the sources available on this Github repository?

Can you put your code between two ``` so that I can copy paste it and make sure we use the same?

Sashachan commented 10 years ago

i changed code above actually i'm using http://lucas.soltic.etu.p.luminy.univmed.fr/sfeMovie/start.php for Windows (Visual Studio 2012) Can this be a problem? Also SFML is linked statically.

Ceylo commented 10 years ago

Sorry for the answer time, been a bit busy for the past two weeks :)

The link you gave is for sfeMovie 1.0. There've been little changes in the meantime (especially easier building and some bugfixes, but nothing related to codec thus it should not change anything to your issue)

As stated in red on the getting started page, the instructions for building from the latest sources are there : http://lucas.soltic.etu.p.luminy.univmed.fr/sfeMovie-v1.1/start.php

Anyway, I'm going to try your movies now on Windows :)

Ceylo commented 10 years ago

So, I tested latest sfeMovie (from Git sources) and here are the results:

With free codecs (those I suppose you are using) I could play all ogv/ogg and webm movies. With all codecs enabled, I could play all the movies (except that the 3GP file audio is broken).

I copy pasted your sample code and it works fine for me except that it doesn't fit the whole window as with the sample code from the git repository.

So I'm wondering whether this is something related to graphics on your computer. Do SFML Graphics samples work fine?

Sashachan commented 10 years ago

SFML graphics works great. I even created tic tac toe game with it. Maybe this is graphics related, my computer isn't new... Video codecs installed on a computer matters? Im using http://www.cccp-project.net/

Ceylo commented 10 years ago

Hmm no. Your own video codecs won't change anything to sfeMovie. Can you check whether the "sfeMovie Demo" program correctly displays video? It's available on this page: http://lucas.soltic.etu.p.luminy.univ-amu.fr/sfeMovie/downloads.php

firefly2442 commented 10 years ago

I tested on the latest master branch. Hash: d79e10bdba9ef27de62a5763b2c085f8dea0c303 CMake Settings: LINK_AGAINST_INTERNAL_FFMPEG: True OS: Linux I tried the following 480p .ogg video file: http://www.bigbuckbunny.org/index.php/trailer-page/ $:~/build/sfeMovie/sample$ ./sfeMovieSample trailer_400p.ogg Going to open movie file "trailer_400p.ogg" [ogg @ 0xa1e2ca0] 25 bytes of comment header remain [ogg @ 0xa1e2ca0] truncated comment header, 1 comments not found [theora @ 0xa1e9020] 7 bits left in packet 82 [ogg @ 0xa1e2ca0] Broken file, keyframe not correctly marked. [theora @ 0xa1eaac0] 7 bits left in packet 82 [ogg @ 0xa1e2ca0] Broken file, keyframe not correctly marked. [ogg @ 0xa1e2ca0] Broken file, keyframe not correctly marked. [ogg @ 0xa1e2ca0] Broken file, keyframe not correctly marked. [ogg @ 0xa1e2ca0] Broken file, keyframe not correctly marked. [ogg @ 0xa1e2ca0] Broken file, keyframe not correctly marked. [ogg @ 0xa1e2ca0] Broken file, keyframe not correctly marked. It does play correctly, but I seem to be able to replicate this issue.

firefly2442 commented 10 years ago

Perhaps this is an issue upstream in FFMPEG?

firefly2442 commented 10 years ago

http://ffmpeg.org/pipermail/ffmpeg-user/2012-February/004861.html

Sashachan commented 10 years ago

Woah, demo works! Both video and sounds. So this is my compiler and wrong configuration fault?

@Firefly2442 i dont have this keyframe error now, now i have problem with video. I have sounds, but black screen instead of video.

Ceylo commented 10 years ago

@firefly2442 I've looked at the thread you gave. Seems like it's just about the "Broken file, keyframe not correctly marked." error and seeking issue, but not about displaying video. So getting a recent version of FFmpeg will most probably help with this error but not with the missing video. @Sashachan You can still check how old your ffmpeg executable is if you want to get rid of the error message.

@Sashachan Well at least we know this is not an issue related to your computer/graphics nor SFML. From what I remember, the sfeMovie was simply built from the sample/main.cpp source file at the time of sfeMovie 1.0: https://github.com/Yalir/sfeMovie/tree/v1.0 I had built it with MinGW, but there should be no difference with Visual Studio. What I'm going to do is packing a full Visual Studio project that uses one of your movies and post it here so that you can test it and check the difference with your own configuration.

Ceylo commented 10 years ago

Here it is: http://lucas.soltic.etu.p.luminy.univ-amu.fr/downloads/sfeMovieSampleWithVS2012.zip (28MB)

With it I could play the pentagon news movie. I packed both the libraries, headers and movie file. And I tried to use only relative paths in Visual Studio so that you can try it both outside and inside of Visual Studio 2012. I also had a crash when exiting the demo if it was launched from Visual Studio, from what I remember this is https://github.com/LaurentGomila/SFML/issues/30 .

Sashachan commented 10 years ago

I can only say that... You're wizard! Thank you very much! It's working great. Even after changing code(for my easier version, because i dont understand everything in your) it works! I dont know why it was not working before. Im looking at the configuration, but i dont see major changes for now. I need to look more. I will write when i will find more. At least I can use this program as a base.

Ceylo commented 10 years ago

Glad that I could help and that it worked for you too!! :) And yes it would be very interesting to know what the little difference that made it work is :)

firefly2442 commented 10 years ago

I think this issue is still persisting in the sfeMovie2 Git branch that uses FFMPEG 2.0.

./sfeMovieSample ~/build/sfeMovie/tests/small_1.ogv 
Going to open movie file "...small_1.ogv"
[ogg @ 0x8dec1c0] Broken file, keyframe not correctly marked.
[ogg @ 0x8dec1c0] Broken file, keyframe not correctly marked.
[ogg @ 0x8dec1c0] Broken file, keyframe not correctly marked.
[ogg @ 0x8dec1c0] Broken file, keyframe not correctly marked.
[ogg @ 0x8dec1c0] Broken file, keyframe not correctly marked.
Ceylo commented 10 years ago

But did you try to reencode the movie with the latest FFmpeg version? At the moment ffplay (from FFmpeg 2.1) yields the same errors. And the fix shown in the FFmpeg thread you gave involves re-encoding the movie with a FFmpeg version built after february 2012. If you're using the original file, it's probably been encoded in 2008 (seems like to be the release date of the movie) with a "broken" version of FFmpeg.

Ceylo commented 10 years ago

Any news about this?

firefly2442 commented 10 years ago

Finally got a chance to try this. Ubuntu 13.10 has a version of FFMPEG that still has the issue and I don't have any computer running 14.04. However, I compiled the latest development version of FFMPEG and re-encoded the file. This seemed to work and did not produce the above error message.

That being said, is there any way to intercept these messages to check for this issue from sfeMovie? I'm just concerned that people may be using older videos and content encoded with older versions of FFMPEG and be confused by these messages. Is there anything that can be done or is this something that is purely handled upstream by FFMPEG?

Ceylo commented 10 years ago

This is handled by FFmpeg but it has a av_log_set_level() function so I can handle that transparently with sfeMovie's log stuff :)

Ceylo commented 10 years ago

Default log level no more shows this warning so I'm closing the issue.