[osg-users] OsgMovie ffmpeg and audio (SDL2) - Audio seems to make video slower. Audio has hiccoughing

120 views
Skip to first unread message

Andrea Martini

unread,
Jun 11, 2018, 10:36:28 AM6/11/18
to osg-...@lists.openscenegraph.org
Hi everyone,
i'm using osg3.5.6 on visual studio 2013 (windows 10), and i'm using ffmpeg plugin combined with SDL2 to play video and audio streaming with osgmovie example.
If i don't use SDL2 (no audio), video streaming works fine.
If i add SDL2 (audio), i get two bad results:
1) video stream get slower
2) Audio has hiccoughing

I tryied with some video examples (with different resolutions) but i get the same result.

Following, i report audio streaming output displayed on the console:

ffmpeg::open(C:\Movie\surfers_360.mp4) size(2048, 1024) aspect ratio 1
Attaching FFmpegAudioStream
AudioStream read []
FFmpegAudioStream::setAudioSink( 00000277C50FEEE0)
Assigning 00000277C50FEEE0
image->s()2048 image-t()=1024 aspectRatio=1
SDLAudioSink()::startPlaying()
audioFrequency()=48000
audioNbChannels()=2
audioSampleFormat()=4
SampleFormat = SAMPLE_FORMAT_F32

I'm wondering if i should continue with ffmpeg and sdl libraries, or i have to look at another one. In this last case, could you suggest me some way to follow? (link, examples, ...)

Thank you!

Cheers,
Andrea

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74033#74033





_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Voerman, L.

unread,
Jun 11, 2018, 11:09:05 AM6/11/18
to OpenSceneGraph Users
Hi Andrea,
did you have a look at the load on the cpu cores? The slowdown seems to indicate a cpu core hitting 100% load.
Regards, Laurens.

Andrea Martini

unread,
Jun 11, 2018, 11:33:06 AM6/11/18
to osg-...@lists.openscenegraph.org
Hi Voerman,
thank you for your fast replay.
I looked at post you suggested, and i downloaded (and compiled) the FFmpegDecoderVideo.zip
Unfortunally, i get the same result.
Following i attached some graphical information about stats and CPU usage.

Cheers,
Andrea

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74038#74038



OsgMovieFFMPEG_SDL.jpg

Voerman, L.

unread,
Jun 11, 2018, 11:41:53 AM6/11/18
to OpenSceneGraph Users
Hi Andrea,
To display the usage of the cpu cores in the task viewer you need to right click the cpu graph, select "Change graph to" and select "Logical Processors".
From "overall usage" we cannot see if that's one core at 100% and the rest near zero or something else.
Laurens.

Andrea Martini

unread,
Jun 12, 2018, 3:26:02 AM6/12/18
to osg-...@lists.openscenegraph.org
Hi Laurens,
sorry for my mistake. I attached the detailed snapshot of both rendering window (with stats) and CPUs usage.
Frame rate is good (60Hz), but i continue to get a bad audio and to get a video play slower.
I would like to underline that if i play this video with a player like VLC, all works fine.
Another detail about osgmovie example with SDL2 (when i play a video stream .mp4 with audio) is the following: i get a good quality for the first 3 or 4 seconds of video, and then i start to get audio hiccoughing and video slower.
I don't know if problem could be focused on some streaming buffer (audio and video) management.

Thank you!

Cheers,
Andrea

PS:

i downloaded SDL2 from: https://www.libsdl.org/download-2.0.php
SDL2-devel-2.0.8-VC.zip (Visual C++ 32/64-bit) I'm using 64bit version

About ffmpeg, i downloaded from: https://ffmpeg.zeranoe.com/builds/
version 4.0
Windows 64bit

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74043#74043



OsgMovieFFMPEG_SDL_details.jpg

Voerman, L.

unread,
Jun 12, 2018, 9:28:00 AM6/12/18
to OpenSceneGraph Users
Hi Andrea,
The ffmpeg version I was using did not have this problem, (ffmpeg-20160517-git-af3e944-win64-shared)
but after updating to ffmpeg-4.0 I could hear and see the problem as well.
I've tried ffmpeg versions 3.4.2 and 3.2 as well - still problems,
found a binary version of 3.0 here (build 2016-02-08) - that works.
I don't have a build setup for ffmpeg yet, so I can't dig down to the actual problem, but I hope finding a working version helps you along.

Laurens.


Andrea Martini

unread,
Jun 12, 2018, 10:31:31 AM6/12/18
to osg-...@lists.openscenegraph.org
Hi Lauren,
GREAT!!! It's works!
Using the 3.0 version of ffmepg, i can play both video and audio correctly.
Thank you a lot!

Cheers,
Andrea

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74055#74055

Javier Taibo

unread,
Jun 12, 2018, 2:25:53 PM6/12/18
to OpenSceneGraph Users
  Hi,

  Try replacing m_context->time_base by m_stream->time_base in FFmpegDecoderVideo::decodeLoop() (FFmpegDecoderVideo.cpp)

  This should solve your problem with FFMPEG versions after 3.0


  Cheers!


Reply all
Reply to author
Forward
0 new messages