• C
    Merge pull request #20978 from cudawarped:videocapture_read_raw_enchancement · 97c6ec6d
    cudawarped 提交于
    Add capacity to Videocapture to return the extraData from FFmpeg when required
    
    * Update rawMode to append any extra data recieved during the initial negotiation of an RTSP stream or during the parsing of an MPEG4 file header.
    For h264[5] RTSP streams this ensures the parameter sets if available are always returned on the first call to grab()/read() and has two purposes:
    1) To ensure the parameter sets are available even if they are not transmitted in band.  This is common for axis ip camera's.
    2) To allow callers of VideoCapture::grab()[read()] to write to split the raw stream over multiple files by appending the parameter sets to the begining of any new files.
    For (1) there is no alternative, for (2) if the parameter sets were provided in band it would be possible to parse the raw bit stream and search for the parameter sets however that would be a lot of work when that information is already provided by FFMPEG.
    For MPEG4 files this information is only suplied in the header and is required for decoding.
    
    Two properties are also required to enable the raw encoded bitstream to be written to multiple files, these are;
    1) an indicator as to whether the last frame was a key frame or not - each new file needs to start at a key frame to avoid storing unusable frame diffs,
    2) the length in bytes of the paramater sets contained in the last frame - required to split the paramater sets from the frame without having to parse the stream.  Any call to VideoCapture::get(CAP_PROP_LF_PARAM_SET_LEN) returning a number greater than zero indicates the presense of a parameter set at the begining of the raw bitstream.
    
    * Adjust test data to account for extraData
    
    * Address warning.
    
    * Change added property names and remove paramater set start code check.
    
    * Output extra data on calls to retrieve instead of appending to the first packet.
    
    * Reverted old test case and added new one to evaluate new functionality.
    
    * Add missing definition.
    
    * Remove flag from legacy api.
    Add property to determine if returning extra data is supported.
    Always allow extra data to be returned on calls to cap.retrieve()
    Update test case.
    
    * Update condition which indicates CAP_PROP_CODEC_EXTRADATA_INDEX is not supported in test case.
    
    * Include compatibility for windows dll if not updated.
    Enforce existing return status convention.
    
    * Fix return error and missing test constraints.
    97c6ec6d
cap_ffmpeg.cpp 20.0 KB