vlc-4.0 video playback is not smooth

This forum is about all development around libVLC.
truekbcl
New Cone
New Cone
Posts: 2
Joined: 19 Aug 2020 06:59

vlc-4.0 video playback is not smooth

Postby truekbcl » 19 Aug 2020 11:06

Hi, everybody.
I am using vlc-4.0 dev daily build version, and the development language is c++. When I play video in dx11 mode, if I switch the audio track, the video playback is not smooth.
The video information is as follows:
codec name = H264 - MPEG-4 AVC (PART 10), profile = 77, level = 51, width = 1920, height = 1080, frame_rate=30
 
The audio information is as follows:
codec name = MPEG AAC AUDIO, channels = 2, sample rate = 48000, bit_rate(kb) = 46
 
If use libvlc_media_player_set_hwnd when using qt, this situation will not happen.
For video, the api I call is libvlc_video_set_output_callbacks.
To switch audio tracks, the api I call is libvlc_media_player_select_track.

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: vlc-4.0 video playback is not smooth

Postby mfkl » 02 Sep 2020 13:17

can you share logs and code? Can you find a build that doesn't have this problem?
https://mfkl.github.io

truekbcl
New Cone
New Cone
Posts: 2
Joined: 19 Aug 2020 06:59

Re: vlc-4.0 video playback is not smooth

Postby truekbcl » 10 Sep 2020 08:06

void play(const string & file)
{
const har * par[] = {
"--no-osd",
"--verbose=2",
};
int count = sizeof(par) / sizeof(char*);
_vlc = libvlc_new(count, par);

_player = libvlc_media_player_new(_vlc);

_dx11_render.crete();
libvlc_video_set_output_callbacks(
_player,
libvlc_video_engine_d3d11,
Setup_cb,
Cleanup_cb
Resize_cb,
UpdateOutput_cb,
Swap_cb,
StartRendering_cb,
nullptr,
nullptr,
SelectPlane_cb,
this);

// event manager
libvlc_event_manager_t *vlc_evt_man = libvlc_media_player_event_manager(_player);
libvlc_event_attach(vlc_evt_man, libvlc_MediaPlayerPlaying, on_vlc_event, this);
libvlc_event_attach(vlc_evt_man, libvlc_MediaPlayerEndReached, on_vlc_event, this);

string fs = string("file:///") + file;
libvlc_media_t * lm = libvlc_media_new_location(_vlc, fs.c_str());
libvlc_media_player_set_media(_player, _media);
libvlc_media_player_play(_player)
}

The above is my code.

I found a solution. If you call seek after switching the audio track, it can be played normally. But with libvlc_media_new_location, seek is very slow.
I tested the executable versions of 3.0 and 4.0 to play the same video, 3.0seek is fast, and 4.0 is very slow.
I switched to my own way of reading and writing files, that is, calling the libvlc_media_new_callbacks method, then the problem of slow seek is solved.
I guess that if you call libvlc_media_new_path, seek may be faster. But not sure.
I looked at the source code and found that the seek event was also sent when the audio track was changed, but for some reason, the playback became unsmooth.
Another problem is that when playing mpg files, the screen will always flash.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 15 guests