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

Update provided FFmpeg version #34

Closed firefly2442 closed 10 years ago

firefly2442 commented 11 years ago

It looks like the version that is provided is 1.0. The latest version on the website is 2.0.

Ceylo commented 11 years ago

Indeed, although this won't be done until the new build system is ready.

firefly2442 commented 11 years ago

Just for fun, I decided to try compiling and linking against 2.0. I was able to replace and compile everything properly on the sfeMovie side. FFmpeg appeared to build just fine. However, I received errors about undefined references on the linking side when trying to compile an example application that uses sfeMovie.

Ceylo commented 11 years ago

How exactly did you update FFmpeg? Because if you replaced the sources in deps/ffmpeg, you also need to replace the headers in deps/headers (may be interesting not to separate sources and headers though...). That would explain why compiling went fine but not linking.

firefly2442 commented 11 years ago

Ahh opps. I didn't replace the headers. It was 1:30 am and I couldn't sleep so I was just messing around. ;)

Ceylo commented 11 years ago

I had a look at it, actually the linking error is related to a missing library: libiconv. FFmpeg 2.0 uses it for subtitles, and it wasn't needed in previous versions. So adding libiconv in the linked libraries list fixes that.

Other than that... one constant (for an audio buffer size) is no more defined, and the deprecated avcodec_decode_audio3() does not work with some audio decoders. So I'll need to use avcodec_decode_audio4() instead. It's not an obvious change but it shouldn't be too much work :) .

SpartanJ commented 11 years ago

I've replaced avcodec_decode_audio3 with this: http://pastebin.com/FBB1aA63 Hope it helps! :)

Ceylo commented 11 years ago

Hello SpartanJ, Have you tested this with samples movies? Because from what I see, this is more or less the current avcodec_audio_decode3() implementation, and from what I had seen, it doesn't work well with every decoders :( Or maybe I had done something wrong.. I don't really know.

SpartanJ commented 11 years ago

I didn't test with many decoders so i really don't known, you are right. Do you know what decoders have problems? I can test them for you.

Ceylo commented 11 years ago

Well.. I think it was just Vorbis audio in an OGV movie. Thanks for your help :)

SpartanJ commented 11 years ago

I've a problem that i'm not sure if is related with what we are talking about. I've downloaded the precompiled ffmpeg builds for windows from http://ffmpeg.zeranoe.com/builds/ and builded sfeMovie with various versions of this ffmpeg ( tested with 0.8, 1.0.1, latest nightly builds ) and the sound decoding in sfeMovie doesn't work well, i get some heavy noise apart from the actual decoded sound, here's an example of what i'm talking about http://xraylabs.com.ar/spartan/os/sfeMovie/sample.7z . I've tested using avcodec_audio_decode3 and using the patched version ( but like you said, it's the same, so the problem persist ). Also, i must clarify that this is a windows only issue, in Linux works great. I've also tried compiling from the source using the ffmpeg master branch but the problem persist. In fact the only version that works fine for me is the ffmpeg version of the sfeMovie repository. Also i've tried the same with the ffmpeg tutorials ( http://dranger.com/ffmpeg/ ), and the sound issue seems to appear there too. But ffplay works great in all versions, no sound issues there. Do you have any idea of what could be happening? I've zero knowledge about sound decoding, so i'm a little lost with this. Oh, and vorbis works just fine with your ffmpeg version, but not the others, so i don't know! Thanks!

Ceylo commented 11 years ago

No, I have no idea for now. But in any case this will need to be fixed when switching to FFmpeg 2.0. If you wish to, you can try to find out what's wrong there in the meantime, because at the moment I'm only focusing on what needs to be done for sfeMovie 1.1.

It is weird that it works fine with FFmpeg 1.0 but not FFmpeg 1.0.1 though... as for getting things working fine, maybe looking at ffplay sources could be a good start.

hsdk123 commented 10 years ago

Any updates on this lately? I'm slightly hesitant on using FFmpeg 1.0 when 2.1's out.

Ceylo commented 10 years ago

Hello hsdk123,

There are no updates on this topic yet, and I'm not working on sfeMovie at the moment thus you shouldn't expect much soon.

Are you concerned only by the fact that it's an old version or are there any specific blockers with FFmpeg 1.0?

hsdk123 commented 10 years ago

@Ceylo Thanks for the quick reply. There aren't any specific blockers that come to mind with FFmpeg 1.0 atm, the fact that sfeMovie currently uses 1.0 just made me wary that there might not be any updates for a while and I won't be able to get any help even if bugs occur.

Are there any plans to start work again on sfeMovie any time again in the near future?

Ceylo commented 10 years ago

As for bugs, the only one I know at the moment is that video playback usually stops 0.5s before the end of the movie. All other bugs known in version 1.0 are fixed if you use the sources from this repository.

If a small fix is needed, I can always take some time to do it. As for real active development, I don't know, because at the moment I'm focused on another real big project (which may take years to reach a truly satisfying state). So the question is rather, will I split my free time with sfeMovie? During february, probably yes. After february till the end of august, probably not except for small things (updating to FFmpeg 2.1 isn't a small "thing").

hsdk123 commented 10 years ago

@Ceylo Thanks for the detailed explanation, really helps. I'll go on testing the repository code then, thanks :+1:

Ceylo commented 10 years ago

I don't know how notifications are handled when a commit references an issue but… well, in case you got no notification, this message is just to let you know that I'm working on updating FFmpeg :) (actually a bit more than that, since I'm redesigning sfeMovie). All this work is pushed to the sfeMovie2 branch.

firefly2442 commented 10 years ago

Super, once you feel it's at a good point for testing, let me know and I can try checking out the branch and compiling it on Linux. Cheers.

Ceylo commented 10 years ago

Yup sure! Although there's still much work left :D At the moment audio is working fine but there're still a few things to do before implementing video, like detecting the end of the audio stream, etc.

Ceylo commented 10 years ago

By now if you use the DemuxerCLI (demux) program, you should be able to play ANY audio stream whose codec is supported by FFmpeg. You can also try with movies but it'll only play the audio streams. Note that if there are several audio streams in the same file, all audio streams will be played at the same time (sfeMovie isn't limited anymore to 1 audio stream / file).

I would be really interested in knowing which audio files fail to play. Till now I tried with PCM (WAV / AIF), Vorbis (OGG / OGV), MP3 and AC3 (AVI) without any issue. If you encounter an issue, check that the decoder exists in the list displayed by the 'demux' program at launch. In order to play more files, don't forget to enable all the decoders in CMake before building, or use your own FFmpeg binaries (though I admit I didn't test this with sfeMovie2).

If you find files that fail to play audio (supported or not by FFmpeg), could you tell me which file/codec fails and upload a sample?

Ceylo commented 10 years ago

Great news here!

Seems like the whole new implementation based on FFmpeg 2.1 is more or less finished! There are still a few details like:

Apart from that well… everything should be working fine! And even better than sfeMovie 1.0 on some parts like movies with variable framerate. This was not supported fine, now it is :)

That's also really good news because the new design will ease a lot the support for:

I guess the time for testing has come. Please try as many different movies / audio files as you can, and if you enable all decoders, there will probably be none or very very few media files that don't play fine. If you ever find one of these non-working media file (good luck!), I'm really interested in getting a sample to try it and fix sfeMovie if possible.

firefly2442 commented 10 years ago

Do you think it would be a good idea to install the examples as well? Right now, make install only copies over the libraries, includes, and doxygen.

Ceylo commented 10 years ago

Why not, but is it really interesting to have sfeMovieSample installed? It's main purpose is demonstration and testing. It's not supposed to be a real feature-rich player.

hsdk123 commented 10 years ago

Hi, I'm currently on Windows 7 64bit (Visual Studio 2013) and trying to configure cmake-gui with the sfemovie2 branch. I'm getting the following errors:

CMake Error at cmake/Modules/FindSFML.cmake:89 (FILE):
  file Internal CMake error when trying to open file:
  C:/Users/Daegon/Desktop/Maydev/projects-main/Light.vn(dev)/external(src.lib)/SFML-build/lib/SFML/Config.hpp
  for reading.
Call Stack (most recent call first):
  CMakeLists.txt:68 (find_package)
CMake Error at cmake/Modules/FindSFML.cmake:199 (message):
  Could NOT find SFML (missing: SFML_GRAPHICS_LIBRARY SFML_WINDOW_LIBRARY
  SFML_SYSTEM_LIBRARY SFML_AUDIO_LIBRARY)
Call Stack (most recent call first):
  CMakeLists.txt:68 (find_package)

I currently have one directory called SFML that contains the headers and sources downloaded from the sfml github repo. I have another directory called SFML-build that I've placed my built libraries in.

The first error occurs if I set SFML_INCLUDE_DIR to the directory that contains my lib files (SFML-build), the second error occurs if I set it to the SFML directory that contains sources and headers.

The errors are understandable since my build folder (with the libs) and header folder (with Config.hpp) are each different. But how should I state the path for each folder in cmake-gui - are there entries that I can use to explicitly specify the SFML include folder (with headers) and the built library folder? (like the FFMPEG_INCLUDE_DIR entry and FFMPEG_LIBRARIES entry)

I'm currently following the instructions here: http://lucas.soltic.etu.p.luminy.univ-amu.fr/sfeMovie-v1.1/start.php

I've also tried copying my lib folder (the folder with the built libraries) into my SFML folder (containing the include folder), then setting SFML_ROOT to that directory, but that again produces the same Could NOT find SFML error (the 2nd error)

SFML itself is working perfectly with the built libs and downloaded headers - I'm just having problems with sfemovie2.

Ceylo commented 10 years ago

I've also tried copying my lib folder (the folder with the built libraries) into my SFML folder (containing the include folder), then setting SFML_ROOT to that directory, but that again produces the same Could NOT find SFML error (the 2nd error)

I do not know exactly what lets the FindSFML script find SFML, but it works fine with the archive provided on SFML's website. So there may be a difference with the structure you created.

If you absolutely need the latest SFML from Git, try to run the INSTALL target to produce a well structured SFML directory.

And setting SFML_ROOT is the way to go (I never tried with SFML_INCLUDE).

hsdk123 commented 10 years ago

@Ceylo Thanks for the comment, I tried using the SFML nightly build and I managed to get configure and generate working for MSVC 2012.

I now get the following error while trying to build ALL_BUILD in msvc 2012: (building in Release mode)

1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Release Win32 ------
1>Build started 2014-05-20 Tue PM 3:07:06.
1>PrepareForBuild:
[...]
2>  CC  libavfilter/vsrc_cellauto.o
2>  CC  libavfilter/vsrc_life.o
2>  CC  libavfilter/vsrc_mandelbrot.o
2>  CC  libavfilter/vsrc_testsrc.o
2>  /bin/sh: -c: line 0: syntax error near unexpected token `dev'
2>  /bin/sh: -c: line 0: `/C/Users/Daegon/Desktop/Maydev/projects-main/Light.vn(dev)/external(src.lib)/sfeMovie-build/YASM-objects/yasm.exe -f win32  -DPREFIX -I./ -I/tmp/ffmpeg-02.26.2014// -Pconfig.asm -I /tmp/ffmpeg-02.26.2014/libavfilter/x86/ -M -o libavfilter/x86/af_volume.o /tmp/ffmpeg-02.26.2014/libavfilter/x86/af_volume.asm > libavfilter/x86/af_volume.d'
2>  make: *** [libavfilter/x86/af_volume.o] Error 2
2>  *** an error occured, aborting.
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(170,5): error MSB6006: "cmd.exe" exited with code 1.
2>
2>Build FAILED.
2>
2>Time Elapsed 00:07:22.59
3>------ Rebuild All started: Project: sfeMovie, Configuration: Release Win32 ------
3>Build started 2014-05-20 Tue PM 3:14:29.
3>PrepareForBuild:
3>  Creating directory "sfeMovie.dir\Release\sfeMovie.tlog\".
3>InitializeBuildStatus:
3>  Creating "sfeMovie.dir\Release\sfeMovie.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
3>CustomBuild:
3>  Building Custom Rule C:/Users/Daegon/Desktop/Maydev/projects-main/Light.vn(dev)/external(src.lib)/sfeMovie-sfeMovie2/CMakeLists.txt
3>  CMake does not need to re-run because C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-build\CMakeFiles\generate.stamp is up-to-date.
3>ClCompile:
3>  AudioStream.cpp
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\AudioStream.cpp(214): warning C4244: '=' : conversion from 'int64_t' to 'int', possible loss of data
3>  Demuxer.cpp
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\Demuxer.cpp(133): warning C4244: '=' : conversion from 'int64_t' to 'long', possible loss of data
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\Demuxer.cpp(139): warning C4018: '<' : signed/unsigned mismatch
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\Demuxer.cpp(377): warning C4244: '=' : conversion from 'int64_t' to 'long', possible loss of data
3>  Log.cpp
3>  Macros.cpp
3>  Movie.cpp
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\Movie.cpp(209): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\Movie.cpp(210): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\Movie.cpp(214): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\Movie.cpp(215): warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\Movie.cpp(228): warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\Movie.cpp(229): warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
3>  Stream.cpp
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\Stream.cpp(176): warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data
3>  SubtitleStream.cpp
3>  Timer.cpp
3>  Utilities.cpp
3>  VideoStream.cpp
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\VideoStream.cpp(46): warning C4351: new behavior: elements of array 'sfe::VideoStream::m_rgbaVideoBuffer' will be default initialized
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\VideoStream.cpp(46): warning C4351: new behavior: elements of array 'sfe::VideoStream::m_rgbaVideoLinesize' will be default initialized
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\VideoStream.cpp(97): warning C4244: 'return' : conversion from 'double' to 'float', possible loss of data
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\VideoStream.cpp(178): warning C4244: 'initializing' : conversion from 'double' to 'sf::Int64', possible loss of data
3>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\src\VideoStream.cpp(179): warning C4244: 'argument' : conversion from 'sf::Int64' to 'sf::Int32', possible loss of data
3>  Generating Code...
3>LINK : fatal error LNK1181: cannot open input file 'FFmpeg-binaries\lib\avformat.lib'
3>
3>Build FAILED.
3>
3>Time Elapsed 00:00:08.02
4>------ Rebuild All started: Project: sfeMovieSample, Configuration: Release Win32 ------
4>Build started 2014-05-20 Tue PM 3:14:37.
4>PrepareForBuild:
4>  Creating directory "sfeMovieSample.dir\Release\sfeMovieSample.tlog\".
4>InitializeBuildStatus:
4>  Creating "sfeMovieSample.dir\Release\sfeMovieSample.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
4>CustomBuild:
4>  Building Custom Rule C:/Users/Daegon/Desktop/Maydev/projects-main/Light.vn(dev)/external(src.lib)/sfeMovie-sfeMovie2/sample/CMakeLists.txt
4>  CMake does not need to re-run because C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-build\sample\CMakeFiles\generate.stamp is up-to-date.
4>MakeDirsForCl:
4>  Creating directory "C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-build\sample\Release".
4>ClCompile:
4>  main.cpp
4>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\sample\main.cpp(44): warning C4244: 'argument' : conversion from 'const int' to 'float', possible loss of data
4>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\sample\main.cpp(44): warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
4>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\sample\main.cpp(45): warning C4244: 'argument' : conversion from 'unsigned int' to 'float', possible loss of data
4>C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-sfeMovie2\sample\main.cpp(45): warning C4244: 'argument' : conversion from 'const int' to 'float', possible loss of data
4>LINK : fatal error LNK1181: cannot open input file '..\bin\sfeMovie.lib'
4>
4>Build FAILED.
4>
4>Time Elapsed 00:00:01.06
5>------ Rebuild All started: Project: ALL_BUILD, Configuration: Release Win32 ------
5>Build started 2014-05-20 Tue PM 3:14:38.
5>PrepareForBuild:
5>  Creating directory "Win32\Release\ALL_BUILD\ALL_BUILD.tlog\".
5>InitializeBuildStatus:
5>  Creating "Win32\Release\ALL_BUILD\ALL_BUILD.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
5>CustomBuild:
5>  Building Custom Rule C:/Users/Daegon/Desktop/Maydev/projects-main/Light.vn(dev)/external(src.lib)/sfeMovie-sfeMovie2/CMakeLists.txt
5>  CMake does not need to re-run because C:\Users\Daegon\Desktop\Maydev\projects-main\Light.vn(dev)\external(src.lib)\sfeMovie-build\CMakeFiles\generate.stamp is up-to-date.
5>  Build all projects
5>FinalizeBuildStatus:
5>  Deleting file "Win32\Release\ALL_BUILD\ALL_BUILD.tlog\unsuccessfulbuild".
5>  Touching "Win32\Release\ALL_BUILD\ALL_BUILD.tlog\ALL_BUILD.lastbuildstate".
5>
5>Build succeeded.
5>
5>Time Elapsed 00:00:00.15
========== Rebuild All: 2 succeeded, 3 failed, 0 skipped ==========

Judging from the output, it seems that

2>  /bin/sh: -c: line 0: syntax error near unexpected token `dev'
2>  /bin/sh: -c: line 0: `/C/Users/Daegon/Desktop/Maydev/projects-main/Light.vn(dev)/external(src.lib)/sfeMovie-build/YASM-objects/yasm.exe -f win32  -DPREFIX -I./ -I/tmp/ffmpeg-02.26.2014// -Pconfig.asm -I /tmp/ffmpeg-02.26.2014/libavfilter/x86/ -M -o libavfilter/x86/af_volume.o /tmp/ffmpeg-02.26.2014/libavfilter/x86/af_volume.asm > libavfilter/x86/af_volume.d'
2>  make: *** [libavfilter/x86/af_volume.o] Error 2
2>  *** an error occured, aborting.

something to do with yasm might be the problem.

Any ideas what's happening?

Ceylo commented 10 years ago

Your build mode in Visual Studio does not match the CMAKE_BUILD_TYPE chosen with CMake :p Make sure you use Debug or Release in both cases.

hsdk123 commented 10 years ago

My CMAKE_BUILD_TYPE is set to 'Release'. My Visual Studio build was also done in Release.. Or at least I think it is. Can you elaborate?

1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Release Win32 ------

Ceylo commented 10 years ago

Well, actually your Visual Studio build has been done in Debug mode:

Rebuild All started: Project: ZERO_CHECK, Configuration: Debug Win32

But at configuration time you indeed selected Release, as this shows:

cl : Command line error D8016: '/O2' and '/RTC1' command-line options are incompatible

O2 is an optimization that I defined in sfeMovie's CMakeLists for the Release mode. I wonder if I can enable it only when Release is really selected within the IDE…

Ceylo commented 10 years ago

Ah, no. I'm mistaken. It can't find FFmpeg-binaries\lib\avformat.lib. Although I don't know why… I'll need to check this this evening :/

Can you open an issue for that? So that we don't go anymore off-topic here :)

hsdk123 commented 10 years ago

@Ceylo Thanks for looking in, will do so :)

Ceylo commented 10 years ago

This task is now finished. FFmpeg 2 has been used for some time and looks to work fine. sfeMovie is actually even using the latest minor version: 2.2.2 (at the time of writing this).

All sfeMovie1 features were successfully achieved with this new version (+ complete internal redesign) except one: checking if the media has an audio or video stream. I don't plan to to this for the first major release of sfeMovie 2.0. It can be added later without breaking the API and should be part of a more important feature: activating any audio / video stream among the one embedded in the media.