jocover / jetson-ffmpeg Goto Github PK
View Code? Open in Web Editor NEWffmpeg support on jetson nano
License: Other
ffmpeg support on jetson nano
License: Other
I'm not sure if everything is correct.
I'm not able to use the acceleration and want to know if there is a way to check if installion is done correctly.
my ffmpeg -hwaccels
ffmpeg -hwaccels
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu/Linaro 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/aarch64-linux-gnu --incdir=/usr/include/aarch64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Hardware acceleration methods:
vdpau
vaapi
Hello,
As far as I understand, using the h264_nvmpi/hevc_nvmpi after patching and installing correctly is supposed to use nvenc for video encoding. I tried encoding a file using it and monitoring using jtop. I was surprised to see only cpu usage and no nvenc usage at all.
Is this OK or is there a bug? Maybe I did something wrong? I followed the instructions exactly.
Occasionally I receive this message when playing back an rtsp stream.
Using ffmpeg -c:v h264_nvmpi -i rtsp://.... -an -f null -
Using just h264 does not get this error.
Hi @jocover !
Thanks v.much for developing jetson-ffmpeg! I was hoping to use my nano as a media playback device but it was pretty useless for that until I discovered jetson-ffmpeg. Very impressive work!
There are at least 2 things I would like to see added to the README:
ffplay -vcodec h264_nvmpi -i vid.mkv
ffplay -vcodec hevc_nvmpi -noautorotate -i vid2.mp4
I also have a few of other questions that are unrelated to the documentation:
Do you know if nvmpi hardware decoding will work with mpv without having to rebuild or update the L4T mpv package, after installing jetson-ffmpeg as a Ubuntu package.
Have you created a Ubuntu (source) package for jetson-ffmpeg yet? It should easy enough to tweak the 20.04 ffmpeg source package (which is for ffmpeg 4.2.x) to create one for jetson-ffmpeg.
I have read on the NVidia dev forums that the official L4T build of ffmpeg is supposed to support hardware decoding now but I haven't got it to work, have you?
I'm running JetPack 4.4 on a Jetson Nano btw.
Thanks
I noticed this code is missing a license. Can you please add a license file to the repository so the code can be legally used and redistributed?
As stated on https://choosealicense.com/no-permission/:
If you find software that doesn’t have a license, that generally means you have no permission from the creators of the software to use, modify, or share the software. Although a code host such as GitHub may allow you to view and fork the code, this does not imply that you are permitted to use, modify, or share the software for any purpose.
Hello, Sir,
I want to try low lentency encoding, I modify "num_capture_buffers" to 5 or less,,ffmpeg will crash. After tested it, must set to 10 or more...could you share some info about this?
Here is my test code to utilize jetson-ffmpeg.
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <cassert>
#include <iostream>
#include <sys/time.h>
#include <fstream>
#include <chrono>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <thread>
#include <mutex>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <dirent.h>
#include <fstream>
#include <FreeImage.h>
#include <vector>
extern "C"{
#include <nvmpi.h>
#include "jetson_ffmpeg/avcodec.h"
#include "jetson_ffmpeg/decode.h"
#include "jetson_ffmpeg/internal.h"
#include <libavcodec/avcodec.h>
#include <libavutil/buffer.h>
#include <libavutil/common.h>
#include <libavutil/frame.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/pixdesc.h>
#include <libavutil/hwcontext.h>
#include <libavutil/hwcontext_drm.h>
#include <libavutil/opt.h>
#include <libavutil/avassert.h>
#include <libavutil/imgutils.h>
#include <libavutil/log.h>
}
using namespace std;
static AVBufferRef *hw_device_ctx = NULL;
enum AVHWDeviceType type;
static enum AVPixelFormat hw_pix_fmt;
typedef struct {
char eos_reached;
nvmpictx* ctx;
AVClass *av_class;
} nvmpiDecodeContext;
static int hw_decoder_init(AVCodecContext *ctx, const enum AVHWDeviceType type)
{
int err = 0;
if ((err = av_hwdevice_ctx_create(&hw_device_ctx, type,
NULL, NULL, 0)) < 0) {
fprintf(stderr, "Failed to create specified HW device.\n");
return err;
}
ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx);
return err;
}
static enum AVPixelFormat get_hw_format(AVCodecContext *ctx,
const enum AVPixelFormat *pix_fmts)
{
const enum AVPixelFormat *p;
for (p = pix_fmts; *p != -1; p++) {
if (*p == hw_pix_fmt)
return *p;
}
fprintf(stderr, "Failed to get HW surface format.\n");
return AV_PIX_FMT_NONE;
}
static nvCodingType nvmpi_get_codingtype(AVCodecContext *avctx)
{
switch (avctx->codec_id) {
case AV_CODEC_ID_H264: return NV_VIDEO_CodingH264;
case AV_CODEC_ID_HEVC: return NV_VIDEO_CodingHEVC;
case AV_CODEC_ID_VP8: return NV_VIDEO_CodingVP8;
case AV_CODEC_ID_VP9: return NV_VIDEO_CodingVP9;
case AV_CODEC_ID_MPEG4: return NV_VIDEO_CodingMPEG4;
case AV_CODEC_ID_MPEG2VIDEO: return NV_VIDEO_CodingMPEG2;
default: return NV_VIDEO_CodingUnused;
}
};
static int nvmpi_init_decoder(AVCodecContext *avctx){
int ret=0;
nvmpiDecodeContext *nvmpi_context = (nvmpiDecodeContext *)avctx->priv_data;
nvCodingType codectype=NV_VIDEO_CodingUnused;
codectype =nvmpi_get_codingtype(avctx); // NV_VIDEO_CodingH264
if (codectype == NV_VIDEO_CodingUnused) {
av_log(avctx, AV_LOG_ERROR, "Unknown codec type (%d).\n", avctx->codec_id);
ret = AVERROR_UNKNOWN;
return ret;
}
nvmpi_context->ctx=nvmpi_create_decoder(codectype,NV_PIX_YUV420);
if(!nvmpi_context->ctx){
av_log(avctx, AV_LOG_ERROR, "Failed to nvmpi_create_decoder (code = %d).\n", ret);
ret = AVERROR_UNKNOWN;
return ret;
}
return ret;
}
static int nvmpi_close(AVCodecContext *avctx){
nvmpiDecodeContext *nvmpi_context = (nvmpiDecodeContext *)avctx->priv_data;
return nvmpi_decoder_close(nvmpi_context->ctx);
}
static int nvmpi_decode(AVCodecContext *avctx,void *data,int *got_frame, AVPacket *avpkt){
//nvmpiDecodeContext *nvmpi_context = avctx->priv_data;
nvmpiDecodeContext *nvmpi_context = (nvmpiDecodeContext*)avctx->priv_data;
AVFrame *frame = (AVFrame *)data;
nvFrame _nvframe={0};
nvPacket packet;
uint8_t* ptrs[3];
int res,linesize[3];
if(avpkt->size){
packet.payload_size=avpkt->size;
packet.payload=avpkt->data;
packet.pts=avpkt->pts;
res=nvmpi_decoder_put_packet(nvmpi_context->ctx,&packet);
cout << "RES TEST:" << res << endl;
}
res=nvmpi_decoder_get_frame(nvmpi_context->ctx,&_nvframe,avctx->flags & AV_CODEC_FLAG_LOW_DELAY);
cout << "decode RES:" << res << endl;
if(res<0)
return avpkt->size;
//if (ff_get_buffer(avctx, frame, 0) < 0) {
//return AVERROR(ENOMEM);
//}
int ret;
ret = avcodec_receive_frame(avctx, frame);
cout << "TEST" << ret << endl;
//return AVERROR(ENOMEM);
linesize[0]=_nvframe.linesize[0];
linesize[1]=_nvframe.linesize[1];
linesize[2]=_nvframe.linesize[2];
cout << "TEST" << endl;
cout << linesize[0] << endl;
cout << linesize[1] << endl;
cout << linesize[2] << endl;
ptrs[0]=_nvframe.payload[0];
ptrs[1]=_nvframe.payload[1];
ptrs[2]=_nvframe.payload[2];
av_image_copy(frame->data, frame->linesize, (const uint8_t **) ptrs, linesize, avctx->pix_fmt, _nvframe.width,_nvframe.height);
frame->width=_nvframe.width;
frame->height=_nvframe.height;
frame->format=AV_PIX_FMT_YUV420P;
frame->pts=_nvframe.timestamp;
frame->pkt_dts = AV_NOPTS_VALUE;
avctx->coded_width=_nvframe.width;
avctx->coded_height=_nvframe.height;
avctx->width=_nvframe.width;
avctx->height=_nvframe.height;
*got_frame = 1;
return avpkt->size;
}
int main(){
AVFormatContext *input_ctx = NULL;
AVInputFormat *input_fmt;
int video_stream, ret;
AVStream *video = NULL;
AVCodecContext *decoder_ctx = NULL;
AVCodec *decoder = NULL;
AVPacket packet;
double fps;
// Jetson nano testing
int ret2;
nvmpictx *ctx_nvmpi = NULL;
nvPacket packet_nvmpi;
int got_frame;
string path = "sample_convert5.h264";
//string path = "/usr/src/jetson_multimedia_api/data/Video/sample_outdoor_car_1080p_10fps.h264";
input_fmt = av_find_input_format("h264_nvmpi");
//if (avformat_open_input(&input_ctx, path.c_str(), input_fmt, NULL) != 0){
if (avformat_open_input(&input_ctx, path.c_str(), NULL, NULL) != 0){
avformat_close_input(&input_ctx);
cout << "FORMAT OPEN ERROR" << endl;
return -1;
}
if (avformat_find_stream_info(input_ctx, NULL) < 0) {
fprintf(stderr, "Cannot find input stream information.\n");
return -1;
}
/* find the video stream information */
ret = av_find_best_stream(input_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &decoder, 0);
if (ret < 0) {
fprintf(stderr, "Cannot find a video stream in the input file\n");
return -1;
}
video_stream = ret;
//decoder_ctx = input_ctx->streams[video_stream]->codec;
decoder = avcodec_find_decoder(AV_CODEC_ID_H264);
if (!(decoder_ctx = avcodec_alloc_context3(decoder)))
return AVERROR(ENOMEM);
ret = avcodec_open2(decoder_ctx, decoder, NULL);
cout << "DECODEROPEN:" << ret << endl;
ret = nvmpi_init_decoder(decoder_ctx);
cout << ret << endl;
if (ret == AVERROR_UNKNOWN)
cout << "NVMPI_INIT_ERROR" << endl;
AVFrame *frame;
for(int i = 0; i<5; i ++){
cout << "PRINT TEST" << endl;
if ((ret = av_read_frame(input_ctx, &packet)) < 0){
cout << "[DEBUG] FRAME_READ_FAILED" << endl;
packet.data = NULL;
packet.size = 0;
av_packet_unref(&packet);
return -1;
}
//AVFrame *frame = NULL;
ret = nvmpi_decode(decoder_ctx, frame, &got_frame, &packet);
//ret = nvmpi_decode(decoder_ctx, packet.data, &got_frame, &packet);
cout << "decode ret:" << ret << endl;
cout << "frame:" << frame << endl;
}
cout << "TEST" << endl;
nvmpi_close(decoder_ctx);
cout << "TEST" << endl;
return 0;
The result of test code is like that
How can I use jetson-ffmpeg to decode frames in C++?
Also, ff_get_buffer cause linking error (undefined reference to ff_get_buffer)
Hi, it's not clear to me if the ffmpeg that is provided by apt (executable and libs) is supposed to be installed or not at the moment of building this project.
In an attempt to prevent possible conflicts, I decided to remove the apt version (apt remove ffmpeg) before running this build, but when it finished I found myself without any ffmpeg executable (at least in the path). I tried relogging just in case, but still no ffmpeg executable. I stress this point of "in the patch" because the running instructions specifically give the example of running ffmpeg and not ./ffmpeg, which would only run if it was available in the system path.
Based on this, I then I thought that maybe I was supposed to have the ffmpeg version installed, so I reinstalled (after having built this project). One "sudo apt install ffmpeg" later, I got my ffmpeg executable back, but unsurprisingly it did not recognize the codec.
That lead me to think that maybe ffmpeg should have been there at the moment of the building/installation of the codec, so now, with the apt package installed, I'm rebuilding the project from scratch as I write this.
In the meantime, it came to my attention an issue created by other user, who stated that he was running "./ffmpeg" ... which is compatible with the lack of sudo make install of the mmpeg. All this while the "running" instructions, as I previously mentioned, clearly say "ffmpeg" (withouth ./) which on the other hand implies that the ffmpeg is expected to be on the system path, but as I stated there was no "sudo make install" of the ffmpeg itself (the expectation of having ffmpeg in the path is what lead me to think that maybe I should have had the apt package installed).
So as you can see I found all this a little confusing. I believe I will be able to sort it out eventually after a couple more trials and errors, but I wanted to leave feedback on this, as I believe the instructions are either incomplete or at least a little bit misleading.
Thank you.
Best regards.
Eduardo
Hello,
When I try and go through the build steps with cmake, I get this error:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIB_V4L2
linked by target "nvmpi" in directory /home/tombert/jetson-ffmpeg
-- Configuring incomplete, errors occurred!
See also "/home/tombert/jetson-ffmpeg/build/CMakeFiles/CMakeOutput.log".
See also "/home/tombert/jetson-ffmpeg/build/CMakeFiles/CMakeError.log".
Is there something that I'm obviously missing?
+ nvmpi_context->ctx=nvmpi_create_decoder(codectype,NV_PIX_YUV420);
In the patch, it is hardcoded to use YUV420. Is there a reason why this is preferred over NV12?
Edit: I tried replacing YUV420 with NV12 and received this error:
Assertion ((src_linesize) >= 0 ? (src_linesize) : (-(src_linesize))) >= bytewidth failed at libavutil/imgutils.c:314
I use ffmpeg to push a camera video to a rtmp url, when I push with cmd ”ffmpeg -thread_queue_size 32 -f video4linux2 -i /dev/video2 -filter_complex "transpose=clock" -threads 6 -pix_fmt yuv420p -b:v 4096k -bufsize 4096k -vcodec h264_nvmpi -r 25 -f flv 'rtmp://xxx'“ ,I get mess video. When i remove the parmas -filter_complex "transpose=clock". It gets correct video. My camera video's size is 1920x1080. So i guess that this ffmpeg with nvmpi encode not handle transpose param. Thanks for reply.
Hi,
I stream vide over local network from PC and I want to get frames with jetson nano.
1- ffmpeg -i rtsp out.mp4 or ffmpeg -c:v h264_nvmpi -i rtsp out.mp4
cpu usage reach to 35% , fps=30 and q=34 , ...
2- ffmpeg -i rtsp -c:v h264_nvmpi out.mp4 or ffmpeg -c:v h264_nvmpi -i rtsp -c:v h264_nvmpi out.mp4
cpu usage reach to 8%, fps=30, q = 0
Is the result correct? jetson nano support 4 streams for encoding and 8 streams for decoding at 1080p30.
Q1 - I use only 1 stream fro decoding and encoding, when the cpu usage is diffrent?
Q2 - If i want to compare with cpu software decoding what elelemt i pass to ffmpg to show me cpu usage in the cpu decoding is high?
In our example the main diffrence between decode and encode is the order of elements in ffmpeg,
Q3-if -c:v h264_nvmpi be right side of -i this comman is encoder and be the left side of -i is decoder, the order of this elelemt effect the result?
Q4- how to use python code for capture the frames?
root@heshunchao-desktop:/home/ffmpeg# ./ffmpeg -c:v h264_nvmpi -i 1.264 -f null -
ffmpeg version 82a3a62 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1)
configuration: --enable-nvmpi
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
[h264 @ 0x5581d15570] SEI type 128 size 576 truncated at 128
[h264 @ 0x5581d15570] SEI type 128 size 576 truncated at 95
[h264 @ 0x5581d15570] SEI type 128 size 576 truncated at 128
Last message repeated 2 times
Input #0, h264, from '1.264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 1920x1080, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Failed to query video capabilities: Inappropriate ioctl for device
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading sys.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_nvmpi) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
NVMAP_IOC_READ failed: Interrupted system call
NVMAP_IOC_READ: Offset 0 SrcStride 2048 pDst 0x7f84005dc0 DstStride 1920 Count 540
NVMAP_IOC_READ failed: Interrupted system call
NVMAP_IOC_READ: Offset 2228224 SrcStride 1024 pDst 0x7f84005de0 DstStride 960 Count 540
NVMAP_IOC_READ failed: Invalid argument
NVMAP_IOC_READ: Offset 2883584 SrcStride 1024 pDst 0x7f84005e00 DstStride 960 Count 2048
NVMAP_IOC_READ failed: Interrupted system call
NVMAP_IOC_READ: Offset 0 SrcStride 2048 pDst 0x7f84007890 DstStride 1920 Count 540
NVMAP_IOC_READ failed: Interrupted system call
NVMAP_IOC_READ: Offset 2228224 SrcStride 1024 pDst 0x7f840078b0 DstStride 960 Count 540
NVMAP_IOC_READ failed: Invalid argument
NVMAP_IOC_READ: Offset 2883584 SrcStride 1024 pDst 0x7f840078d0 DstStride 960 Count 2048
Segmentation fault (core dumped)
How to deal with this bug?
Sometimes I can see not working rtmp stream (data transmitted, but video doesn't work). In such case extradata in AVCodecContext has size many bigger that normal 22 byte:
extradata_size => 4194336 extra_data:0x00, 0x00, 0x00, 0x01, 0x61, 0xE1, 0x42, 0x80, 0x10, 0x70,...
or
extradata_size => 382 extra_data:0x00, 0x00, 0x00, 0x01, 0x61, 0xE1, 0x42, 0x80, 0x11, 0x70,
etc...
Normal extradata has size 22 byte:
0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x40, 0x33, 0x96, 0x54, 0x02, 0x80, 0x2D, 0xC8, 0x00, 0x00, 0x00, 0x01, 0x68, 0xCE, 0x3C, 0x80
(or similar)
Bug contains in "static av_cold int nvmpi_encode_init(AVCodecContext *avctx){" when code parse packet from nvmpi encoder.
Encoder h264_nvmpi [nvmpi H.264 encoder wrapper]:
General capabilities: delay hardware
Threading capabilities: none
Supported pixel formats: yuv420p
h264_nvmpi_encoder AVOptions:
-num_capture_buffers <int> E..V..... Number of buffers in the capture context (from 1 to 32) (default 10)
-profile <int> E..V..... Set the encoding profile (from -99 to 100) (default -99)
baseline E..V.....
main E..V.....
high E..V.....
-level <int> E..V..... Profile Level (from 0 to 62) (default auto)
auto E..V.....
1.0 E..V.....
1.1 E..V.....
1.2 E..V.....
1.3 E..V.....
2.0 E..V.....
2.1 E..V.....
2.2 E..V.....
3.0 E..V.....
3.1 E..V.....
3.2 E..V.....
4.0 E..V.....
4.1 E..V.....
4.2 E..V.....
5.0 E..V.....
5.1 E..V.....
-rc <int> E..V..... Override the preset rate-control (from -1 to INT_MAX) (default -1)
cbr E..V..... Constant bitrate mode
vbr E..V..... Variable bitrate mode
-preset <int> E..V..... Set the encoding preset (from 1 to 4) (default default)
default E..V.....
slow E..V.....
medium E..V.....
fast E..V.....
ultrafast E..V.....
Is there any example to set up the context required to use this backend for decoding in C?
I compared this to CUVID and it appears like it is missing the .hw_configs in the AVCodec which allow you to specify the device type (i.e. AV_HWDEVICE_TYPE_NVMPI)
static const AVCodecHWConfigInternal *nvmpi_hw_configs[] = {
&(const AVCodecHWConfigInternal) {
.public = {
.pix_fmt = ...,
.methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX | AV_CODEC_HW_CONFIG_METHOD_INTERNAL,
.device_type = AV_HWDEVICE_TYPE_NVMPI
},
.hwaccel = NULL,
},
NULL
};
Edit: It looks like I can do avcodec_find_decoder_by_name("h264_nvmpi")
But, I need to have some lookup of codec id's to names then. There's no easy way to tell it 'just use nvmpi'
const char* nvmpiName = "";
switch(sourceinfo->m_CodecId)
{
case AV_CODEC_ID_H264: nvmpiName = "h264_nvmpi"; break;
case AV_CODEC_ID_HEVC: nvmpiName = "hevc_nvmpi"; break;
case AV_CODEC_ID_VP8: nvmpiName = "vp8_nvmpi"; break;
case AV_CODEC_ID_VP9: nvmpiName = "vp9_nvmpi"; break;
case AV_CODEC_ID_MPEG2VIDEO: nvmpiName = "mpeg2video_nvmpi"; break;
case AV_CODEC_ID_MPEG4: nvmpiName = "mpeg4_nvmpi"; break;
default: break;
};
Have you considered to submit this patch to ffmpeg - to be a part of official ffmpeg code ?
Perhaps it makes sense to add to the manual that using "make -j 8" (or the number of cores that your CPU has) speeds up the build process?
Hi Sir,
I was trying to compile ffmpeg in jetson-nano.
I was getting this error after compiling it and running ./ffmpeg
ffmpeg: error while loading shared libraries: libnvmpi.so.1.0.0: cannot open shared object file: No such file or directory
Running on:
Linux version 4.9.140-tegra (buildbrain@mobile-u64-911) (gcc version 7.3.1 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05) ) #1 SMP PREEMPT Tue Jul 16 17:04:49 PDT 2019
doneill@jetson:~$ ffmpeg -re -vcodec h264_nvmpi -i ./2019-01-06\ 04-07-25.mkv -r 30 -profile:v high -level 4.2 -b:v 720k -ar 44100 -ab 128k -threads 4 -vcodec h264_nvmpi -acodec libmp3lame -flags +global_header -f matroska test.mkv
ffmpeg version git-2019-10-16-1e35519 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1)
configuration: --enable-nvmpi --enable-cuda-nvcc --enable-nonfree --enable-shared --enable-gpl --nvcc=/usr/local/cuda-10.0/bin/nvcc --enable-libmp3lame --enable-libopus --enable-librtmp --enable-libx264
libavutil 56. 35.101 / 56. 35.101
libavcodec 58. 59.102 / 58. 59.102
libavformat 58. 33.100 / 58. 33.100
libavdevice 58. 9.100 / 58. 9.100
libavfilter 7. 63.100 / 7. 63.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, matroska,webm, from './2019-01-06 04-07-25.mkv':
Metadata:
ENCODER : Lavf57.83.100
Duration: 00:05:24.53, start: 0.000000, bitrate: 3627 kb/s
Stream #0:0: Video: h264 (Main), yuv420p(tv, bt470bg/unknown/unknown, progressive), 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1k tbn, 60 tbc (default)
Metadata:
DURATION : 00:05:24.533000000
Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
Metadata:
title : Track1
DURATION : 00:05:24.480000000
File 'test.mkv' already exists. Overwrite? [y/N] y
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_nvmpi) -> h264 (h264_nvmpi))
Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
875967048
842091865
H264: Profile = 100, Level = 42
Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
Error initializing output stream 0:0 --
Segmentation fault (core dumped)
doneill@jetson:~$
Using libx264 works as expected:
doneill@jetson:~$ ffmpeg -re -vcodec h264_nvmpi -i ./2019-01-06\ 04-07-25.mkv -r 30 -profile:v high -level 4.2 -b:v 720k -ar 44100 -ab 128k -threads 4 -vcodec libx264 -acodec libmp3lame -flags +global_header -f matroska test.mkv
ffmpeg version git-2019-10-16-1e35519 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1)
configuration: --enable-nvmpi --enable-cuda-nvcc --enable-nonfree --enable-shared --enable-gpl --nvcc=/usr/local/cuda-10.0/bin/nvcc --enable-libmp3lame --enable-libopus --enable-librtmp --enable-libx264
libavutil 56. 35.101 / 56. 35.101
libavcodec 58. 59.102 / 58. 59.102
libavformat 58. 33.100 / 58. 33.100
libavdevice 58. 9.100 / 58. 9.100
libavfilter 7. 63.100 / 7. 63.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, matroska,webm, from './2019-01-06 04-07-25.mkv':
Metadata:
ENCODER : Lavf57.83.100
Duration: 00:05:24.53, start: 0.000000, bitrate: 3627 kb/s
Stream #0:0: Video: h264 (Main), yuv420p(tv, bt470bg/unknown/unknown, progressive), 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1k tbn, 60 tbc (default)
Metadata:
DURATION : 00:05:24.533000000
Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
Metadata:
title : Track1
DURATION : 00:05:24.480000000
File 'test.mkv' already exists. Overwrite? [y/N] y
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_nvmpi) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[libx264 @ 0x55a2168a30] using SAR=1/1
[libx264 @ 0x55a2168a30] using cpu capabilities: ARMv8 NEON
[libx264 @ 0x55a2168a30] profile High, level 4.2
[libx264 @ 0x55a2168a30] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=4 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=720 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'test.mkv':
Metadata:
encoder : Lavf58.33.100
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 720 kb/s, 30 fps, 1k tbn, 30 tbc (default)
Metadata:
DURATION : 00:05:24.533000000
encoder : Lavc58.59.102 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/720000 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
title : Track1
DURATION : 00:05:24.480000000
encoder : Lavc58.59.102 libmp3lame
frame= 398 fps= 17 q=-1.0 Lsize= 1275kB time=00:00:13.42 bitrate= 777.8kbits/s speed=0.567x
video:1057kB audio:210kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.573169%
[libx264 @ 0x55a2168a30] frame I:2 Avg QP:34.75 size: 20989
[libx264 @ 0x55a2168a30] frame P:113 Avg QP:39.36 size: 4858
[libx264 @ 0x55a2168a30] frame B:283 Avg QP:42.74 size: 1735
[libx264 @ 0x55a2168a30] consecutive B-frames: 0.8% 6.0% 21.9% 71.4%
[libx264 @ 0x55a2168a30] mb I I16..4: 36.3% 53.0% 10.7%
[libx264 @ 0x55a2168a30] mb P I16..4: 11.9% 25.0% 0.3% P16..4: 20.7% 1.3% 0.6% 0.0% 0.0% skip:40.1%
[libx264 @ 0x55a2168a30] mb B I16..4: 1.1% 1.6% 0.0% B16..8: 24.6% 0.7% 0.0% direct: 0.8% skip:71.2% L0:46.0% L1:53.4% BI: 0.6%
[libx264 @ 0x55a2168a30] final ratefactor: 37.98
[libx264 @ 0x55a2168a30] 8x8 transform intra:65.5% inter:93.4%
[libx264 @ 0x55a2168a30] coded y,uvDC,uvAC intra: 7.2% 32.9% 4.2% inter: 2.0% 6.2% 0.0%
[libx264 @ 0x55a2168a30] i16 v,h,dc,p: 36% 42% 9% 13%
[libx264 @ 0x55a2168a30] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 11% 65% 1% 2% 1% 2% 1% 1%
[libx264 @ 0x55a2168a30] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 25% 28% 4% 6% 4% 5% 4% 3%
[libx264 @ 0x55a2168a30] i8c dc,h,v,p: 75% 14% 10% 1%
[libx264 @ 0x55a2168a30] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x55a2168a30] ref P L0: 63.9% 11.6% 17.0% 7.5%
[libx264 @ 0x55a2168a30] ref B L0: 85.0% 11.9% 3.2%
[libx264 @ 0x55a2168a30] ref B L1: 95.6% 4.4%
[libx264 @ 0x55a2168a30] kb/s:652.52
doneill@jetson:~$
I've also tried decoding with libx264 instead, to feed the encoder, but get the same results.
Hi,
When I stream .264 file over network and decoding with jetson-nano does work, but when I stream .mkv stream file, the decoding doesn't work. why?
I use these elemets:
ffmpeg -c:v h264_nvmpi -i -c:v rawvideo -f avi out.mkv
but when I don't use -c:v h264_nvmpi , work corectly, why?
PTS/DTS return as PTS % 1000000
avcodec_send_frame(); <= pts: 1000123
avcodec_receive_packet() => pts: 123
Error:
[flv @ 0x55ceac0a60] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 999999 >= 32
Jetson Xavier
When trying to decode a video with ffplay I get the following error on a 4k h264 video.
I also attached a trace log if that helps: ffplay.log
I used the following command: ./ffplay feather_reflow-4K.mp4 -codec:v h264_nvmpi
Running L4T 32.3.1 on Jetson Nano.
Transform failed
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Hi,
i'm missing CRF Encoding ?!
Will this be added ?
Dear sir,
When i try to decode four 720p h264 videos, i found that it's cpu is similar with software decoder, about 310% with GPU 35%.
Any idea for this?
thanks.
$ ffmpeg -loglevel debug -y -f rawvideo -s 480x272 -i /dev/zero -c:v h264_nvmpi foo.mp4
ffmpeg version 61853f7 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1)
configuration: --prefix=/usr --enable-nvmpi --disable-gpl
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rawvideo'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '480x272'.
Reading option '-i' ... matched as input url with argument '/dev/zero'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'h264_nvmpi'.
Reading option 'foo.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url /dev/zero.
Applying option f (force format) with argument rawvideo.
Applying option s (set frame size (WxH or abbreviation)) with argument 480x272.
Successfully parsed a group of options.
Opening an input file: /dev/zero.
[rawvideo @ 0x5588804780] Opening '/dev/zero' for reading
[file @ 0x5588805190] Setting default whitelist 'file,crypto'
[rawvideo @ 0x5588804780] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[rawvideo @ 0x5588804780] All info found
[rawvideo @ 0x5588804780] After avformat_find_stream_info() pos: 195840 bytes read:195840 seeks:0 frames:1
Input #0, rawvideo, from '/dev/zero':
Duration: N/A, start: 0.000000, bitrate: 39168 kb/s
Stream #0:0, 1, 1/25: Video: rawvideo, 1 reference frame (I420 / 0x30323449), yuv420p, 480x272, 0/1, 39168 kb/s, 25 tbr, 25 tbn, 25 tbc
Successfully opened the file.
Parsing a group of options: output url foo.mp4.
Applying option c:v (codec name) with argument h264_nvmpi.
Successfully parsed a group of options.
Opening an output file: foo.mp4.
[file @ 0x55887eb5a0] Setting default whitelist 'file,crypto'
Successfully opened the file.
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_nvmpi))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[rawvideo @ 0x5588806b40] PACKET SIZE: 195840, STRIDE: 720
detected 4 logical cores
[graph 0 input from stream 0:0 @ 0x55887e3ee0] Setting 'video_size' to value '480x272'
[graph 0 input from stream 0:0 @ 0x55887e3ee0] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 0x55887e3ee0] Setting 'time_base' to value '1/25'
[graph 0 input from stream 0:0 @ 0x55887e3ee0] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0x55887e3ee0] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x55887e3ee0] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x55887e3ee0] w:480 h:272 pixfmt:yuv420p tb:1/25 fr:25/1 sar:0/1 sws_param:flags=2
[format @ 0x55888162c0] Setting 'pix_fmts' to value 'yuv420p'
[AVFilterGraph @ 0x55887f79f0] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
875967048
842091865
H264: Profile = 77, Level = 51
(And then it just sits, there, a non-patched ffmpeg works fine.)
Hello, first of all, congratulations for your work!
I was able to succesfully run
ffmpeg -i test.avi -c:v h264_nvmpi result.mp4
but I am having problems when running h264_nvmpi with "encode_example.c" from FFMPEG 4.2. The example is in the official ffmpeg folder and runs with other encoders, but when using with h264_nvmpi I got the following error:
./encode_video result.mp4 h264_nvmpi
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
875967048
842091865
H264: Profile = 77, Level = 51
Send frame 0
Send frame 1
Send frame 2
Send frame 3
Send frame 4
Send frame 5
Write packet 0 (size= 5823)
Segmentation fault (core dumped)
Have you succeed to encode video with h264_nvmpi in a C/C++ project?
Thanks in advance
First off thanks a million for the project! hardware decoding with ffmpeg on jetson-tx1/nano/x2 has been a long time coming!
I am noticing some issues with deinterlacing on my TX1. I built mpv against the nvmpi patched ffmpeg and I am noticing some issues with choppy deinterlacing.
How can we switch the deinterlacing mode with NVMEDIA/NVMPI decoding?
i grepped ffmpeg and your repo for NVMEDIA_DEINTERLACE_TYPE and didnt see anything so just curious if this is possible. Thanks in advance! Much appreciation for this repo!!
first ,thanks for your work.
i met some probles, when i run ffmpeg -re -i /dev/video1 -c:v h264 -tune zerolatency -payload_type 103 -r 20 -s 640x480 -an -f rtp rtp://106.53.95.37:56408 > test.sdp
The following error occurred:
ffmpeg version 03d6632 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) configuration: --enable-nvmpi libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 Unrecognized option 'tune'. Error splitting the argument list: Option not found
Is there a solution, thank you
Hello!
I was trying to decode a DVD rip I made using this command: ffmpeg -c:v mpeg2_nvmpi -i title_t00.mkv -c:v hevc_nvmpi -c:a flac boondocks_01.mkv
, but this is the result I got:
tombert@jetson1:/tank/boondocks_disc_1$ ffmpeg -c:v mpeg2_nvmpi -i title_t00.mkv -c:v hevc_nvmpi -c:a flac boondocks_01.mkv
ffmpeg version d1e8be3 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
configuration: --enable-nvmpi
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
Input #0, matroska,webm, from 'title_t00.mkv':
Metadata:
encoder : libmakemkv v1.14.5 (1.3.5/1.4.7) x86_64-linux-gnu
creation_time : 2020-04-21T00:08:33.000000Z
Duration: 00:19:58.16, start: 0.000000, bitrate: 5303 kb/s
Chapter #0:0: start 0.000000, end 105.972533
Metadata:
title : Chapter 01
Chapter #0:1: start 105.972533, end 559.458900
Metadata:
title : Chapter 02
Chapter #0:2: start 559.458900, end 1165.631133
Metadata:
title : Chapter 03
Chapter #0:3: start 1165.631133, end 1196.662133
Metadata:
title : Chapter 04
Chapter #0:4: start 1196.662133, end 1198.163633
Metadata:
title : Chapter 05
Stream #0:0(eng): Video: mpeg2video (Main), yuv420p(tv, top first), 720x480 [SAR 32:27 DAR 16:9], SAR 186:157 DAR 279:157, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc
Metadata:
BPS-eng : 4904729
DURATION-eng : 00:19:58.163633333
NUMBER_OF_FRAMES-eng: 35909
NUMBER_OF_BYTES-eng: 734583144
SOURCE_ID-eng : 0100E0
_STATISTICS_WRITING_APP-eng: MakeMKV v1.14.5 linux(x64-release)
_STATISTICS_WRITING_DATE_UTC-eng: 2020-04-21 00:08:33
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
title : Stereo
BPS-eng : 192000
DURATION-eng : 00:19:58.144000000
NUMBER_OF_FRAMES-eng: 37442
NUMBER_OF_BYTES-eng: 28755456
SOURCE_ID-eng : 0180BD
_STATISTICS_WRITING_APP-eng: MakeMKV v1.14.5 linux(x64-release)
_STATISTICS_WRITING_DATE_UTC-eng: 2020-04-21 00:08:33
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
Stream #0:2(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
title : Stereo
BPS-eng : 192000
DURATION-eng : 00:19:58.144000000
NUMBER_OF_FRAMES-eng: 37442
NUMBER_OF_BYTES-eng: 28755456
SOURCE_ID-eng : 0181BD
_STATISTICS_WRITING_APP-eng: MakeMKV v1.14.5 linux(x64-release)
_STATISTICS_WRITING_DATE_UTC-eng: 2020-04-21 00:08:33
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
Stream #0:3(fre): Subtitle: dvd_subtitle, 720x480 (default)
Metadata:
BPS-eng : 7700
DURATION-eng : 00:19:53.058255555
NUMBER_OF_FRAMES-eng: 318
NUMBER_OF_BYTES-eng: 1148322
SOURCE_ID-eng : 0120BD
_STATISTICS_WRITING_APP-eng: MakeMKV v1.14.5 linux(x64-release)
_STATISTICS_WRITING_DATE_UTC-eng: 2020-04-21 00:08:33
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
Stream #0:4(eng): Subtitle: subrip
Metadata:
BPS-eng : 166
DURATION-eng : 00:19:18.688000000
NUMBER_OF_FRAMES-eng: 477
NUMBER_OF_BYTES-eng: 24137
SOURCE_ID-eng : 0100E0
_STATISTICS_WRITING_APP-eng: MakeMKV v1.14.5 linux(x64-release)
_STATISTICS_WRITING_DATE_UTC-eng: 2020-04-21 00:08:33
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 267
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 267
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (mpeg2_nvmpi) -> hevc (hevc_nvmpi))
Stream #0:1 -> #0:1 (ac3 (native) -> flac (native))
Stream #0:4 -> #0:2 (subrip (srt) -> ass (ssa))
Press [q] to stop, [?] for help
[flac @ 0x558404dac0] encoding as 24 bits-per-sample
NVMEDIA: NvMediaMixerInit: 119: frameWidth = 720, frameHeight = 480
NVMEDIA: DeinterlaceThread: 782: DeinterlaceThread is created
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 8
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8
892744264
842091865
Output #0, matroska, to 'boondocks_01.mkv':
Metadata:
encoder : Lavf58.29.100
Chapter #0:0: start 0.000000, end 105.972533
Metadata:
title : Chapter 01
Chapter #0:1: start 105.972533, end 559.458900
Metadata:
title : Chapter 02
Chapter #0:2: start 559.458900, end 1165.631133
Metadata:
title : Chapter 03
Chapter #0:3: start 1165.631133, end 1196.662133
Metadata:
title : Chapter 04
Chapter #0:4: start 1196.662133, end 1198.163633
Metadata:
title : Chapter 05
Stream #0:0(eng): Video: hevc (hevc_nvmpi), yuv420p, 720x480 [SAR 186:157 DAR 279:157], q=-1--1, 2000 kb/s, 29.97 fps, 1k tbn, 29.97 tbc
Metadata:
BPS-eng : 4904729
DURATION-eng : 00:19:58.163633333
NUMBER_OF_FRAMES-eng: 35909
NUMBER_OF_BYTES-eng: 734583144
SOURCE_ID-eng : 0100E0
_STATISTICS_WRITING_APP-eng: MakeMKV v1.14.5 linux(x64-release)
_STATISTICS_WRITING_DATE_UTC-eng: 2020-04-21 00:08:33
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
encoder : Lavc58.54.100 hevc_nvmpi
Stream #0:1(eng): Audio: flac ([172][241][0][0] / 0xF1AC), 48000 Hz, stereo, s32 (24 bit), 128 kb/s (default)
Metadata:
title : Stereo
BPS-eng : 192000
DURATION-eng : 00:19:58.144000000
NUMBER_OF_FRAMES-eng: 37442
NUMBER_OF_BYTES-eng: 28755456
SOURCE_ID-eng : 0180BD
_STATISTICS_WRITING_APP-eng: MakeMKV v1.14.5 linux(x64-release)
_STATISTICS_WRITING_DATE_UTC-eng: 2020-04-21 00:08:33
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
encoder : Lavc58.54.100 flac
Stream #0:2(eng): Subtitle: ass (ssa)
Metadata:
BPS-eng : 166
DURATION-eng : 00:19:18.688000000
NUMBER_OF_FRAMES-eng: 477
NUMBER_OF_BYTES-eng: 24137
SOURCE_ID-eng : 0100E0
_STATISTICS_WRITING_APP-eng: MakeMKV v1.14.5 linux(x64-release)
_STATISTICS_WRITING_DATE_UTC-eng: 2020-04-21 00:08:33
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
encoder : Lavc58.54.100 ssa
NVMEDIA: H265 : Profile : 3
Segmentation fault (core dumped)
This also happens if I omit the hardware decoder (-c:v mpeg2_nvmpi
) and just go straight to the -i
Is there something I'm missing or doing wrong?
Is there any way to get this to build/install a static library version as well? Or any pointers for how-to? Trying to create a static build of ffmpeg and running into lots of pkg-config --static errors. Thanks!
Stream keeps playing past end of file in ffplay. Havnt tested in ffmpeg directly. Tested with H264 decoding. ffplay goes to black screen at end, but stays open, and decoder is still active. If this is the case for encoding as well, that could be problematic at best, and a space nightmare at worst.
No auto detection of nvmpi codecs in ffmpeg/ffplay. Meaning you have to specify which decoder you want to use on command line. For apps that call ffmpeg direct, it would be nice if ffmpeg handled this detection automatically like it does for most other decoders/encoders.
Other than that, awesome project, it makes video encoding/decoding much easier than nvidia's broken OMX/Gstreamer implementation, and brings more support for different apps.
Dear Sir,
When I try to decode USB camera, i get failed results as below:
"....
Code type or id mismatches.
...
"
AV_PIX_FMT_YUYV422 can't support?
I am trying to receive video stream from ffserver with this config:
HttpPort 8090
HttpBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 500000
CustomLog -
RTSPPort 554
RTSPBindAddress 0.0.0.0
<Stream s>
Format rtp
File "../data/some.mp4"
NoLoop
</Stream>
this works perfectly well with h264 video decoder. But with h264_nvmpi decoding never starts. I've tried to debug nvmpi_dec code a bit. NvVideoDecoder was created sucessfully, but it never emits V4L2_EVENT_RESOLUTION_CHANGE, so respondToResolutionEvent is never invoked, so rest of decoding never happens. What can be a reason for that?
Hi,
I am trying to use with https://github.com/KhaosT/homebridge-camera-ffmpeg. However seems patched ffmpeg is not able to recognize ioctl
Log attached.
Input #0, rtsp, from 'rtsp://xxxxx':
Metadata:
title : Media Presentation
Duration: N/A, start: 0.299667, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 60 tbc
Failed to query video capabilities: Inappropriate ioctl for device
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading sys.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_nvmpi) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
NVMAP_IOC_READ failed: Interrupted system call
NVMAP_IOC_READ: Offset 0 SrcStride 1280 pDst 0x7f84006330 DstStride 1280 Count 360
NVMAP_IOC_READ failed: Interrupted system call
NVMAP_IOC_READ: Offset 1048576 SrcStride 768 pDst 0x7f84006350 DstStride 640 Count 360
NVMAP_IOC_READ failed: Invalid argument
NVMAP_IOC_READ: Offset 1441792 SrcStride 768 pDst 0x7f84006370 DstStride 640 Count 1280
NVMAP_IOC_READ failed: Interrupted system call
NVMAP_IOC_READ: Offset 0 SrcStride 1280 pDst 0x7f84007e00 DstStride 1280 Count 360
NVMAP_IOC_READ failed: Interrupted system call
NVMAP_IOC_READ: Offset 1048576 SrcStride 768 pDst 0x7f84007e20 DstStride 640 Count 360
NVMAP_IOC_READ failed: Invalid argument
NVMAP_IOC_READ: Offset 1441792 SrcStride 768 pDst 0x7f84007e40 DstStride 640 Count 1280
Segmentation fault (core dumped)
galasso@jet2:~/jetson-ffmpeg/build$ cmake ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIB_V4L2
linked by target "nvmpi" in directory /home/galasso/jetson-ffmpeg
Hi,
decoding is not working
It can not decode sample Jetson Nano file
./ffmpeg -c:v h264_nvmpi -i /usr/src/nvidia/tegra_multimedia_api/data/Video/sample_outdoor_car_1080p_10fps.h264 -f null -
it throws Segmentation fault (core dumped)
Hi, I tried using the Decoder with Moonlight-qt for using the jetson nano as a streaming client.
Moonlight probes ffmpeg for codec capabilities by rapidly opening and closing the codecs.
Currently this results in a segfault because the v4l device is closed while it is still being used.
The capture thread needs to be joined before deleting ctx->dec in nvmpi_decoder_close.
The problem is this results in deadlocks in the external function v4l2_ioctl(fd,VIDIOC_DQEVENT, &ev);.
While technically this is a problem on nvidias side where the driver should return when the codec is signaled to close, it just doesn't. It keeps blocking forever resulting in a frozen application that has to be killed.
I tried just killing the thread in the decoder_close function and moving the lock around but couldn't find a solution. Right now i have more exit points in the capture loop in case the eos flag changes at some other point except the beginning.
I also decreased the timeout in ctx->dec->dqEvent(v4l2Event, 50000); to like 500 or 5000 since it would kill the codec before it received the first event, also resulting in a deadlock.
When the decoder runs, it works perfectly with decoding a HEVC stream in under 2ms. But it freezes 2 out of 3 when closing. I could clean up my testing code a bit and post a diff it it helps. But i don't know if it has any influence on the general transcoding case.
Any ideas?
Both stream are recorded from Hikvision DS-2CD3955FWD-IWS(not start with iframe)
Hello, Sir,
When encoding a H264 file, can't find valid SPS/PPS w/ VLC player,,just show "waiting for PPS/SPS"...
dou you know why?
Thanks.
First - thanks for this patch! I was getting some random crashes decoding an h264 stream - tracing back to differences in frame size of the gpu and stream image... likely due to network errors.
av_assert0 aborts and bombs ffmpeg in a way unrecoverable by python. Swap out the following function in libavutil/imgutils.c to just skip the frame:
static void image_copy_plane(uint8_t *dst, ptrdiff_t dst_linesize,
const uint8_t *src, ptrdiff_t src_linesize,
ptrdiff_t bytewidth, int height)
{
if (!dst || !src)
return;
// av_assert0(FFABS(src_linesize) >= bytewidth);
// av_assert0(FFABS(dst_linesize) >= bytewidth);
if (FFABS(src_linesize) < bytewidth || FFABS(dst_linesize) < bytewidth){
av_log(NULL, AV_LOG_ERROR, "Bytewidth greater than line\n");
}
else{
for (;height > 0; height--) {
memcpy(dst, src, bytewidth);
dst += dst_linesize;
src += src_linesize;
}
}
}
With H264 use ffmpeg on other machines I was able to control the CRF and encoding speed. See link below. All this seems missing.
https://williamyaps.blogspot.com/2017/01/ffmpeg-encoding-h264-decrease-size.html
nvmpi_encoder_put_frame: 1683 us
nvmpi_encoder_get_packet: 1650 us
nvmpi_encoder_put_frame: 1716 us
nvmpi_encoder_get_packet: 1683 us
nvmpi_encoder_put_frame: 1749 us
nvmpi_encoder_get_packet: 1716 us
nvmpi_encoder_put_frame: 1782 us
nvmpi_encoder_get_packet: 1749 us
nvmpi_encoder_put_frame: 1815 us
nvmpi_encoder_get_packet: 1452 us <<<
[flv @ 0x55c3b1e880] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 1749 >= 1452
Like circular buffer's error, but I don't know.
first , thanks for your work,this is great.
Now i comlile this on my jetson tx2. when i run ./configure --enable-nvmpi
error appears:
`ERROR: nvmpi not found using pkg-config
If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
`
I tried to find nvmpi in the system,
When I type pkg-config --list-all | grep nvmpi
in the command line,
nvidia@nvidia:~/jetsonTX2-ffmpeg/ffmpeg$ pkg-config --list-all | grep nvmpi nvmpi nvmpi - nvidia multimedia api
I cannot find any solutions,can you give me some advices.thanks for your help.
I follow the steps for installing the jetson-ffmpeg. And I execute the command: ffmpeg -i input.mp4 -c:v h264_nvmpi out.mp4.
It show Unknown encoder 'h264_nvmpi'. I dont know where I am wrong? Can Somebody tell me how to install correctly thanks!
Following the steps it used to work for me.
now:
git clone https://github.com/jocover/jetson-ffmpeg.git
cd jetson-ffmpeg
mkdir build
cd build
cmake .. <--- I GET THIS OUTPUT ON TERMINAL HERE
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
CMake Error at CMakeLists.txt:17 (add_library):
Cannot find source file:
/usr/src/jetson_multimedia_api/samples/common/classes/NvBuffer.cpp
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error: CMake can not determine linker language for target: nvmpi
CMake Error: Cannot determine link language for target "nvmpi".
-- Generating done
-- Build files have been written to: /home/nano1/src/jetson-ffmpeg/build
I get a segfault when running under Jetpack 4.4 on a Jetson Nano trying to transcode a h264/avc into a hevc:
$ sudo ffmpeg -i example.mp4 -c:v hevc_nvmpi test.mp4
[sudo] password for dan:
ffmpeg version 03d6632 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
configuration: --enable-nvmpi
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'example.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2020-07-17T14:51:51.000000Z
com.android.version: 10
Duration: 00:03:31.41, start: 0.000000, bitrate: 42036 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt2020nc/bt2020/bt709), 3840x2160, 41981 kb/s, SAR 1:1 DAR 16:9, 29.64 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2020-07-17T14:51:51.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 96 kb/s (default)
Metadata:
creation_time : 2020-07-17T14:51:51.000000Z
handler_name : SoundHandle
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> hevc (hevc_nvmpi))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 8
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8
892744264
842091865
NVMEDIA: H265 : Profile : 3
Output #0, mp4, to 'test.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
com.android.version: 10
encoder : Lavf58.29.100
Stream #0:0(eng): Video: hevc (hevc_nvmpi) (hev1 / 0x31766568), yuv420p, 2160x3840 [SAR 1:1 DAR 9:16], q=-1--1, 2000 kb/s, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
encoder : Lavc58.54.100 hevc_nvmpi
creation_time : 2020-07-17T14:51:51.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -0.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2020-07-17T14:51:51.000000Z
handler_name : SoundHandle
encoder : Lavc58.54.100 aac
Segmentation fault
thank jocover's work
the decoder works sucessful to decode mp4 file,
but I got Segmentation fault when run encode example
time /usr/local/lib/ffmpeg-4.2/bin/ffmpeg -c:v h264_nvmpi -i /home/nari/test.mp4 test.yuv
time /usr/local/lib/ffmpeg-4.2/bin/ffmpeg -f rawvideo -s:v 544x960 -r 30 -pix_fmt nv12 -i test.yuv -c:v h264_nvmpi -preset slow -bf 2 -g 150 test_encode.mp4
is it really a bug or i use wrong prams, hope someone give me some advise
Hello, Sir,
thanks for your great work and kindly share, I test this with Nano, just get below info:
Input #0, h264, from '/home/work/workshop/tegra_multimedia_api/data/Video/sample_outdoor_car_1080p_10fps.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 10 fps, 10 tbr, 1200k tbn, 20 tbc
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_nvmpi) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: wrapped_avframe, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 10 fps, 10 tbn, 10 tbc
Metadata:
encoder : Lavc58.54.100 wrapped_avframe
frame= 568 fps=146 q=-0.0 Lsize=N/A time=00:00:58.80 bitrate=N/A speed=15.1x
video:297kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
NVMAP_IOC_READ failed: Interrupted system call
NVMAP_IOC_READ: Offset 0 SrcStride 2048 pDst 0x7fa5180130 DstStride 1920 Count 1080
nvbuf_utils: dmabuf_fd 1057 mapped entry NOT found
Segmentation fault (core dumped)
Did you hit this? my platform info is shown as below:
Ubuntu 18.04.3 LTS
Kernel Version: 4.9.140-tegra
CUDA 10.0.326
I compile with
--enable-nvmpi --enable-nonfree --enable-shared --enable-ffplay
and I installed libsdl2 with "apt install libsdl2-dev " to get ffplay built.
When running "ffplay -rtsp_transport udp rtsp://192.168.11.202:8554/unicast"
I get
dbus[29617]: arguments to dbus_message_new_method_call() were incorrect, assertion "path != NULL" failed in file ../../../dbus/dbus-message.c line 1362.
This is normally a bug in some application using the D-Bus library.
I make sure I can play the stream with gstreamer:
gst-launch-1.0 rtspsrc location="rtsp://192.168.11.202:8554/unicast" latency=100 ! rtph264depay ! h264parse ! omxh264dec ! nvoverlaysink overlay-x=0 overlay-y=20 overlay-w=960 overlay-h=540 overlay=2
What am I missing?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.