How to save incoming h264 stream without re-encoding?

garrett weaverg at email.arizona.edu
Mon May 14 19:00:28 PDT 2012


I'm trying to do the exact same thing. I stumbled upon a heap of unanswered
threads like these on my search, so I'll bump this one because it's most
similar to what I want to do.  

I'm trying to transmit H264 video in RTP packets, over UDP and then on the
receiving end reconvert the packets into an H264 stream and both output the
stream with ximagesink and save the h264 stream into a file. 

I can output the live stream to ximagesink just fine. Saving the stream is a
whole different ordeal. No matter what I do, I cannot save a stream to a
file. 

I'll start by posting my transmit script.
gst-launch-0.10 v4l2src ! queue ! 'video/x-raw-yuv,width=640,height=480' !
x264enc bitrate=500 speed-preset=superfast tune=zerolatency ! queue !
rtph264pay ! udpsink host=224.1.1.1 port=5010 auto-multicast=true

This is my most desired receiving script (it's supposed to both show the
video in a window and write the video to an avi file):
gst-launch-0.10 udpsrc multicast-group=224.1.1.1 auto-multicast=true
port=5010 caps='application/x-rtp, media=(string)video,
clock-rate=(int)90000, encoding-name=(string)H264,
sprop-parameter-sets=(string)\"Z0KAHukBQHpCAAAH0AAB1MAIAA\\=\\=\\,aM48gAA\\=\",
payload=(int)96, ssrc=(uint)3315029550, clock-base=(uint)3926529534,
seqnum-base=(uint)45576' ! gstrtpjitterbuffer drop-on-latency=true
latency=500  ! rtph264depay ! tee name=videosrc \
videosrc. ! queue ! ffdec_h264 ! ffmpegcolorspace ! ximagesink sync=false \
videosrc. ! queue ! avimux ! filesink location=video.avi

Unfortunately that doesn't work, doesn't throw any errors, but it doesn't
bring up the video window nor does it try to write a file. If I take out the
last line (the tee for printing out the file), it does bring up the video
window. If I take out the second to last line (the tee for displaying the
window) it creates the file, but it's zero bytes in size. 

My scripts do depend on the elements rtph264pay and rtph264depay which are
poorly documented. I thought that perhaps the output of rtph264depay doesn't
output an h264 format avimux likes. So I ran this script:
gst-launch-0.10 v4l2src ! queue ! 'video/x-raw-yuv,width=640,height=480' !
x264enc bitrate=500 speed-preset=superfast tune=zerolatency ! rtph264pay !
rtph264depay ! avimux ! filesink location=video.avi

Which doesn't work, it only writes a file of zero bytes large, but if I took
out the "rtph264pay ! rtph264depay !" part, it works fine. But what's more?
If I add "ffdec_h264 ! ffmpegcolorspace !" between rtph264depay and avimux
it does write a file (albeit a very large file). 

But then if I try to run this script as the receive script (just to try to
write a file):
gst-launch-0.10 udpsrc multicast-group=224.1.1.1 auto-multicast=true
port=5010 caps='application/x-rtp, media=(string)video,
clock-rate=(int)90000, encoding-name=(string)H264,
sprop-parameter-sets=(string)\"Z0KAHukBQHpCAAAH0AAB1MAIAA\\=\\=\\,aM48gAA\\=\",
payload=(int)96, ssrc=(uint)3315029550, clock-base=(uint)3926529534,
seqnum-base=(uint)45576' ! gstrtpjitterbuffer drop-on-latency=true
latency=500  ! rtph264depay ! ffdec_h264 ! ffmpegcolorspace ! tee
name=videosrc \
videosrc. ! queue ! avimux ! filesink location=video.avi

It does not work. So what is the deal here? Is there any way to write video
from a h264 stream? 

--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-save-incoming-h264-stream-without-re-encoding-tp1559487p4633660.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list