[FFmpeg-user] how to ­get h264 stream from webc­am with hardware H264 en

Val Malykh valem at pochta.ru
Thu Dec 20 17:34:56 CET 2012


Срд 19 Дек 2012 03:45:20 +0400, Carl Eugen Hoyos  написал:
Val Malykh  writes:

> I have a webcam with hardware H264 encoding support and I'd 

> like to stream it with ffmpeg & ffserver. How can I get 

> hardware encoded h264 stream from camera with ffmpeg?

Does this patch help?

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

For future questions, please do not post information 

on external resources, always post the failing command 

line and complete, uncut console output in your mail.

And please remember not to top-post, Carl Eugen

_______________________________________________

ffmpeg-user mailing list

ffmpeg-user at ffmpeg.org

Thank you, Carl

I've applied the patch and recompile all the stuff. Now the output:
ubuntu at arm:~/ffmpeg$ ./ffmpeg -f video4linux2 -vcodec h264 -s 640x480 -r 15 -i /dev/video0 test2.h264
ffmpeg version 1.0.git Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec 20 2012 10:15:28 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --enable-libx264 --enable-gpl --prefix='~/ff'
  libavutil      52. 11.101 / 52. 11.101
  libavcodec     54. 79.100 / 54. 79.100
  libavformat    54. 44.100 / 54. 44.100
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 24.100 /  3. 24.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[video4linux2,v4l2 @ 0xc16650] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 28680.925819, bitrate: N/A
    Stream #0:0: Video: h264 (Constrained Baseline), yuvj420p, 640x480 [SAR 1:1 DAR 4:3], -2 kb/s, 15 tbr, 1000k tbn, 30 tbc
File 'test2.h264' already exists. Overwrite ? [y/N] y
using SAR=1/1
[libx264 @ 0xc17a90] using cpu capabilities: ARMv6 NEON
[libx264 @ 0xc17a90] profile High, level 2.2
Output #0, h264, to 'test2.h264':
  Metadata:
    encoder         : Lavf54.44.100
    Stream #0:0: Video: h264, yuvj420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 90k tbn, 15 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
Press [q] to stop, [?] for help
frame=    8 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/sframe=   15 fps= 14 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/sframe=   22 fps= 14 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/sframe=   29 fps= 14 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/sframe=   36 fps= 14 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/sframe=   43 fps=8.8 q=27.0 size=      38kB time=00:00:00.00 bitrate=   0.0kbits/frame=   44 fps=7.5 q=27.0 size=      40kB time=00:00:00.06 bitrate=4916.6kbits/frame=   45 fps=7.1 q=27.0 size=      41kB time=00:00:00.13 bitrate=2512.6kbits/frame=   47 fps=6.6 q=27.0 size=      52kB time=00:00:00.26 bitrate=1602.1kbits/frame=   48 fps=5.7 q=27.0 size=      53kB time=00:00:00.33 bitrate=1305.4kbits/

So it's using CPU to do the transcoding. When I' usin ffmpeg with -vcodec copy it gives only this:

frame=    8 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/sframe=   15 fps= 14 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/sframe=   22 fps= 14 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/sframe=   29 fps= 14 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/sframe=   36 fps= 14 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s

And the output file is empty.

Any suggestions?

Regards,

Valentin Malykh.

http://ffmpeg.org/mailman/listinfo/ffmpeg-user


More information about the ffmpeg-user mailing list