Repository: opencv
Issue: Allow to force the video codec when reading a video using FFmpeg backend by VideoCapture instance
Labels: feature,priority: low,category: videoio

##### System information (version)
- OpenCV => 4.1.2
- Operating System / Platform => Ubuntu 18.04

##### Detailed description

<!-- your description -->
I'm reading from two video streaming: one encoded in mjpeg and another in h264. The first is corrected identified by FFmpeg, but the last is not.

As described on [issue 11480](https://github.com/opencv/opencv/issues/11480), setting
```!bash
export OPENCV_FFMPEG_CAPTURE_OPTIONS="input_format;h264"
```
is enough to force the video codec when using the FFmpeg backend. This fix the problem for the second video streaming, but it makes one for the first. 

I tried the following approaches, but they do not work.
1. Setting video capture fourcc https://stackoverflow.com/questions/27392455/opencv-videocapture-with-h264-codec

2. Setting a dummy extension as `http://url?dummy=h264` https://stackoverflow.com/questions/14204185/read-stream-from-specific-link/15487578#15487578

So, instead of a global video codec using `export OPENCV_FFMPEG_CAPTURE_OPTIONS`, we should be able to set it for each `cv::VideoCapture` instance.

##### Steps to reproduce

<!-- to add code example fence it with triple backticks and optional file extension
    ```.cpp
    // C++ code example
    ```
 or attach as .txt or .zip file
-->


##### Issue submission checklist

 - [ ] I report the issue, it's not a question
   <!--
   OpenCV team works with answers.opencv.org, Stack Overflow and other communities
   to discuss problems. Tickets with question without real issue statement will be
   closed.
   -->
 - [x] I checked the problem with documentation, FAQ, open issues,
       answers.opencv.org, Stack Overflow, etc and have not found solution
   <!--
   Places to check:
   * OpenCV documentation: https://docs.opencv.org
   * FAQ page: https://github.com/opencv/opencv/wiki/FAQ
   * OpenCV forum: https://answers.opencv.org
   * OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
   -->
 - [x] I updated to latest OpenCV version and the issue is still there
   <!--
   master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
   OpenCV team supports only latest release for each branch.
   The ticket is closed, if the problem is not reproduced with modern version.
   -->
 - [ ] There is reproducer code and related data files: videos, images, onnx, etc
   <!--
   The best reproducer -- test case for OpenCV that we can add to the library.
   Recommendations for media files and binary files:
   * Try to reproduce the issue with images and videos in opencv_extra repository
     to reduce attachment size
   * Use PNG for images, if you report some CV related bug, but not image reader
     issue
   * Attach the image as archite to the ticket, if you report some reader issue.
     Image hosting services compress images and it breaks the repro code.
   * Provide ONNX file for some public model or ONNX file with with random weights,
     if you report ONNX parsing or handling issue. Architecture details diagram
     from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
   -->