Gstreamer raw video AVI does not play in Media Player

I am using GStreamer on Windows XP to write a stream of raw (YUV) video to a sequence of AVI files. A simplified version of the pipeline I am using is shown below:

gst-launch -e -v videotestsrc pattern=smpte100 num-buffers=10 horizontal-speed=1 ! video/x-raw-yuv, format=(fourcc)UYVY, width=(int)640, height=(int)480, framerate=30/1 ! ffmpegcolorspace ! avimux ! multifilesink next-file=key-frame location="frame_%d.avi" index=1

The first problem I have is that the first file written has the file name “frame_d.avi”, ie the “%d” is being interpreted as “d” and so the Index is not getting substituted into the string. I am guessing that this is Unicode issue? For the moment I can work around this by modifying the source code for filesink, though I rather not do this if possible.

The second problem I have is that when I try viewing the AVI file in Windows Media Player I get the message:

“Windows Media Player cannot play the file. The Player might not support the file type or might not support the codec that was used to compress the file.”

When I try using the filesink element in the pipeline (instead of multifilesink) I can view the video in Media Player.

Looking at the file contents using a Hex editor I can see that when using multifilesink an AVI header has been written out followed by the YUV data:

5249464610030000415649204c495354f80200006864726c6176696838000000 3582000080969800000000000000000000000000000000000100000000000000 80020000e0010000000000000000000000000000000000004c49535494020000 7374726c73747268380000007669647359555932000000000000000000000000 010000001e000000000000000000000000000000000000000000000000000000 0000000073747266280000002800000080020000e00100000100100059555932 00b00400000000000000000000000000000000004a554e4b1802000004000000 0000000030306462000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000 000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000004c495354100000006f646d6c 646d6c6804000000000000004c495354040000006d6f76693030646200600900 eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80 eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80 eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80 eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80 eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80 eb80eb80eb80eb80eb80eb80eb80eb80eb80eb80eb48d289d2 10d292d210d292 d210d292d210d292d210d292d210d292d210d292d210d292d210d292d210d292 d210d292d210d292d210d292d210d292d210d292d210d292d210d292d210d292 d210d292d210d292d210d292d210d292d210d292d210d292d210d292d210d292 d210d292d210d292d210d292d210d292d210d292d210d292d210d292d210d292 d210d292d210d292d210d292d210d292d210d292d210d292d210d292d210d292 d210d292d210d292d210d292aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10 aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10 aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10 aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10 aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10 aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10aaa6aa10 aaa6aa1091369122913691229136912291369122913691229136912291369122 9136912291369122913691229136912291369122913691229136912291369122 9136912291369122913691229136912291369122913691229136912291369122 9136912291369122913691229136912291369122913691229136912291369122 9136912291 369122913691229136912291369122913691229136912291369122 91369122913691229136912291369122913691229136912291806a806aca6ade 6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade 6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade 6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade 6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade 6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade6aca6ade 6aca6ade6aca6ade6aca6ade6aca6ade6a9251e7515a51f0515a51f0515a51f0 515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0 515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0 515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0 515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0 515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0515a51f0 515a51f0515a51f029f0296e29f0296e29f0296e29f0296e29f0296e29f0296e 29f0296e29f0296e29f0296e29f0296e29f0296e29f0296e29f0296e29f0296e 29f0296e29f0296e29f0296e29f0296e29f 0296e29f0296e29f0296e29f0296e 29f0296e29f0296e29f0296e29f0296e29f0296e29f0296e29f0296e29f0296e 29f0296e29f0296e29f0296e29f0296e29f0296e29f0296e29f0296e29f0296e 29f0296e29f0296e29f0296e29f0296e29f0296e29f0296e29f0296e29f0296e

The header generated when I use filesink (and which plays correctly) looks like this:

5249464608c45d00415649204c495354f80200006864726c6176696838000000 35820000b840190100000000100000000a000000000000000100000000000000 80020000e0010000000000000000000000000000000000004c49535494020000 7374726c73747268380000007669647359555932000000000000000000000000 010000001e000000000000000a00000000600900000000000000000000000000 0000000073747266280000002800000080020000e00100000100100059555932 00b00400000000000000000000000000000000004a554e4b1802000004000000 0000000030306462000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000 000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000004c495354100000006f646d6c 646d6c68040000000a0000004c49535454c05d006d6f76693030646200600900

The data itself looks OK; apart from the fact that avimux has forced a conversion from UYUV to YUY2, which means I will need to modify avimux to support this.

Why does the header written out by multifilesink differ to the one written out by filesink, and why do these differences stop the video from playing?

Thanks in advance for any thoughts.


On the dos command promt you will need to write

location="frame_%%d.avi"

to escape the % char. Regarding your actual problem, multifilesink won't work this way for muxed content. You can use it for headerless content. avimux won't write a new header on subsequent parts. It would probably be easier to put the avimux ! filesink combo to a bin and on some event, send an eos tot he bin, set the bin to ready, change the filename and set it back to playing.

链接地址: http://www.djcxy.com/p/43936.html

上一篇: 使用复用器会破坏来自ALSA的输入

下一篇: Gstreamer原始视频AVI不能在Media Player中播放