[Libav-user] UDP streaming from one PC to another

2016-09-20 Thread Timur Guseynov
Hi.

I am wondering if I can stream with ffmpeg from one PC via UDP to another
and the second one has ffmpeg using this stream as an input and save to
file?

Can I do it via CLI?
Will I be able to do the same programatically using its API?

Kind regards,
Timur Guseynov
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] Querying v4l2 devices

2016-09-17 Thread Timur Guseynov
avdevice_list_input_sources works.

Thank you!

сб, 17 сент. 2016 г. в 1:33, Lukasz Marek :

> On 17.09.2016 00:08, Lukasz Marek wrote:
> > I guess input device private data is not initialized, try to add this
> > code right after formatContext->iformat=inputFormat, just replace s with
> > formatContext
> >
> > if (s->iformat->priv_data_size > 0) {
> > s->priv_data = av_mallocz(s->iformat->priv_data_size);
> > if (s->iformat->priv_class) {
> > *(const AVClass**)s->priv_data= s->iformat->priv_class;
> > av_opt_set_defaults(s->priv_data);
> > }
> > } else
> > s->priv_data = NULL;
> >
> >
> > Maybe ff_alloc_input_device_context function should be moved to
> > libavdevice's public API
>
> Ignore this answer, it should work but manipulates private fields
> You should use avdevice_list_input_sources. If still not working then
> please attach some *.c file so i can test it locally.
> ___
> Libav-user mailing list
> Libav-user@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


[Libav-user] Querying v4l2 devices

2016-09-16 Thread Timur Guseynov
Hi. I wrote the code for getting a list of input devices:

 avdevice_register_all();


AVFormatContext *formatContext = avformat_alloc_context();

AVInputFormat *inputFormat = NULL;

while((inputFormat = av_input_video_device_next(inputFormat)))

{

formatContext->iformat = inputFormat;


AVDeviceInfoList *deviceList = NULL;

avdevice_list_devices(formatContext, );


if(deviceList)

{

for(int i = 0; i < deviceList->nb_devices; ++i)

{

AVDeviceInfo *device = deviceList->devices[i];

..

}

}


   avdevice_free_list_devices();

 }


It fails with SIGSEGV on avdevice_list_devices when it comes to v4l2
input format.


Why does it fail?

How can I get list of video devices?


Btw I'm using Ubuntu 16.04
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] Decoding/encoding api

2016-09-16 Thread Timur Guseynov
Thanks! Will try it out.

пт, 16 сент. 2016 г. в 13:56, Steve <musicspeedchan...@gmail.com>:

> Timur Guseynov wrote
> > So I can write something like this and it would be ok?
> >
> > AVCodecContext *codecContext;
> > AVPacket *packet;
> > AVFrame *frame;
> > // allocating codec context, getting packet
> > .
> > //
> > avcodec_send_packet(codecContext, packet);
> > while(avcodec_receive_frame(codecContext, frame) == 0)
> > {
> >   av_frame_unref(frame);
> > }
>
> No, that's where the doc you were referring to comes in, av_frame_unref is
> called for you. But you have to handle the packet, so:
>
> avcodec_send_packet(codecContext, packet);
> while(avcodec_receive_frame(codecContext, frame) == 0)
> {
> ..
> }
>  av_packet_unref(packet);
>
>
>
>
>
> --
> View this message in context:
> http://libav-users.943685.n4.nabble.com/Libav-user-Decoding-encoding-api-tp4662664p4662679.html
> Sent from the libav-users mailing list archive at Nabble.com.
> ___
> Libav-user mailing list
> Libav-user@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] Decoding/encoding api

2016-09-16 Thread Timur Guseynov
So I can write something like this and it would be ok?

AVCodecContext *codecContext;
AVPacket *packet;
AVFrame *frame;
// allocating codec context, getting packet
.
//
avcodec_send_packet(codecContext, packet);
while(avcodec_receive_frame(codecContext, frame) == 0)
{
  av_frame_unref(frame);
}

пт, 16 сент. 2016 г. в 2:26, Steve <musicspeedchan...@gmail.com>:

> Timur Guseynov wrote
> > I'm a bit confused with decoding/encoding api. I've read this
> > https://ffmpeg.org/doxygen/3.1/group__lavc__encdec.html;
> > documentation and
> > it says "Receive output in a loop. Periodically call one of the
> > avcodec_receive_*()...".
> >
> > avcodec_receive_frame() docs say "the function will always call
> > av_frame_unref(frame) before doing anything else." The same goes for
> > avcodec_receive_packet().
> >
> > So, for example, I will write such code:
> >
> > AVCodecContext *codecContext;
> > AVPacket *packet;
> > AVFrame *frame;
> > // allocating codec context, getting packet
> > .
> > //
> > avcodec_send_packet(codecContext, packet);
> > while(avcodec_receive_frame(codecContext, frame) == 0)
> > {
> > }
> >
> > Will this code be functioning right?
> >
> > ___
> > Libav-user mailing list
>
> > Libav-user@
>
> > http://ffmpeg.org/mailman/listinfo/libav-user
>
> The doc for avcodec_receive_packet has  you need to check a typo, it calls
> av_packet_unref. This is just convenience, you would have to call
> av_packet_unref or av_frame_unref yourself otherwise on each turn.
>
> Your code would be ok but you need to call av_packet_unref at the end
> because you retain ownership of the packet.
>
>
>
> --
> View this message in context:
> http://libav-users.943685.n4.nabble.com/Libav-user-Decoding-encoding-api-tp4662664p4662672.html
> Sent from the libav-users mailing list archive at Nabble.com.
> ___
> Libav-user mailing list
> Libav-user@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


[Libav-user] Get input device formats

2016-09-15 Thread Timur Guseynov
I've been trying to find out the way to get capabilities of my webcam like
resolution, pixel format, fps etc. I've tried using
AVDeviceCapabilitiesQuery, but after creating it, it was shown as NULL
pointer.

I've seen command like this
ffmpeg -f v4l2 -list_formats all -i /dev/video0

How can I implement something like this in C++?
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


[Libav-user] Decoding/encoding api

2016-09-15 Thread Timur Guseynov
I'm a bit confused with decoding/encoding api. I've read this
 documentation and
it says "Receive output in a loop. Periodically call one of the
avcodec_receive_*()...".

avcodec_receive_frame() docs say "the function will always call
av_frame_unref(frame) before doing anything else." The same goes for
avcodec_receive_packet().

So, for example, I will write such code:

AVCodecContext *codecContext;
AVPacket *packet;
AVFrame *frame;
// allocating codec context, getting packet
.
//
avcodec_send_packet(codecContext, packet);
while(avcodec_receive_frame(codecContext, frame) == 0)
{
}

Will this code be functioning right?
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


[Libav-user] Streaming from camera to server

2016-09-10 Thread Timur Guseynov
Hi.

I am new to C++ and FFmpeg and wanted to write application that streams
video from camera (webcam at least) to some server.

I've seen StreamingGuide <https://trac.ffmpeg.org/wiki/StreamingGuide> and
wanted to know how to implement it.
I think that basic flow is like this, please correct me if I'm wrong:

   1. Get input device AVInputFormat from libavdevice
   2. Open that input with avformat_open_input
   3. Find its streams' codecs
   4. Get decoder with avcodec_find_decoder
   5. Decode it somehow
   6. Encode it for stream
   7. Write data with muxer
   8. Send muxed data to server

So I imagine how to implement the first half of this list but not the
second.

2 questions that I have are:

   1. Do I understand the streaming flow right? What are the nuances that I
   must consider? What modules/methods should I look into to implement it?
   2. How can I do a preview of stream in a GUI using, for example, Qt
   Quick? Is an input device blocked by one of the processes (either FFmpeg or
   Qt)? If it is, should I somehow copy frames for GUI to show them for user
   or just reference it?

Thanks in advance!

Kind regards,
Timur Guseynov
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user