Sponsored Content
Top Forums UNIX for Advanced & Expert Users Ffmpeg (avconv) + crtmpserver Linux streaming video, no player to play it Post 302843812 by +Yan on Thursday 15th of August 2013 07:56:56 AM
Old 08-15-2013
Ffmpeg (avconv) + crtmpserver Linux streaming video, no player to play it

Hello Linux experts,

I'm working on live video streaming project, and my job is to create video streaming server using
Ubuntu 13.04
Here is what I've done so far:
1. Installed crtmpserver from Ubuntu's repositories.
2. Installed ffmpeg

To test the server i use webcam as source of video, and the following command:
avconv -f video4linux2 -i /dev/video0 -f flv -an -metadata streamName="test" tcp://localhost:6666


The command output is:

Code:
avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
  built on Mar 30 2013 22:20:06 with gcc 4.7.2
[video4linux2 @ 0x25b79e0] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2, from '/dev/video0':
  Duration: N/A, start: 14840.930660, bitrate: 147456 kb/s
    Stream #0.0: Video: rawvideo, yuyv422, 640x480, 147456 kb/s, 30 tbr, 1000k tbn, 30 tbc
Incompatible pixel format 'yuyv422' for codec 'flv', auto-selecting format 'yuv420p'
[buffer @ 0x25b92e0] w:640 h:480 pixfmt:yuyv422
[avsink @ 0x25a5160] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x25a5840] w:640 h:480 fmt:yuyv422 -> w:640 h:480 fmt:yuv420p flags:0x4
Output #0, flv, to 'tcp://localhost:6666':
  Metadata:
    streamName      : test
    encoder         : Lavf53.21.1
    Stream #0.0: Video: flv, yuv420p, 640x480, q=2-31, 200 kb/s, 1k tbn, 30 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> flv)
Press ctrl-c to stop encoding


So far so good, BUT when I try to play the stream with mplayer from another console with the command:
mplayer rtmp://localhost/live/test mplayer is stalled for very long time (10-15 min.) before the video starts.

If in the meantime I terminate the avconv command, the video is being shown immediately by mplayer.
I tryied the following mplayer options without success:
-nosound
-nocache
different combinations of -cachie N

I had success with this flash player: Flash RTMP Player - Live Video Streaming
But there is about 3 sec. delay which is too much for me.


Please advice me how can I make mplayer play the video as soon as possible ?

Here is the mplayer output:
Code:
mplayer rtmp://localhost/live/test

MPlayer2 UNKNOWN (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing rtmp://localhost/live/test.
Forced lavf FLV format demuxer
Detected file format: libavformat

Thank you in advance.
 

We Also Found This Discussion For You

1. Programming

Video/Audio Streaming in C?

Hi Folks, I have just joined, and have a problem... I am doing my thesis and need to transfer a file from server to the client, while doing that I want to stream the file ( the files being video/audio files). I am unable to figure out abt the streaming part...if there exist any libraries... (0 Replies)
Discussion started by: pappu
0 Replies
VIDEO(4)						   BSD Kernel Interfaces Manual 						  VIDEO(4)

NAME
video -- device-independent video driver layer SYNOPSIS
#include <sys/videoio.h> DESCRIPTION
The video driver provides support for various video peripherals. It provides a uniform programming interface layer above different underly- ing video hardware drivers. The video layer provides a Video4Linux2 compatible API. A number of ioctl(2) commands are supported controlling the device. See http://v4l2spec.bytesex.org/ for the official V4L2 specification. The device file for video operation is /dev/video. READING VIDEO SAMPLES
Video data is separated into logical video samples which will typically be one complete video frame. With compressed formats, a video sample may be one logical chunk and not one complete frame depending on the compression format. Video samples may be read from /dev/video in one of several different modes. In read mode, calls to read(2) will return at most the data of one video sample. If the entire sample is not read, then subsequent reads will return at most the remaining data in that video sample. Video samples may be mapped into memory with mmap(2). The driver allocates internal buffers for a number of video samples which are mapped into memory. Initiating this mode requires several ioctl(2) commands: VIDIOC_REQBUFS to request the driver reserve buffers, VIDIOC_QUERYBUF to query the details of each buffer, mmap(2) to map each buffer into memory, VIDIOC_QBUF to queue the buffers for receiving video data, VIDIOC_STREAMON to begin streaming of video data, and VIDIOC_DQBUF to remove a filled buffer from the queue. At this point the video data from the dequeued buffer is valid. DEVICE CAPABILITIES
VIDIOC_QUERYCAP (struct v4l2_capability) This command queries the capabilities of the device. The first three fields are informational NULL terminated strings filled by the driver: driver describes the driver used by this device, card describes the video capture card or camera, and buf_info represents the bus to which the hardware device is attached. The capabilities field contains a number of flags indicating various features supported by the driver or hardware: V4L2_CAP_VIDEO_CAPTURE support video capturing V4L2_CAP_READWRITE supports the read(2) and/or write(2) mode V4L2_CAP_STREAMING supports mmap(2) mode struct v4l2_capability { uint8_t driver[16]; uint8_t card[32]; uint8_t bus_info[32]; uint32_t version; uint32_t capabilities; uint32_t reserved[4]; }; STREAMING INTERFACE
VIDIOC_REQBUFS (struct v4l2_requestbuffers) This command requests that the driver reserve space for count samples. type must be set to V4L2_BUF_TYPE_VIDEO_CAPTURE and memory to V4L2_MEMORY_MMAP. The returned count represents the actual number of samples reserved which may be more or fewer than requested. struct v4l2_requestbuffers { uint32_t count; enum v4l2_buf_type type; enum v4l2_memory memory; uint32_t reserved[2]; }; VIDIOC_QUERYBUF (struct v4l2_buffer) This command should be called for each buffer in count above. The fields index, type, and memory must be set to a valid index from 0 to count-1, and the same type and memory as used in VIDIOC_QUERYBUF. The driver returns m.offset and length. struct v4l2_buffer { uint32_t index; enum v4l2_buf_type type; uint32_t bytesused; uint32_t flags; enum v4l2_field field; struct timeval timestamp; struct v4l2_timecode timecode; uint32_t sequence; enum v4l2_memory memory; union { uint32_t offset; unsigned long userptr; } m; uint32_t length; uint32_t input; uint32_t reserved; }; mmap(2) Each buffer must be mapped with a call to mmap(2), passing the length and m.offset values obtained above. The prot PROT_READ|PROT_WRITE and flags MAP_SHARED are recommended. VIDIOC_QBUF (struct v4l2_buffer) This command indicates to the driver that the buffer is ready to receive a video sample. The following fields must be set: index, set to a valid buffer index from 0 to count - 1; type, set to the same type used above; and memory, set to the same memory used above. Each buffer should be queued with this command. Order is not important. VIDIOC_STREAMON (int) This command starts streaming. Queued buffers will be filled with data. select(2) will indicate that a buffer is done and available for reading. VIDIOC_DQBUF (struct v4l2_buffer) This command dequeues an available buffer from the driver. If no buffer is available, it blocks until one is, unless O_NONBLOCK was specified to open(2), in which case it returns EAGAIN. select(2), or poll(2) prior to initiating any other mode will begin streaming of video for reading with read(2). In this streaming mode select(2) or poll(2) indicate the availability of a video frame. Calls to read(2) will return at most the video data of one video sample. If the entire sample is not read, then subsequent reads will return at most the remaining data in that video sample. FILES
/dev/video SEE ALSO
auvitek(4), pseye(4), uvideo(4), video(9) HISTORY
The video device driver first appeared in NetBSD 5.0. AUTHORS
Patrick Mahoney <pat@polycrystal.org> BUGS
Does not support the complete V4L2 API. Only supports the capture interface. Does not support writing, overlay, VBI, tuner, audio, radio, or asyncio. BSD
March 5, 2011 BSD
All times are GMT -4. The time now is 08:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy