jetson-ffmpeg icon indicating copy to clipboard operation
jetson-ffmpeg copied to clipboard

FFmpeg hangs while attempting to transcode a h264 video

Open lordjim1985 opened this issue 3 years ago • 14 comments

Hi,

can You advise why after sucessfull patching and buiding ffmpeg hangs while trying to transcode a h264 -> h264 video?

FFmpeg command line used:

./ffmpeg -i bbb_sunflower_1080p_30fps_normal.mp4 -c:v h264_nvmpi -b:v 5000k -b:a 128k -c:a aac -f mp4 test.mp4

I get the following:

Opening in BLOCKING MODE Opening in BLOCKING MODE NvMMLiteOpen : Block : BlockType = 4 ===== NVMEDIA: NVENC ===== NvMMLiteBlockCreate : Block : BlockType = 4 875967048 842091865 H264: Profile = 77, Level = 51 Got 0 size buffer in capture

And ffmpeg just sits there.

I'm using JetPack 4.5.1.

If I change the ffmpeg settings to create a hevc video it properly starts to transcode.

lordjim1985 avatar Mar 22 '21 18:03 lordjim1985

Same by me. I try now to revert the changes from 18. Mrz and if it works then.

manswiss avatar Mar 25 '21 08:03 manswiss

Strange, it also not work when I revert changes from 18. Mrz, and also when I revert changes from 1. Mrz. But I try the tool in the past (Feb 2021) and the it was working. Maybe it depends on a update from another component from atp.

manswiss avatar Mar 25 '21 09:03 manswiss

I've installed all of the updates that were available. When I'll get back home I'll try to recompile it with updated dependecies.

lordjim1985 avatar Mar 25 '21 11:03 lordjim1985

I've tryed now with a blank jetson image without any updates. Same result. Now I will compile the jetson-ffmpeg without commits from 18.Mrz. Maybe it works then.

manswiss avatar Mar 25 '21 11:03 manswiss

It also not work. I don't know what is the source of the problem.

manswiss avatar Mar 25 '21 11:03 manswiss

Maybe it's a profile and level problem. I'll check different settings when I'll get back.

lordjim1985 avatar Mar 25 '21 11:03 lordjim1985

I've checked different source files and profiles and levels. I'm afraid it did not help. I'll try to compile again.

lordjim1985 avatar Mar 25 '21 17:03 lordjim1985

I've tried recompiling but also ffmpeg hangs after entering the command. I've been thinking (maybe it's a clue), when gstreamer transcodes he states that:

NvMMLiteOpen : Block : BlockType = 279 NVMEDIA: Reading vendor.tegra.display-size : status: 6 NvMMLiteBlockCreate : Block : BlockType = 279 Redistribute latency... NvMMLiteOpen : Block : BlockType = 4 ===== NVMEDIA: NVENC ===== NvMMLiteBlockCreate : Block : BlockType = 4 H264: Profile = 100, Level = 0

While ffmpeg states:

Opening in BLOCKING MODE Opening in BLOCKING MODE NvMMLiteOpen : Block : BlockType = 4 ===== NVMEDIA: NVENC ===== NvMMLiteBlockCreate : Block : BlockType = 4 875967048 842091865 H264: Profile = 100, Level = 51 Got 0 size buffer in capture

The Level part is interesting. Whatever profile I set, gstreamer always report Level = 0. Maybe something with the source libraries is broken or the've changed some options. From what I have seen in gstreamer also cabac-entropy-coding=1 parameter does not work. So that might be a clue that something is broken in the source.

lordjim1985 avatar Mar 25 '21 20:03 lordjim1985

Anyone happen to find a resolution to this?

pickledgator avatar Apr 08 '21 22:04 pickledgator

It could be fixed by checkout to 4ba259a

git clone https://github.com/jocover/jetson-ffmpeg.git && \
cd jetson-ffmpeg && \
git checkout 4ba259a && \
mkdir build && cd build && \
cmake .. && \
make && \
sudo make install && \
sudo ldconfig && \
git clone git://source.ffmpeg.org/ffmpeg.git -b release/4.2 --depth=1 && \
cd ffmpeg && \
cp ../ffmpeg_nvmpi.patch . && \
git apply ffmpeg_nvmpi.patch && \
./configure --enable-nvmpi && \
make && \
sudo make install

pi-null-mezon avatar Apr 27 '21 19:04 pi-null-mezon

Having the same issues with most recent build 3dff99c. I also tried building on 4ba259a that @pi-null-mezon brought up with no luck. It idles on Got 0 size buffer in capture e= 0kB time=00:00:00.14 bitrate= 2.6kbits/s speed=0.0795x

Full Console:

> /home/nano/jetson-ffmpeg/build/ffmpeg/ffmpeg \
> -i /home/nano/Downloads/test_1080p.mp4 \
> -c:v h264_nvmpi /home/nano/Downloads/re-encoded_test_1080p.mp4 \
> -b 2500k -minrate 850k -maxrate 3000k

ffmpeg version c9f3835 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
  configuration: --enable-nvmpi --enable-libpulse
  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
Trailing options were found on the commandline.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/nano/Downloads/test_1080p.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.36.100
  Duration: 00:02:30.13, start: 0.000000, bitrate: 10680 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 10424 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 255 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvmpi))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
Opening in BLOCKING MODE
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
875967048
842091865
H264: Profile = 77, Level = 51
NVMEDIA_ENC: bBlitMode is set to TRUE
Opening in BLOCKING MODE
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
875967048
842091865
H264: Profile = 77, Level = 51
Output #0, mp4, to '/home/nano/Downloads/re-encoded_test_1080p.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
    Stream #0:0(und): Video: h264 (h264_nvmpi) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 24 fps, 12288 tbn, 24 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.54.100 h264_nvmpi
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc58.54.100 aac
Got 0 size buffer in capture e=       0kB time=00:00:00.14 bitrate=   2.6kbits/s speed=0.0795x

IsaiahPapa avatar Apr 28 '21 20:04 IsaiahPapa

Ok I had the same problem and this is how I fixed it: You need to checkout to 7baa3d8, also you need to apply the patch from this version.

wget https://raw.githubusercontent.com/jocover/jetson-ffmpeg/7baa3d8232478b82799a90c37b86a986e4df1df2/ffmpeg_nvmpi.patch
git apply ffmpeg_nvmpi.patch

cnavarrete avatar Apr 29 '21 22:04 cnavarrete

It may be caused by FFmpeg frame linesize is different with NVBuffer, I temporarily canceled this submission

jocover avatar Apr 30 '21 02:04 jocover

It may be caused by FFmpeg frame linesize is different with NVBuffer, I temporarily canceled this submission

Not too savvy with this tech, but what @cnavarrete said works with regards to building and patching from 7baa3d8. I just did a fresh build about 10 minutes ago and it seems to be working great.

Thanks guys!

IsaiahPapa avatar Apr 30 '21 02:04 IsaiahPapa