Alex-q-z / myh264

[MLSys '22 artifact] an incremental x264 video encoder for video analytics
7 stars 4 forks source link

Segmentation Fault in Encoding #2

Open ChristophReich1996 opened 2 years ago

ChristophReich1996 commented 2 years ago

Hi @Alex-q-z,

I managed to install your H.264 implementation, however, I run into a segmentation fault if I want to perform encoding.

My setup looks as follows. The operation mode is set to 20, and I want to encode just two PNG frames from the REDS dataset. The respective frames are attached (original license of the REDS dataset is CC BY 4.0 license). The image resolution is [H=720, W=1280], thus, my qp_matrix_file includes a matrix of shape [H=2 * 45=90, W=80]. However when running encoding by calling

ffmpeg -y -i 000/%08d.png -start_number 0 -qp 10 -pix_fmt yuv420p video.mp4

I run into the following segmentation fault message.

image

Do you have any idea what is causing this issue?

Thanks for your help, Christoph

To reproduce the issue here all required files.

Here the two REDS frames. The name (and path) of the first frame is 000/00000000.png and 000/00000001.png of the second frame.

00000000 00000001

Here is the operation_mode_file file (converted as a CSV to work with GitHub). The left side of each frame is should be encoded by qp=0 and the right side with qp=51.

qp_matrix_file.csv

ChristophReich1996 commented 2 years ago

When running with debug info I get the following output.

ffmpeg version N-102789-g072788c46e Copyright (c) 2000-2021 the FFmpeg developers  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --enable-libx264 --enable-gpl --enable-shared  libavutil      57.  0.100 / 57.  0.100  libavcodec     59.  1.102 / 59.  1.102  libavformat    59.  3.101 / 59.  3.101  libavdevice    59.  0.100 / 59.  0.100  libavfilter     8.  0.102 /  8.  0.102  libswscale      6.  0.100 /  6.  0.100  libswresample   4.  0.100 /  4.  0.100  libpostproc    56.  0.100 / 56.  0.100Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-i' ... matched as input url with argument 'assets/frame-1.png'.
Reading option 'assets/frame-2.png' ... matched as output url.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-start_number' ... matched as AVOption 'start_number' with argument '0'.
Reading option '-qp' ... matched as AVOption 'qp' with argument '10'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'.
Reading option 'video.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url assets/frame-1.png.
Successfully parsed a group of options.
Opening an input file: assets/frame-1.png.
[NULL @ 0x564b72ea99c0] Opening 'assets/frame-1.png' for reading[file @ 0x564b72eaa2c0] Setting default whitelist 'file,crypto,data'[png_pipe @ 0x564b72ea99c0] Format png_pipe probed with size=2048 and score=99[png_pipe @ 0x564b72ea99c0] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1[png_pipe @ 0x564b72ea99c0] After avformat_find_stream_info() pos: 1398402 bytes read:1398402 seeks:0 frames:1Input #0, png_pipe, from 'assets/frame-1.png':
  Duration: N/A, bitrate: N/A  Stream #0:0, 1, 1/25: Video: png, 1 reference frame, rgb24(pc), 1280x720, 0/1, 25 fps, 25 tbr, 25 tbnSuccessfully opened the file.
Parsing a group of options: output url assets/frame-2.png.
Successfully parsed a group of options.
Opening an output file: assets/frame-2.png.
Successfully opened the file.
Parsing a group of options: output url video.mp4.
Applying option pix_fmt (set pixel format) with argument yuv420p.
Successfully parsed a group of options.
Opening an output file: video.mp4.
[file @ 0x564b72ec0fc0] Setting default whitelist 'file,crypto,data'Successfully opened the file.
++++++++++ cp 0 ++++++++++detected 16 logical coresStream mapping:
  Stream #0:0 -> #0:0 (png (native) -> png (native))
  Stream #0:0 -> #1:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for helpcur_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)
++++++++++ cp 2 ++++++++++++++++++++ cp 2 ++++++++++1 times    Last message repeated 1 times[graph 0 input from stream 0:0 @ 0x564b72f178c0] Setting 'video_size' to value '1280x720'[graph 0 input from stream 0:0 @ 0x564b72f178c0] Setting 'pix_fmt' to value '2'[graph 0 input from stream 0:0 @ 0x564b72f178c0] Setting 'time_base' to value '1/25'[graph 0 input from stream 0:0 @ 0x564b72f178c0] Setting 'pixel_aspect' to value '0/1'[graph 0 input from stream 0:0 @ 0x564b72f178c0] Setting 'frame_rate' to value '25/1'[graph 0 input from stream 0:0 @ 0x564b72f178c0] w:1280 h:720 pixfmt:rgb24 tb:1/25 fr:25/1 sar:0/1[format @ 0x564b72f17ec0] Setting 'pix_fmts' to value 'rgb24|rgba|rgb48be|rgba64be|pal8|gray|ya8|gray16be|ya16be|monob'[AVFilterGraph @ 0x564b72f15c80] query_formats: 4 queried, 3 merged, 0 already done, 0 delayedOutput #0, image2, to 'assets/frame-2.png':
  Metadata:
    encoder         : Lavf59.3.101  Stream #0:0, 0, 1/25: Video: png, 1 reference frame, rgb24(pc, progressive), 1280x720 (0x0), 0/1, q=2-31, 200 kb/s, 25 fps, 25 tbn    Metadata:
      encoder         : Lavc59.1.102 pngClipping frame in rate conversion by 0.000008[graph 1 input from stream 0:0 @ 0x564b73399dc0] Setting 'video_size' to value '1280x720'[graph 1 input from stream 0:0 @ 0x564b73399dc0] Setting 'pix_fmt' to value '2'[graph 1 input from stream 0:0 @ 0x564b73399dc0] Setting 'time_base' to value '1/25'[graph 1 input from stream 0:0 @ 0x564b73399dc0] Setting 'pixel_aspect' to value '0/1'[graph 1 input from stream 0:0 @ 0x564b73399dc0] Setting 'frame_rate' to value '25/1'[graph 1 input from stream 0:0 @ 0x564b73399dc0] w:1280 h:720 pixfmt:rgb24 tb:1/25 fr:25/1 sar:0/1[format @ 0x564b7339a3c0] Setting 'pix_fmts' to value 'yuv420p'[auto_scaler_0 @ 0x564b7339a8c0] Setting 'flags' to value 'bicubic'[auto_scaler_0 @ 0x564b7339a8c0] w:iw h:ih flags:'bicubic' interl:0[format @ 0x564b7339a3c0] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format'[AVFilterGraph @ 0x564b73398200] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed[auto_scaler_0 @ 0x564b7339a8c0] w:1280 h:720 fmt:rgb24 sar:0/1 -> w:1280 h:720 fmt:yuv420p sar:0/1 flags:0x4Segmentation fault (core dumped)

Maybe this helps...

szh2022 commented 1 year ago

same issue.