aws-robotics / kinesisvideo-encoder-common

ROS packages for facilitating the use of AWS cloud services.
GNU Lesser General Public License v2.1
9 stars 12 forks source link

Update codec opening test to include opts and params #37

Closed ryanewel closed 5 years ago

ryanewel commented 5 years ago

Signed-off-by: Ryan Newell ryanewel@amazon.com

Issue #, if available: https://github.com/aws-robotics/kinesisvideo-encoder-common/issues/36

Description of changes: Rearrange the codec opening logic so that parameters are included Unit tests passed Tested following cases manually

Running with hardware encoding enabled Node correctly uses hardware encoding Saw video in Kinesis console

$ ros2 run h264_video_encoder h264_video_encoder __params:=video_encoder_config.yaml
[INFO] [h264_video_encoder]: [RunEncoderNode] Starting H264 Video Node...
[INFO] [h264_video_encoder]: [InitializeCommunication] subscribed to /videofile/image_raw...
[INFO] [h264_video_encoder]: [InitializeCommunication] subscribed to /image_metadata for metadata...
[INFO] [h264_video_encoder]: [open_codec] Attempting to open codec: h264_omx
[h264_omx @ 0x240cb70] Using OMX.broadcom.video_encode
[INFO] [h264_video_encoder]: [Initialize] Encoding using h264_omx codec

Running with an unavailable codec specified in config Node then exited as intended

$ ros2 run h264_video_encoder h264_video_encoder __params:=video_encoder_config.yaml
[INFO] [h264_video_encoder]: [RunEncoderNode] Starting H264 Video Node...
[INFO] [h264_video_encoder]: [InitializeCommunication] subscribed to /videofile/image_raw...
[INFO] [h264_video_encoder]: [InitializeCommunication] subscribed to /image_metadata for metadata...
[ERROR] [h264_video_encoder]: [Initialize] hevc_amf codec not found!

Running node with broken hardware encoding Node successfully backs off to software encoding, Saw video in kinesis console

ros2 run h264_video_encoder h264_video_encoder __params:=video_encoder_config.yaml
[INFO] [h264_video_encoder]: [RunEncoderNode] Starting H264 Video Node...
[INFO] [h264_video_encoder]: [InitializeCommunication] subscribed to /videofile/image_raw...
[INFO] [h264_video_encoder]: [InitializeCommunication] subscribed to /image_metadata for metadata...
[INFO] [h264_video_encoder]: [open_codec] Attempting to open codec: h264_omx
[h264_omx @ 0x18d04b0] libOMX_Core.so not found
[h264_omx @ 0x18d04b0] libOmxCore.so not found
[ERROR] [h264_video_encoder]: [open_codec] Could not open codec
[INFO] [h264_video_encoder]: [open_codec] Attempting to open codec: libx264
[libx264 @ 0x18d1500] using cpu capabilities: ARMv6 NEON
[libx264 @ 0x18d1500] profile High, level 2.1
[libx264 @ 0x18d1500] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=4 lookahead_threads=4 sliced_threads=1 slices=4 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=28 keyint_min=15 scenecut=40 intra_refresh=0 rc=abr mbtree=0 bitrate=512 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[INFO] [h264_video_encoder]: [Initialize] Encoding using libx264 codec

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

mm318 commented 5 years ago

Perhaps, we should just consider wrapping these raw SwsContext, AVCodecContext, AVFrame pointers into smart pointers (unique_ptr) with custom deleters.

codecov[bot] commented 5 years ago

Codecov Report

Merging #37 into master will increase coverage by 0.86%. The diff coverage is 89.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #37      +/-   ##
==========================================
+ Coverage   78.72%   79.59%   +0.86%     
==========================================
  Files           3        3              
  Lines         188      196       +8     
==========================================
+ Hits          148      156       +8     
  Misses         40       40
Flag Coverage Δ
#ROS_1 79.59% <89.74%> (+0.86%) :arrow_up:
#ROS_2 79.48% <89.74%> (+0.87%) :arrow_up:
#dashing 79.48% <89.74%> (+0.87%) :arrow_up:
#kinetic 76.41% <74.35%> (+2.07%) :arrow_up:
#melodic 79.48% <89.74%> (+0.87%) :arrow_up:
Impacted Files Coverage Δ
h264_encoder_core/src/h264_encoder.cpp 85.54% <89.74%> (+0.7%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 487b331...5daabb1. Read the comment docs.