Re: [Libav-user] Hardware encoder ARM input as device input

2018-03-02 Thread Marcin Woźniak

Writing to myself. Problem resolved. Wrong timebase.
Thanks.

W dniu 13.02.2018 o 13:56, Marcin Woźniak pisze:
I am using HiSilicon 3516A board, there is no V4L device but other 
approach using /dev/venc ioctl calls and MPP API.
I am able to open the encoder, read raw H264 packets but no go, looks 
like read_packet is called about 10 times slower than it should.

If i move the code to outside of ffmpeg and open it as:
dump_stream | ffmpeg -i - vcodec copy out.h264 //it works at good speed.

Why libav is not calling read_packet as fast as it should?
Marcin




what board are you using? if there is already v4l2 support in the kernel
it should be a matter of just calling the ffmpeg with the right encoding
parameters
below an example to encode an NV12 YUV format:

$ ffmpeg -f rawvideo -pix_fmt nv12 -s:v 1280:720 -r 25 -i
~/Videos/raw/freeway.yuv -c:v h264_v4l2m2m out/out.h264.mp4



___
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] Hardware encoder ARM input as device input

2018-02-13 Thread Marcin Woźniak

I am using HiSilicon 3516A board, there is no V4L device but other approach 
using /dev/venc ioctl calls and MPP API.
I am able to open the encoder, read raw H264 packets but no go, looks like 
read_packet is called about 10 times slower than it should.
If i move the code to outside of ffmpeg and open it as:
dump_stream | ffmpeg -i - vcodec copy out.h264 //it works at good speed.

Why libav is not calling read_packet as fast as it should?
Marcin




what board are you using? if there is already v4l2 support in the kernel
it should be a matter of just calling the ffmpeg with the right encoding
parameters
below an example to encode an NV12 YUV format:

$ ffmpeg -f rawvideo -pix_fmt nv12 -s:v 1280:720 -r 25 -i
~/Videos/raw/freeway.yuv -c:v h264_v4l2m2m out/out.h264.mp4

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


Re: [Libav-user] Hardware encoder ARM input as device input

2018-02-05 Thread Marcin Woźniak

Finnaly i was able to set up timing data in h264 stream.
Trying to save this as -f test.h264 produces good file, trying to mux it 
drops FPS to tenth of original (25 fps becomes 2.5 fps and bitrate from 
1024 kb/s to little more than 100 kbs).

PTS of every NAL unit is different exactly by 4 (sometimes 40001).
What am i doing wrong?

Input #0, hisi, from '/dev/video':
  Duration: N/A, start: 895789.311044, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 
1920x1080, 25 fps, 25 tbr, 90k tbn, 50 tbc

File 'out.mkv' already exists. Overwrite ? [y/N] getchnattr worksy
Output #0, matroska, to 'out.mkv':
  Metadata:
encoder : Lavf57.83.100
Stream #0:0: Video: h264 (Main) (H264 / 0x34363248), yuvj420p(pc, 
bt709, progressive), 1920x1080, q=2-31, 25 fps, 25 tbr, 1k tbn, 90k tbc

Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[matroska @ 0x1a1c4b0] Non-monotonous DTS in output stream 0:0; 
previous: 0, current: -2627; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x1a1c4b0] Non-monotonous DTS in output stream 0:0; 
previous: 0, current: -2182; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x1a1c4b0] Non-monotonous DTS in output stream 0:0; 
previous: 0, current: -1738; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x1a1c4b0] Non-monotonous DTS in output stream 0:0; 
previous: 0, current: -1293; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x1a1c4b0] Non-monotonous DTS in output stream 0:0; 
previous: 0, current: -849; changing to 0. This may result in incorrect 
timestamps in the output file.
[matroska @ 0x1a1c4b0] Non-monotonous DTS in output stream 0:0; 
previous: 0, current: -404; changing to 0. This may result in incorrect 
timestamps in the output file.
frame=   24 fps=3.5 q=-1.0 Lsize=  94kB time=00:00:07.15 bitrate= 
107.6kbits/s speed=1.04x
video:93kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB 
muxing overhead: 0.929940%


Marcin


W dniu 04.02.2018 o 16:24, Marcin Woźniak pisze:

Hello,
I try to implement an HiSilicon H264 encoder direct input as ffmpeg 
libavdevice source (someking like V4L linux for cameras with H264 
source driver).
I successfully recieve H264 packets with NAL units and set correct PTS 
according to source packet.
I am stuck at the moment where timing data is not extracted from raw 
H264 paassed data and looks like this:


Input #0, armdevice, from '/dev/video':
  Duration: N/A, start: 0.00, bitrate: N/A
Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 
1920x1080, 1000k tbr, 1000k tbn, 2000k tbc


Resolution is okay but timing data is wrong. I passed SPS and PPS of 
incomming data in "read_packet".


In shotcut:
1. Open H264 encoder using low-level API in device_open
2. Initialize encoder with fps and resolution using API in device_init
3. In read_packet i get NAL units from buffer and:
av_new_packet(pkt,total);
memcpy(pkt->data,buffer) -> stub
 pkt->pts = buffer.u64PTS;
pkt->size = size
and return packet.

Profile level is guessed okay but not the timing data.

What am i doing wrong?
 Marcin


___
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