[libav-tools] Encoding and streaming raw h.264 over rtp

Luca Barbato lu_zero at gentoo.org
Thu Sep 11 12:03:30 CEST 2014


On 06/05/14 08:34, Janina Lautensack | Callom GmbH wrote:
> Hello,
> 
> I have a MJPEG video file that I want to encode into H.264 and stream
> it over rtp. If I save the encoded video into a file, all looks fine.
> The video has the right format and can be played. But if I want to
> stream the video, either the NAL prefix codes (0x00 0x00 0x00 0x01) of
> the frames are missing or the rtp header is missing. What am I doing
> wrong? 
> 
> *******
> 1st try - recording the encoded video: 
>       avconv -y -f image2pipe -c:v mjpeg -i video.mjpeg -vcodec
> libx264 -bf 0 -bsf:v h264_mp4toannexb -f h264 encoded.264
>      -> mediainfo encoded.264
>          General
>          Complete name : encoded.264
>          Video
>          Format               : AVC
>          Format profile : High at L3.0
>          [.]
>          Writing library  : x264 core 120 r2151 a3f4407
> 
> *******
> 2nd try - streaming the encoded video and force rtp output format -
> Problem: No NAL prefix codes (00 00 00 01)
>       avconv -y -f image2pipe -c:v mjpeg -i video.mjpeg -vcodec
> libx264 -bf 0 -bsf:v h264_mp4toannexb -f rtp rtp://10.100.1.10:22345
>     -> avconv version 10, Copyright (c) 2000-2014 the Libav
> developers[...]
> 	Input #0, image2pipe, from 'video.mjpeg':
> 	  Duration: N/A, bitrate: N/A
> 	    Stream #0.0: Video: mjpeg, yuvj420p, 704x576 [PAR 96:96
> DAR 11:9], 25 fps, 25 tbn
> 	[libx264 @ 0x3097f80] using SAR=1/1
> 	[libx264 @ 0x3097f80] using cpu capabilities: MMX2 SSE2Fast
> SSSE3 FastShuffle Cache64
> 	[libx264 @ 0x3097f80] profile High, level 3.0
> 	Output #0, rtp, to 'rtp://10.100.1.10:22345':
> 	  Metadata:
> 	    encoder         : Lavf55.12.0
> 	    Stream #0.0: Video: libx264, yuvj420p, 704x576 [PAR 96:96
> DAR 11:9], q=-1--1, 90k tbn, 25 tbc
> 	Stream mapping:
> 	  Stream #0:0 -> #0:0 (mjpeg -> libx264)
> 	SDP:
> 	v=0
> 	o=- 0 0 IN IP4 127.0.0.1
> 	s=No Name
> 	c=IN IP4 10.100.1.10
> 	t=0 0
> 	a=tool:libavformat 55.12.0
> 	m=video 22345 RTP/AVP 96
> 	a=rtpmap:96 H264/90000
> 	a=fmtp:96 packetization-mode=1
> 
> *******
> 3rd try - streaming the encoded video and force h264 output format -
> Problem: Rtp header missing. Input #0, image2pipe, from 'test1.mjpeg':
>       avconv -y -f image2pipe -c:v mjpeg -i video.mjpeg -vcodec
> libx264 -bf 0 -bsf:v h264_mp4toannexb -f h264 rtp://10.100.1.10:22345
>      -> Input #0, image2pipe, from 'video.mjpeg':
> 	  Duration: N/A, bitrate: N/A
> 	   Stream #0.0: Video: mjpeg, yuvj420p, 704x576 [PAR 96:96 DAR
> 11:9], 25 fps, 25 tbn
> 	[libx264 @ 0x1fa3f80] using SAR=1/1
> 	[libx264 @ 0x1fa3f80] using cpu capabilities: MMX2 SSE2Fast
> SSSE3 FastShuffle Cache64
> 	[libx264 @ 0x1fa3f80] profile High, level 3.0
> 	Output #0, h264, to 'rtp://10.100.1.10:22345':
> 	  Metadata:
> 	    encoder         : Lavf55.12.0
> 	    Stream #0.0: Video: libx264, yuvj420p, 704x576 [PAR 96:96
> DAR 11:9], q=-1--1, 90k tbn, 25 tbc
> 	Stream mapping:
> 	  Stream #0:0 -> #0:0 (mjpeg -> libx264)
> 	
> Thank you,
> Janina
> 

The correct format is rtp and if you do not force the use of annexb you
should have the extradata in the sdp, I tested using the rtsp
mini-server and seems working as should.

lu


More information about the libav-tools mailing list