f***8 发帖数: 641 | 1 我想在一个机器上把mpg文件stream出去,我来本版询问大家推荐了gstreamer。
我的目的就是我想在一个机器上把mpg文件stream出去,但是这个stream里要能改codec
的属性,比如P-frame的rate什么的。在另一台机器上接受这个stream播放出来。
于是我就试了一下gstreamer。我实在是对linux一窍不通阿,总遇到error。
google出来的几个结果我也不动阿。
比如:我在当前文件夹下,有个子文件夹叫做video,这个video文件夹里面有一个视频
叫做1.MPG。我现在就是想把这个视频stream出去,我就按照google的结果试了一下:
gst-launch v4l2src ! video/1.MPG,width=640,height=480,framerate=\(fraction\)
5/1 ! ffmpegcolorspace ! jpegenc ! multipartmux ! tcpserversink host=192.168
.2.1 port=5000
结果报错:
(gst-launch-0.10:9145): GLib-WARNING **: g_set_prgname() called multiple
times
WARNING: erroneous pipeline: could not link v4l2src0 to ffmpegcsp0
求助!谢谢! | r****t 发帖数: 10904 | 2 gst-launch filesrc location=1.MPG ! decodebin ! video/x-raw-yuv, width=640,
height=480,framerate=5/1 ! ffmpegcolorspace ! jpegenc ! multipartmux !
tcpserversink host=192.168.2.1 port=5000
streaming 我自己只试过 shout2send, 不过 tcpserver 应该差不太多。 | f***8 发帖数: 641 | 3 多谢!我上一个帖子就是你回复的:)
我也加入了gstreamer的emial list,有不懂的也要问问他们。
【在 r****t 的大作中提到】 : gst-launch filesrc location=1.MPG ! decodebin ! video/x-raw-yuv, width=640, : height=480,framerate=5/1 ! ffmpegcolorspace ! jpegenc ! multipartmux ! : tcpserversink host=192.168.2.1 port=5000 : streaming 我自己只试过 shout2send, 不过 tcpserver 应该差不太多。
| f***8 发帖数: 641 | 4 谢谢!这个works。
在另一台ubuntu PC上,我用
“gst-launch tcpclientsrc host=130.160.47.62 port=5002 ! multipartdemux !
jpegdec ! autovideosink“
接收这个stream,能播放。
但是我的目的是:
1.MPG这个视频的framerate是25,但是我想把它有时候改成20,有时候改成10。甚至还
要更改I-frame,B-frame和p-frame的rate。那这该怎么实现呢?
有人说要“put a videoscale element between decodebin and the caps filter”,
那我具体啊该怎么做呢?
谢谢!!!
【在 r****t 的大作中提到】 : gst-launch filesrc location=1.MPG ! decodebin ! video/x-raw-yuv, width=640, : height=480,framerate=5/1 ! ffmpegcolorspace ! jpegenc ! multipartmux ! : tcpserversink host=192.168.2.1 port=5000 : streaming 我自己只试过 shout2send, 不过 tcpserver 应该差不太多。
| r****t 发帖数: 10904 | 5 我给你那行里面直接改 framerate=25/1, or framerate=20/1 就行了。
B-frame 这些和具体 codec 有关,需要改 encoder element 的参数,具体来说,
gst-inspect theoraenc 把 theoraenc 换成你需要用的 encoder。
【在 f***8 的大作中提到】 : 谢谢!这个works。 : 在另一台ubuntu PC上,我用 : “gst-launch tcpclientsrc host=130.160.47.62 port=5002 ! multipartdemux ! : jpegdec ! autovideosink“ : 接收这个stream,能播放。 : 但是我的目的是: : 1.MPG这个视频的framerate是25,但是我想把它有时候改成20,有时候改成10。甚至还 : 要更改I-frame,B-frame和p-frame的rate。那这该怎么实现呢? : 有人说要“put a videoscale element between decodebin and the caps filter”, : 那我具体啊该怎么做呢?
| f***8 发帖数: 641 | 6 不行啊。。。我右键单击得到那个视频的属性是framerate=25.
我试了把你给我的那个改成framerate=20/1就报错,但是改成framerate=25/1就OK。
你给我的那个是这样的:
gst-launch filesrc "location=1.MPG" ! decodebin ! video/x-raw-yuv, width=640
,height=480,framerate=25/1 ! ffmpegcolorspace ! jpegenc ! multipartmux !
tcpserversink host=192.168.2.1 port=5006
这个运行OK。但是如果直接写成framerate=25/1就报错。
于是我加了"!videoscale!"在decodebin和cap之间,又把framerate改成15:
gst-launch filesrc "location=1.MPG" ! decodebin ! videoscale ! video/x-raw-
yuv, width=640,height=480,framerate=15/1 ! ffmpegcolorspace ! jpegenc !
multipartmux ! tcpserversink host=192.168.2.1 port=5006
然后就报错,错误行数太多,我就写在这个帖子的末尾吧:)
下面这个也不行:
gst-launch -v filesrc location=1.MPG ! decodebin ! videoscale ! video/x-raw-
yuv, width=640,height=480,framerate=15/1 ! ffmpegcolorspace ! xvimagesink !
下面的这些行是前面第三段提到的报错,因为行数比较多,所以我写在了末尾:
(gst-launch-0.10:11600): GLib-WARNING **: g_set_prgname() called multiple
times
Setting pipeline to PAUSED ...
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind.
GstPad:src: caps = video/mpeg, systemstream=(boolean)true, mpegversion=(int)
2
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMpegPSDemux:mpegpsdemux0.
GstPad:sink: caps = video/mpeg, systemstream=(boolean)true, mpegversion=(int
)2
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQueue:queue0.GstPad:sink:
caps = video/mpeg, mpegversion=(int)2, systemstream=(boolean)false
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQueue:queue1.GstPad:sink:
caps = audio/mpeg, mpegversion=(int)1
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQueue:queue0.GstPad:src:
caps = video/mpeg, mpegversion=(int)2, systemstream=(boolean)false
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/MpegVideoParse:
mpegvideoparse0.GstPad:sink: caps = video/mpeg, mpegversion=(int)2,
systemstream=(boolean)false
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQueue:queue1.GstPad:src:
caps = audio/mpeg, mpegversion=(int)1
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMPEGAudioParse:
mpegaudioparse0.GstPad:sink: caps = audio/mpeg, mpegversion=(int)1
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/MpegVideoParse:
mpegvideoparse0.GstPad:src: caps = video/mpeg, systemstream=(boolean)false,
parsed=(boolean)true, mpegversion=(int)2, width=(int)640, height=(int)480,
framerate=(fraction)25/1, pixel-aspect-ratio=(fraction)1/1, interlaced=(
boolean)false, codec_data=(buffer)
000001b32801e013ffffe090000001b5148a00010000
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMpeg2dec:mpeg2dec0.GstPad:
sink: caps = video/mpeg, systemstream=(boolean)false, parsed=(boolean)true,
mpegversion=(int)2, width=(int)640, height=(int)480, framerate=(fraction)25/
1, pixel-aspect-ratio=(fraction)1/1, interlaced=(boolean)false, codec_data=(
buffer)000001b32801e013ffffe090000001b5148a00010000
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQueue:queue0: max-size-
bytes = 20240
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:src0: caps =
video/x-raw-yuv, format=(fourcc)I420, width=(int)640, height=(int)480, pixel
-aspect-ratio=(fraction)1/1, framerate=(fraction)25/1, interlaced=(boolean)
false
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMpeg2dec:mpeg2dec0.GstPad:
src: caps = video/x-raw-yuv, format=(fourcc)I420, width=(int)640, height=(
int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)25/1,
interlaced=(boolean)false
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMpeg2dec:mpeg2dec0.GstPad:
src: caps = video/x-raw-yuv, format=(fourcc)I420, width=(int)640, height=(
int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)25/1,
interlaced=(boolean)false
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/FluMp3Dec:flump3dec0.GstPad:
sink: caps = audio/mpeg, mpegversion=(int)1, mpegaudioversion=(int)1, layer=
(int)3, rate=(int)44100, channels=(int)2, parsed=(boolean)true
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:src1: caps =
audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16,
depth=(int)16, rate=(int)44100, channels=(int)2
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/FluMp3Dec:flump3dec0.GstPad:
src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true,
width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:decodebin0/
GstMpegPSDemux:mpegpsdemux0: Internal data stream error.
Additional debug info:
gstmpegdemux.c(2734): gst_flups_demux_loop (): /GstPipeline:pipeline0/
GstDecodeBin:decodebin0/GstMpegPSDemux:mpegpsdemux0:
stream stopped, reason not-negotiated
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:src1: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstGhostPad:src0: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/FluMp3Dec:flump3dec0.GstPad:
src: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/FluMp3Dec:flump3dec0.GstPad:
sink: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMPEGAudioParse:
mpegaudioparse0.GstPad:src: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMPEGAudioParse:
mpegaudioparse0.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQueue:queue1.GstPad:src:
caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQueue:queue1.GstPad:sink:
caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMpeg2dec:mpeg2dec0.GstPad:
src: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMpeg2dec:mpeg2dec0.GstPad:
sink: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/MpegVideoParse:
mpegvideoparse0.GstPad:src: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/MpegVideoParse:
mpegvideoparse0.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQueue:queue0.GstPad:src:
caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstQueue:queue0.GstPad:sink:
caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMpegPSDemux:mpegpsdemux0.
GstPad:audio_c0: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMpegPSDemux:mpegpsdemux0.
GstPad:video_e0: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstMpegPSDemux:mpegpsdemux0.
GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind.
GstPad:src: caps = NULL
【在 r****t 的大作中提到】 : 我给你那行里面直接改 framerate=25/1, or framerate=20/1 就行了。 : B-frame 这些和具体 codec 有关,需要改 encoder element 的参数,具体来说, : gst-inspect theoraenc 把 theoraenc 换成你需要用的 encoder。
| r****t 发帖数: 10904 | 7 videoscale 换成 videorate 应该行了
640
【在 f***8 的大作中提到】 : 不行啊。。。我右键单击得到那个视频的属性是framerate=25. : 我试了把你给我的那个改成framerate=20/1就报错,但是改成framerate=25/1就OK。 : 你给我的那个是这样的: : gst-launch filesrc "location=1.MPG" ! decodebin ! video/x-raw-yuv, width=640 : ,height=480,framerate=25/1 ! ffmpegcolorspace ! jpegenc ! multipartmux ! : tcpserversink host=192.168.2.1 port=5006 : 这个运行OK。但是如果直接写成framerate=25/1就报错。 : 于是我加了"!videoscale!"在decodebin和cap之间,又把framerate改成15: : gst-launch filesrc "location=1.MPG" ! decodebin ! videoscale ! video/x-raw- : yuv, width=640,height=480,framerate=15/1 ! ffmpegcolorspace ! jpegenc !
| f***8 发帖数: 641 | 8 果然好使了!谢谢:)
你说更改I、B、P-frame需要改 encoder element 的参数:
gst-inspect theoraenc 把 theoraenc 换成需要用的 encoder
我怎么google不到这样的例子呀,自己猜来猜去太费劲了。。。能麻烦你发个链接之类
的吗?
【在 r****t 的大作中提到】 : videoscale 换成 videorate 应该行了 : : 640
| r****t 发帖数: 10904 | 9 google 的第一个结果就是 http://gstreamer.freedesktop.org/documentation/
把前三个 HTML 文档读了,后面的一边用一边查。
【在 f***8 的大作中提到】 : 果然好使了!谢谢:) : 你说更改I、B、P-frame需要改 encoder element 的参数: : gst-inspect theoraenc 把 theoraenc 换成需要用的 encoder : 我怎么google不到这样的例子呀,自己猜来猜去太费劲了。。。能麻烦你发个链接之类 : 的吗?
|
|