我有一个加载到内存中的 h264 视频文件,我尝试使用参数“imem-cat = 4”使用 imem 播放它,以便 vlc 将使用访问模块来解复用视频,并且 vlc 启动并接收我的 imem参数成功:
[0x7f38a0000e28] access_imem demux debug: Using get(0x404e1d), release(0x404e91), data(0x7fff5b4a9430), cookie("IMEM")
此类别还意味着我不必提供 DTS 和 PTS。 VLC 的 imem 模块没有很好的文档记录,但我在几个地方找到了提示,例如
https://forum.videolan.org/viewtopic.php?t=111917 https://forum.videolan.org/viewtopic.php?t=111917
在 python 中使用 libVLC 从内存中播放视频 https://stackoverflow.com/questions/19602790/play-video-using-libvlc-from-memory-in-python
我的 imem-get 函数只是在第一次调用时将缓冲区指针设置为视频数据,返回 0,在任何进一步的调用中,它返回 1 以指示没有更多数据:
int MyImemGetCallback (void *data,
const char *cookie,
int64_t *dts,
int64_t *pts,
unsigned *flags,
size_t * bufferSize,
void ** buffer)
{
ImemData* imem = (ImemData*)data;
cookie = imem->cookieString;
if(imem == NULL || imem->allBuffered==true) //indicate all data has been get()ted
return 1;
*buffer = (void*) imem->video;
bufferSize = (size_t*) &(imem->bytes);
imem->allBuffered=true;
return 0;
}
不幸的是,在第一次通话后我收到以下错误:
[0x189cb18] main input debug: Creating an input for 'imem://'
[0x189cb18] main input debug: using timeshift granularity of 50 MiB, in path '/tmp'
[0x189cb18] main input debug: `imem://' gives access `imem' demux `' path `'
[0x189cb18] main input debug: creating demux: access='imem' demux='' location='' file='(null)'
[0x7f2808000e28] main demux debug: looking for access_demux module matching "imem": 20 candidates
[0x7f2808000e28] access_imem demux debug: Using get(0x404e1d), release(0x404e91), data(0x7ffe0da3b940), cookie("h264")
[0x7f2808000e28] main demux debug: no access_demux modules matched
[0x189cb18] main input debug: creating access 'imem' location='', path='(null)'
[0x7f2808001958] main access debug: looking for access module matching "imem": 25 candidates
[0x7f2808001958] access_imem access debug: Using get(0x404e1d), release(0x404e91), data(0x7ffe0da3b940), cookie("h264")
[0x7f2808001958] main access debug: using access module "access_imem"
[0x7f2808000e28] main stream debug: Using block method for AStream*
[0x7f2808000e28] main stream debug: starting pre-buffering
[0x7f2808000e28] main stream error: cannot pre fill buffer
[0x7f2808001958] main access debug: removing module "access_imem"
[0x189cb18] main input warning: cannot create a stream_t from access
[0x17d7298] main libvlc debug: removing all interfaces
[0x17d7298] main libvlc debug: exiting
[0x17d7298] main libvlc debug: no exit handler
[0x17d7298] main libvlc debug: removing stats
由于某种原因,vlc 似乎无法访问视频数据,但错误消息不是很有帮助,并且通常指的是网络流而不是内存位置。
有没有人以这种方式成功使用 imem 或者对问题可能是什么有任何想法?该视频可以在 VLC 中完美地从磁盘播放。
谢谢你的帮助。
Edit
看起来物品界面实际上可能不支持这种方式播放。然而,libVLC 提供了 libvlc_media_t 和 livblc_media_new_callbacks ,这可以让我实现我想要的。如果我能正常工作,我会报告。