Re: [Libav-user] Fast parsing of H.264 video stream using libavcodec

2016-07-20 Thread Gonzalo



El 20/07/16 a las 18:58, Puneet Kapoor escribió:


If you could share some examples of multi-threaded libav user code, it 
would be helpful.


Thanks

Google for "dranger ffmpeg".  The original page is a tutorial page, but 
it is a tad out of date.  Some other repositories contain updated code.


Some demuxers may support multithreaded operation, albeit for most 
operations you gain little.  For that, you can use:


  AVDictionary* info = NULL;
  av_dict_set(, "threads", "auto", 0);

  avcodec_open2( video_ctx, video_codec,  );

--
Gonzalo Garramuño
ggarr...@gmail.com

___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] Fast parsing of H.264 video stream using libavcodec

2016-07-20 Thread Puneet Kapoor
I am new to H264 decoding and using this library, so pardon me if my
questions seem too naive.

Isn't the libav function  avcodec_decode_video2() internally multi-threaded
to be able to use multiple cores itself? Do we need to enable it somehow ?

If you could share some examples of multi-threaded libav user code, it
would be helpful.

Thanks
On Jul 21, 2016 3:14 AM, "Gonzalo"  wrote:

>
>
> El 20/07/16 a las 17:46, Puneet Kapoor escribió:
>
>>
>> By making it multithreaded ?
>>
>> Yes.
>
> --
> Gonzalo Garramuño
> ggarr...@gmail.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] Fast parsing of H.264 video stream using libavcodec

2016-07-20 Thread Gonzalo



El 20/07/16 a las 17:46, Puneet Kapoor escribió:


By making it multithreaded ?


Yes.

--
Gonzalo Garramuño
ggarr...@gmail.com

___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


[Libav-user] Fast parsing of H.264 video stream using libavcodec

2016-07-20 Thread Puneet Kapoor
Hi,

I am using Libav* libraries to decode the frames from the byte stream data
I am receiving from another thread.

I have been able to successfully parse the byte stream and render video
correctly using the OpenCV API. *Basic flow in my code using libav is like:*
*init() { *
*avcodec_find_decoder(AV_CODEC_ID_H264) ;*
*avcodec_alloc_context3(codec);*

*avcodec_open2(codec_context, codec, NULL)*




*picture = av_frame_alloc();pictureBGR = av_frame_alloc();parser =
av_parser_init(AV_CODEC_ID_H264);codec_context->thread_count = 2; // tried
to increase threads}readFrame() {int len = av_parser_parse2(parser,
codec_context, , , [0],
buffer.size(), 0, 0, AV_NOPTS_VALUE); ...int len_dec =
avcodec_decode_video2(codec_context, picture, _picture, ); // takes
most time (~77%)...iResult = sws_scale(...)*
*}*

The problem I am facing is related to performance of my decoding code. My
program manages to do 10 frames per second (fps) for a 720p video. When I
save the same video stream as a file and use OpenCV code to parse it, it is
able to parse the same video at around 24 fps.

I did basic profiling of my code and found that most of the time is going
in decoding call "*avcodec_decode_video2()*" (~77% time) and SWS rescaling
call "*sws_scale()*" (~18% time).

I haven't profiled the OpenCV code, but one difference I noticed is that
OpenCV code uses multiple cores from *top* and *time* command
statistics(shared below). And, my code runs single threaded.
My question here is: How can I improve the performance of my code ? By
making it multithreaded ? Are there any library specific tweaks that can
help ?

*Time command statistics*
*For OpenCV code:*
real 0m17.496s
user 0m48.030s
sys 0m2.410s

*For My code using Libav library:*
real 0m39.478s
user 0m39.380s
sys 0m0.100s


Thanks
Puneet
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] ffmpeg command line for video rendered from set of image snapshots

2016-07-20 Thread Josef Vosyka
>> ffmpeg -start_number 1 -framerate 2 -i img_%d.jpg
>> -c:v h264 -profile:v baseline -r 25 -s 208:160 movie.mp4
>
> Complete, uncut console output missing.

Working syntax:

string img_mask = imagesRootPath + "/img_%7d.jpg";
cmd_str = string_format("ffmpeg -start_number 1 -framerate %d -i %s
-b:v 132k -r 25 %s", framerate, img_mask.c_str(), out.c_str());


> Generally, this mailing list is for questions using the
> libraries, ffmpeg-user is for questions regarding
> command line usage.

Sorry about that. Will use correct forum next time.
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


[Libav-user] decoding for stream 0 failed ?

2016-07-20 Thread ssshukla26
Hi,

I am implementing a custom decoder of qualcomm chipset into ffmpeg, have a
working linux application for the same. I am able to run decoder, but its
closing with aN error as show below.

Note: The output format is nv12 tiled, we have already added support for
nv12 tile to yuv420p conversion in libswscale. 
0001-NV12-Tile-pixel-format-support-added.patch

  

# *ffmpeg -f h264 -c:v h264_qhw -i no_mans_sky_1080p_10sec.h264 -pix_fmt
nv12_tiled -s 1920x1080 -r 30 out_1080p.yuv*
ffmpeg version N-80917-gc5096bc Copyright (c) 2000-2016 the FFmpeg
developers
  built with gcc 4.9.2 (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC
4.9-2014.09) 20140904 (prerelease)
  configuration: --prefix=comark_SBC_ffmpeg/ --enable-shared
--enable-nonfree --enable-pic --enable-gpl --enable-cross-compile
--cross-prefix=arm-linux-gnueabihf- --arch=arm --target-os=linux
--extra-cflags=-I../sdl/source/SDL-1.2.15/comark_SBC_SDL//include/SDL/
--extra-ldflags='-L../sdl/source/SDL-1.2.15/comark_SBC_SDL//lib/ -lSDL'
  libavutil  55. 28.100 / 55. 28.100
  libavcodec 57. 48.101 / 57. 48.101
  libavformat57. 41.100 / 57. 41.100
  libavdevice57.  0.102 / 57.  0.102
  libavfilter 6. 47.100 /  6. 47.100
  libswscale  4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc54.  0.100 / 54.  0.100
Initialized Params
@ 328 in init_params : width = 1920 & height = 1080
Initialized Decoder
@ 680 in vdec_set_buffer_requirement : Input Buffer mincount=1
maxcount=32
actualcount=3
,buffer_size=2097152
,alignment=2048
@ 703 in vdec_set_buffer_requirement : Output Buffer mincount=6
maxcount=32
actualcount=10
,buffer_size=3137536
,alignment=8192
@ 910 in vdec_alloc_h264_mv : Entered vdec_alloc_h264_mv act_width: 1920,
act_height: 1080, size: 5570560, alignment 8192
Start Decoder
Buffers freed for reconfiguration
@ 910 in vdec_alloc_h264_mv : Entered vdec_alloc_h264_mv act_width: 1920,
act_height: 1080, size: 5570560, alignment 8192
Buffers allocated for reconfiguration
*[h264 @ 0x4a260] decoding for stream 0 failed*

Stop Decoder
De-Initialized Decoder
De-Initialized Params
*[h264 @ 0x4a260] Could not find codec parameters for stream 0 (Video: h264
(High), none, 1920x1080): unspecified pixel format
*Consider increasing the value for the 'analyzeduration' and 'probesize'
options
Input #0, h264, from 'no_mans_sky_1080p_10sec.h264':
  Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), none, 1920x1080, 12.50 fps, 25 tbr,
1200k tbn, 25 tbc
File 'out_1080p.yuv' already exists. Overwrite ? [y/N] n
Not overwriting - exiting

Please help.




--
View this message in context: 
http://libav-users.943685.n4.nabble.com/Libav-user-decoding-for-stream-0-failed-tp4662372.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] one question about network blocking issue

2016-07-20 Thread qw
Hi,

I'm making program to read and write rtmp av stream. If network is bad, some 
ffmpeg functions will block indefinitely.

The rtmp application will use the following functions, including 
avformat_open_input(), avformat_find_stream_info(), 
avformat_alloc_output_context2(), avio_open(), avformat_write_header(), 
av_read_frame(), av_interleaved_write_frame(), av_write_trailer(), 
avformat_close_input(), and avformat_free_context().

The above functions are used in ffmpeg and transcoding binary programs.

Which function has indefinite-block issue? How to avoid indefinite-block issue?

Thanks!

Regards

Andrew
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


[Libav-user] how to deal with network timeout

2016-07-20 Thread qw
Hi,

I'm making program to read and write rtmp stream to server. Many ffmpeg 
functions are related in network operation, such as connection, read and write:

avformat_open_input(), avformat_find_stream_info(), av_read_frame(), and 
av_interleaved_write_frame().

If network is not good, avformat_open_input() and av_read_frame() will wait 
indefinitely. How to deal with indefinite-waiting issue?

Thanks!

Regards

Andrew
___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


[Libav-user] One question about timeout in rtmp

2016-07-20 Thread qw
Hi,

I use native rtmp in ffmpeg 3.1.1 to demuxer rtmp stream from nginx server. 
avformat_open_input() is used to open input rtmp stream. Native rtmp plugin 
supports 'timeout' option as shown below:

  -timeout   .D.. Maximum timeout (in seconds) to wait 
for incoming connections. -1 is infinite. Implies -rtmp_listen 1 (from INT_MIN 
to INT_MAX) (default -1)

I add timeout of 10 seconds to rtmp option set, and call avformat_open_input().

AVDictionary *format_opts = NULL;
av_dict_set(_opts, "timeout", "10", 0);
avformat_open_input(fmt-ctx, rtmp-url, NULL, _opts);

But avformat_open_input() will return immediately with error messages as 
follows:

[rtmp @ 0x8ff9a0] Cannot open connection 
tcp://localhost:1935?listen_timeout=1
Cannot open input rtmp url:
rtmp://localhost:1935/live1/abc!
Fail to call openInputLiveStream()!

nginx server didn't provide live streaming service. It was expected that 
avformat_open_input() would return in 10 seconds with error mesage. But why did 
the function return immediately?

Thanks!

Regards

Andrew


___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user


Re: [Libav-user] ffmpeg command line for video rendered from set of image snapshots

2016-07-20 Thread Carl Eugen Hoyos
Josef Vosyka  writes:

> ffmpeg -start_number 1 -framerate 2 -i img_%d.jpg 
> -c:v h264 -profile:v baseline -r 25 -s 208:160 movie.mp4

Complete, uncut console output missing.

Generally, this mailing list is for questions using the 
libraries, ffmpeg-user is for questions regarding 
command line usage.

Carl Eugen

___
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user