vlc通过http播放mp4文件的问题

zhang_jiang 2010-11-10 03:15:39
使用vlc通过http协议播放mp4文件是遇到下面的问题:
1. vlc通过access_http不断seek,导致播放不流畅,特别网络不好的情况下
2. 有时候音频卡住,有时候视音频都卡住

其中问题1应该是主要原因,导致了问题2的出现。

测试视频:
http://221.6.14.54/test.mp4

vlc日志输出主要部分(不断seek):
main debug: connection succeeded (socket = 1700)
access_http debug: protocol 'HTTP' answer code 206
access_http debug: Server: Apache/2.2.3 (Red Hat)
access_http debug: this frame size=164526
access_http debug: stream size=202203,pos=37677,remaining=164526
access_http debug: Connection: close
access_http debug: Content-Type: text/plain; charset=zh-CN
main debug: Buffering 91%
access_http debug: trying to seek to 9845
main debug: net: connecting to 192.168.1.209 port 88
main debug: connection succeeded (socket = 1700)
access_http debug: protocol 'HTTP' answer code 206
access_http debug: Server: Apache/2.2.3 (Red Hat)
access_http debug: this frame size=192358
access_http debug: stream size=202203,pos=9845,remaining=192358
access_http debug: Connection: close
access_http debug: Content-Type: text/plain; charset=zh-CN
main debug: Buffering 100%
access_http debug: trying to seek to 39725
main debug: net: connecting to 192.168.1.209 port 88
main debug: no usable vout present, spawning one
main debug: looking for text renderer module: 2 candidates
freetype debug: Building font databases.
main debug: connection succeeded (socket = 1700)
access_http debug: protocol 'HTTP' answer code 206
access_http debug: Server: Apache/2.2.3 (Red Hat)
access_http debug: this frame size=162478
access_http debug: stream size=202203,pos=39725,remaining=162478
access_http debug: Connection: close
access_http debug: Content-Type: text/plain; charset=zh-CN
access_http debug: trying to seek to 9845
main debug: net: connecting to 192.168.1.209 port 88
main debug: connection succeeded (socket = 1700)
access_http debug: protocol 'HTTP' answer code 206
access_http debug: Server: Apache/2.2.3 (Red Hat)
access_http debug: this frame size=192358
access_http debug: stream size=202203,pos=9845,remaining=192358
access_http debug: Connection: close
access_http debug: Content-Type: text/plain; charset=zh-CN
main debug: Stream buffering done (1300 ms in 66 ms)
freetype debug: Took 346000 microseconds
freetype debug: Using Arial as font from file C:/WINDOWS/fonts/arial.ttf
freetype debug: using fontsize: 2
main debug: using text renderer module "freetype"
main debug: TIMER module_need() : 348.000 ms - Total 348.000 ms / 1 intvls (Avg 348.000 ms)
main debug: looking for video filter2 module: 18 candidates
swscale debug: 32x32 chroma: YUVA -> 16x16 chroma: YUVA with scaling using Bicubic (good quality)
main debug: using video filter2 module "swscale"
main debug: TIMER module_need() : 1.000 ms - Total 1.000 ms / 1 intvls (Avg 1.000 ms)
main debug: looking for video filter2 module: 18 candidates
yuvp debug: YUVP to YUVA converter
main debug: using video filter2 module "yuvp"
main debug: TIMER module_need() : 0.000 ms - Total 0.000 ms / 1 intvls (Avg 0.000 ms)
main debug: window size: 384x288
main debug: Deinterlacing available
main debug: deinterlace 0, mode blend, is_needed 0
main debug: looking for video output module: 1 candidate
vout_wrapper debug: Opening vout display wrapper
main debug: looking for vout display module: 8 candidates
directx debug: creating Vout EventThread
directx debug: DirectXCreateWindow
main debug: looking for vout window hwnd module: 3 candidates
qt4 debug: requesting video...
qt4 debug: Video was requested 0, 0
qt4 debug: embedded video ready (handle 00020912)
main debug: using vout window hwnd module "qt4"
main debug: TIMER module_need() : 87.000 ms - Total 87.000 ms / 1 intvls (Avg 87.000 ms)
directx debug: created video sub-window
directx debug: Vout EventThread running
directx debug: disabling screen saver
directx debug: directx-device:
directx debug: DirectXEnumCallback: Mobile Intel(R) 4 Series Express Chipset Family, \\.\DISPLAY1
directx debug: selecting Mobile Intel(R) 4 Series Express Chipset Family, \\.\DISPLAY1
directx debug: screen dimensions (0x0,1280x800)
directx debug: DirectDraw Capabilities: overlay=1 yuvoverlay=1 can_deinterlace_overlay=1 colorkey=1 stretch=1 bltfourcc=1
main debug: VoutDisplayEvent 'resize' 392x315 window
directx debug: DirectXUpdateRects image_dst_clipped coords: 198,171,590,465
directx debug: DirectXUpdateRects image_src_clipped coords: 0,0,352,288
directx debug: YUV overlay surface created successfully
main debug: using vout display module "directx"
main debug: TIMER module_need() : 126.000 ms - Total 126.000 ms / 1 intvls (Avg 126.000 ms)
main debug: using video output module "vout_wrapper"
main debug: TIMER module_need() : 126.000 ms - Total 126.000 ms / 1 intvls (Avg 126.000 ms)
main debug: got 1 direct buffer(s)
main debug: pic render sz 352x288, of (0,0), vsz 352x288, 4cc I420, sar 12:11, msk r0x0 g0x0 b0x0
main debug: pic in sz 352x288, of (0,0), vsz 352x288, 4cc I420, sar 12:11, msk r0x0 g0x0 b0x0
main debug: pic out sz 352x288, of (0,0), vsz 352x288, 4cc I420, sar 12:11, msk r0x0 g0x0 b0x0
main debug: direct render, mapping render pictures 0-23 to system pictures 1-24
avcodec debug: using direct rendering
main debug: End of video preroll
main debug: Received first picture
main debug: Decoder buffering done in 452 ms
access_http debug: trying to seek to 39725
main warning: buffer is 62000 late, triggering upsampling
main debug: net: connecting to 192.168.1.209 port 88
main warning: timing screwed, stopping resampling
main warning: buffer is 111750 late, triggering upsampling
main debug: VoutDisplayEvent 'resize' 384x288 window
directx debug: DirectXUpdateRects image_dst_clipped coords: 198,161,582,449
directx debug: DirectXUpdateRects image_src_clipped coords: 0,0,352,288
main debug: Post-processing available
main warning: vlc_object_find_name(postproc) is not safe!
main debug: connection succeeded (socket = 1700)
access_http debug: protocol 'HTTP' answer code 206
access_http debug: Server: Apache/2.2.3 (Red Hat)
access_http debug: this frame size=162478
access_http debug: stream size=202203,pos=39725,remaining=162478
access_http debug: Connection: close
access_http debug: Content-Type: text/plain; charset=zh-CN
access_http debug: trying to seek to 9845
main debug: net: connecting to 192.168.1.209 port 88
main debug: connection succeeded (socket = 1700)
access_http debug: protocol 'HTTP' answer code 206
access_http debug: Server: Apache/2.2.3 (Red Hat)
access_http debug: this frame size=192358
main debug: VoutDisplayEvent 'resize' 427x288 window
access_http debug: stream size=202203,pos=9845,remaining=192358
directx debug: DirectXUpdateRects image_dst_clipped coords: 219,161,603,449
directx debug: DirectXUpdateRects image_src_clipped coords: 0,0,352,288
access_http debug: Connection: close
access_http debug: Content-Type: text/plain; charset=zh-CN
access_http debug: trying to seek to 40764
main debug: net: connecting to 192.168.1.209 port 88
main debug: connection succeeded (socket = 1700)
access_http debug: protocol 'HTTP' answer code 206
access_http debug: Server: Apache/2.2.3 (Red Hat)
access_http debug: this frame size=161439
access_http debug: stream size=202203,pos=40764,remaining=161439
access_http debug: Connection: close
access_http debug: Content-Type: text/plain; charset=zh-CN
access_http debug: trying to seek to 10357
main debug: net: connecting to 192.168.1.209 port 88
main debug: connection succeeded (socket = 1700)
access_http debug: protocol 'HTTP' answer code 206
access_http debug: Server: Apache/2.2.3 (Red Hat)
access_http debug: this frame size=191846
access_http debug: stream size=202203,pos=10357,remaining=191846
access_http debug: Connection: close
access_http debug: Content-Type: text/plain; charset=zh-CN
access_http debug: trying to seek to 40764
main debug: net: connecting to 192.168.1.209 port 88
main debug: connection succeeded (socket = 1700)
access_http debug: protocol 'HTTP' answer code 206
access_http debug: Server: Apache/2.2.3 (Red Hat)
access_http debug: this frame size=161439
access_http debug: stream size=202203,pos=40764,remaining=161439
access_http debug: Connection: close
access_http debug: Content-Type: text/plain; charset=zh-CN
access_http debug: trying to seek to 10357
main debug: net: connecting to 192.168.1.209 port 88
main debug: connection succeeded (socket = 1700)
access_http debug: protocol 'HTTP' answer code 206
access_http debug: Server: Apache/2.2.3 (Red Hat)
access_http debug: this frame size=191846
access_http debug: stream size=202203,pos=10357,remaining=191846
access_http debug: Connection: close
access_http debug: Content-Type: text/plain; charset=zh-CN
access_http debug: trying to seek to 40764
main debug: net: connecting to 192.168.1.209 port 88
main debug: connection succeeded (socket = 1700)
access_http debug: protocol 'HTTP' answer code 206
access_http debug: Server: Apache/2.2.3 (Red Hat)
access_http debug: this frame size=161439
access_http debug: stream size=202203,pos=40764,remaining=161439
access_http debug: Connection: close
access_http debug: Content-Type: text/plain; charset=zh-CN
access_http debug: trying to seek to 10357
main debug: net: connecting to 192.168.1.209 port 88
main debug: connection succeeded (socket = 1700)
access_http debug: protocol 'HTTP' answer code 206
access_http debug: Server: Apache/2.2.3 (Red Hat)
access_http debug: this frame size=191846
access_http debug: stream size=202203,pos=10357,remaining=191846
access_http debug: Connection: close
access_http debug: Content-Type: text/plain; charset=zh-CN


期待牛人帮忙!

ps. csdn帖子字数限制的厉害。log不能完整写入。试试上面的测试视频就能得到log了
...全文
1703 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhang_jiang 2010-11-15
  • 打赏
  • 举报
回复
忘了来结贴了。

改了时间戳问题依旧。

估计是vlc的http access有点问题
zhang_jiang 2010-11-11
  • 打赏
  • 举报
回复
嗯,我试试把时间戳间隔做均匀。

用rtsp over udp是ok的,用rtsp over tcp的话开始一段有问题,视频会回跳。
SoftSoftSoft2008 2010-11-11
  • 打赏
  • 举报
回复
可以用rtsp来播放视频哦。
tufaqing 2010-11-10
  • 打赏
  • 举报
回复
可能是时间戳误差太大了,看你的音视频时间戳蛮不均匀的。你先可以按照理论均匀地打时间戳(视频按照帧率,音频按照采样率),先不管同步,看播放器能不能流畅播放。
这个有点不好查,其实VLC本身播放控制也不是很理想的,也许你自己写个播放器就比较好了。
还有,你的H264视频好多解码器解码不了。
zhang_jiang 2010-11-10
  • 打赏
  • 举报
回复
我写文件的时候是根据音视频帧的dts顺序来写的。

另外,我写文件的时候尝试过2种机制:
1. 每一帧的第一个包来的时候作为包的dts
2. 组成一个完整帧的时间作为dts

出来的效果都是一样。

因为我刚开始学习mp4文件格式,不是很熟悉。

tufaqing 2010-11-10
  • 打赏
  • 举报
回复
文件时间戳同步OK也不一定行,要相近时间戳的音视频包尽量放在一起,不要偏差太远,因为网络是下一段解码一段的,不能将整个文件都缓存起来,如果偏差太大,音视频不能同时找到数据,就不能同时解码播放了。
zhang_jiang 2010-11-10
  • 打赏
  • 举报
回复
谢谢你的回复。

是的音视频时间戳我是根据本地时间和采样率计算出来的,所以不是固定的。
而音频比视频多1s是因为视频编码系统初始化需要1s多。我在mp4文件里面加了edts来保证视音频同步。
tufaqing 2010-11-10
  • 打赏
  • 举报
回复
应该是文件本身打包不均匀,看了一下音视频时间戳有点乱,音频比视频多1秒多。打包时尽量将音视频时间戳相近的放在一起,便于同时解码,否则缓冲区里面文件数据里面音视频时间相差太远,只能取其中一个解码,另外一个可能就要丢掉了。

2,543

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧