Skip to content

Commit abb0c49

Browse files
committed
added CRF and updated docs
1 parent 6609e78 commit abb0c49

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,28 @@ export LD_LIBRARY_PATH=/home/foo/ffmpeg/build/lib:${LD_LIBRARY_PATH}
5757
### How to use ffmpeg hardware accelerated encoding on the NVidia Jetson
5858

5959
Follow the instructions
60-
[here](https://github.com/jocover/jetson-ffmpeg) to build a version of
61-
ffmpeg that supports NVMPI. Then follow the section above on how to
60+
[here](https://github.com/Keylost/jetson-ffmpeg) to build a version of
61+
ffmpeg that supports NVMPI. This long magic line should build a nvmpi enabled
62+
version of ffmpeg and install it under ``/usr/local/``:
63+
```
64+
git clone https://github.com/berndpfrommer/jetson-ffmpeg.git && cd jetson-ffmpeg && mkdir build && cd build && cmake -DCMAKE_INSTALL
65+
_PREFIX:PATH=/usr/local .. && make install && ldconfig && cd ../.. && git clone git://source.ffmpeg.org/ffmpeg.git -b release/7.1 --
66+
depth=1 &&cd jetson-ffmpeg && ./ffpatch.sh ../ffmpeg && cd ../ffmpeg && ./configure --enable-nvmpi --enable-shared --disable-static
67+
--prefix=/usr/local && make install
68+
```
69+
70+
Then follow the section above on how to
6271
actually use that custom ffmpeg library. As always first test on the
6372
CLI that the newly compiled ``ffmpeg`` command now supports
64-
``h264_nvmpi``. Afterwards you should be able to use e.g. the ``ffmpeg_image_transport`` with
65-
parameters like so:
66-
67-
The transport can now be configured to use nvmpi like so:
73+
``h264_nvmpi``. The transport can then be configured to use
74+
nvmpi like so:
6875

6976
```
7077
parameters=[{'ffmpeg_image_transport.encoding': 'h264_nvmpi',
7178
'ffmpeg_image_transport.profile': 'main',
7279
'ffmpeg_image_transport.preset': 'll',
73-
'ffmpeg_image_transport.gop': 15}]
80+
'ffmpeg_image_transport.gop_size': 15}]
7481
```
75-
76-
7782
## License
7883

7984
This software is issued under the Apache License Version 2.0.

include/ffmpeg_encoder_decoder/encoder.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ class Encoder
8080
Lock lock(mutex_);
8181
delay_ = p;
8282
}
83-
83+
void setCRF(const std::string & c)
84+
{
85+
Lock lock(mutex_);
86+
crf_ = c;
87+
}
8488
void setQMax(int q)
8589
{
8690
Lock lock(mutex_);
@@ -152,6 +156,7 @@ class Encoder
152156
std::string profile_; // e.g. "main", "high", "rext"
153157
std::string tune_; // e.g. "tune"
154158
std::string delay_; // default is 4 frames for parallel processing. 0 is lowest latency
159+
std::string crf_; // constant rate factor. 0 is lossless, 51 is worst quality
155160
int qmax_{0}; // max allowed quantization. The lower the better quality
156161
int GOPSize_{15}; // distance between two keyframes
157162
AVPixelFormat pixFormat_{AV_PIX_FMT_NONE};

src/encoder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ void Encoder::doOpenCodec(int width, int height)
207207
setAVOption("preset", preset_);
208208
setAVOption("tune", tune_);
209209
setAVOption("delay", delay_);
210+
setAVOption("crf", crf_);
210211
RCLCPP_DEBUG(
211212
logger_,
212213
"codec: %10s, profile: %10s, preset: %10s,"

0 commit comments

Comments
 (0)