Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to stream h264 video from my Logitech C920 webcam. I'm using such ffserver.conf:

Port 8099

NoDaemon

BindAddress 0.0.0.0


RTSPPort 5004
RTSPBindAddress 0.0.0.0

MaxClients 10

MaxBandwidth 10000

CustomLog -


<Feed feed1.ffm>
        File /tmp/feed1.ffm
        FileMaxSize 20M
</Feed>

<Stream viewport1>
        Feed feed1.ffm
        Format rtp
        VideoCodec libx264
        VideoFrameRate 15
        VideoBufferSize 40
        VideoBitRate 3000
        VideoQMin 1
        VideoQMax 31
        VideoSize 640x480
        PreRoll 0
        NoAudio
        Strict -1
</Stream>

<Stream stat.html>
        Format status
</Stream>

<Redirect index.html>
        URL http://ffmpeg.sourceforge.net/
</Redirect>

And I'm starting ffmpeg like this:

./ffmpeg -f video4linux2 -s 640x480 -r 15 -re -i /dev/video0 -an -vcodec libx264  -bf 5  http://localhost:8099/feed1.ffm

But in the output there is:

[video4linux2,v4l2 @ 0xc0b5e0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 2930.711051, bitrate: 73728 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 73728 kb/s, 15 tbr, 1000k tbn, 15 tbc
[libx264 @ 0xc183f0] using cpu capabilities: ARMv6 NEON
[libx264 @ 0xc183f0] VBV buffer size cannot be smaller than one frame, using 400 kbit
[libx264 @ 0xc183f0] profile High 4:2:2, level 2.2, 4:2:2 8-bit
[libx264 @ 0xc183f0] 264 - core 120 r2151 a3f4407 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=5 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=1 weightp=2 keyint=50 keyint_min=5 scenecut=0 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=3000 ratetol=1.0 qcomp=0.50 qpmin=10 qpmax=51 qpstep=4 vbv_maxrate=6000 vbv_bufsize=400 nal_hrd=none ip_ratio=1.40 aq=1:1.00
Output #0, ffm, to 'http://localhost:8099/feed1.ffm':
  Metadata:
    creation_time   : now
    encoder         : Lavf54.44.100
    Stream #0:0: Video: h264, yuv422p, 640x480, q=10-51, 3000 kb/s, 1000k tbn, 15 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> libx264)
Press [q] to stop, [?] for help
[libx264 @ 0xc183f0] VBV buffer size cannot be smaller than one frame, using 400 kbit
frame=   12 fps=0.0 q=0.0 size=       4kB time=00:00:00.00 bitrate=   0.0kbits/sframe=   22 fps= 20 q=0.0 size=       4kB time=00:00:00.00 bitrate=   0.0kbits/sframe=   30 fps= 19 q=0.0 size=       4kB time=00:00:00.00 bitrate=   0.0kbits/sframe=   38 fps= 18 q=0.0 size=       4kB time=00:00:00.00 bitrate=   0.0kbits/s

Any suggestion how not to do transcoding and stream the video directly?

share|improve this question
    
Your question seems to contradicts itself. "I'm trying to stream h264 video" with "Any suggestion how not to do transcoding". What is it you want? –  gertvdijk Dec 17 '12 at 14:23
    
Apparently, this webcam should be able to output h264 directly, so there should be no transcoding needed... I suppose that's the gist of the question –  sr_ Dec 17 '12 at 14:54
    
Yeah, sr_ understands correctly. I'm sorry for my poor English, if it's a reason of this misunderstanding. –  Val Dec 17 '12 at 14:59
    
Random guess, can you specify a video codec of copy? That works with other ffmpeg stuff, but I've never used ffserver. –  derobert Dec 17 '12 at 17:14
1  
I'm successfully streaming video in MJPEG directly from camera. With H264 there is a problem in ffmpeg itself as far as I understand. ffmpeg.org/trac/ffmpeg/ticket/1387 –  Val Dec 18 '12 at 14:14
show 2 more comments

1 Answer

Actually I've succeed with streaming of h264 video with ffmpeg. I was able to do this with help from ffmpeg-user list, especially from Carl Eugen Hoyos, author of this patch:

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c 
index cd6aeb2..c3f813d 100644 
--- a/libavdevice/v4l2.c 
+++ b/libavdevice/v4l2.c 
@@ -150,6 +150,7 @@ static struct fmt_map fmt_conversion_table[] = { 
 { AV_PIX_FMT_NV12, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_NV12 }, 
 { AV_PIX_FMT_NONE, AV_CODEC_ID_MJPEG, V4L2_PIX_FMT_MJPEG }, 
 { AV_PIX_FMT_NONE, AV_CODEC_ID_MJPEG, V4L2_PIX_FMT_JPEG }, 
+ { AV_PIX_FMT_NONE, AV_CODEC_ID_H264, V4L2_PIX_FMT_H264 }, 
 #ifdef V4L2_PIX_FMT_CPIA1 
 { AV_PIX_FMT_NONE, AV_CODEC_ID_CPIA, V4L2_PIX_FMT_CPIA1 }, 
 #endif

Actual command I've used:

./ffmpeg -f video4linux2 -s 640x480 -r 15 -vcodec h264 -i /dev/video0 -an http://localhost:8099/feed1.ffm

But I wasn't able to get rid of transcoding, so I switched to vlc (and succeed).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.