Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ frames = decoder.decode(h264_data, 1)

#### 3. Use VideoEncoder
```python
encoder = VideoEncoder(width, height)
encoder = VideoEncoder(width, height, cliParams)
h264_data = encoder.encode(frame)
```
7 changes: 4 additions & 3 deletions nvcodec-python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,12 @@ static PyObject* VideoEncoder_Repr(NvCodec* Self)
static void VideoEncoder_init(NvCodec* Self, PyObject* pArgs)
{
unsigned int width,height;
if(!PyArg_ParseTuple(pArgs, "II", &width, &height)){
PyErr_SetString(PyExc_ValueError, "Parse the argument FAILED! You should pass width and height!");
char* params;
if(!PyArg_ParseTuple(pArgs, "IIs", &width, &height, &params)){
PyErr_SetString(PyExc_ValueError, "Parse the argument FAILED! You should pass width, height and framerate!");
return;
}
Self->m_handle = (long long)(videoEncoder_init(width, height));
Self->m_handle = (long long)(videoEncoder_init(width, height, params));
}

static PyTypeObject VideoEncoder_ClassInfo =
Expand Down
4 changes: 2 additions & 2 deletions src/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ void _InitializeEncoder(NvEncoder* pEnc, NvEncoderInitParam encodeCLIOptions, NV
}


videoEncoderHandle videoEncoder_init(int width, int height){
videoEncoderHandle videoEncoder_init(int width, int height, char* params){
videoEncoderHandle handle = (videoEncoderHandle)malloc(sizeof(videoEncoder));
ck(cuInit(0));
handle->cuContext = nullptr;
createCudaContext(&(handle->cuContext), 0, 0);
handle->enc = new NvEncoderCuda(handle->cuContext, width, height, NV_ENC_BUFFER_FORMAT_ARGB);

NV_ENC_BUFFER_FORMAT eFormat = NV_ENC_BUFFER_FORMAT_ARGB;
NvEncoderInitParam encodeCLIOptions;
NvEncoderInitParam encodeCLIOptions(params);
_InitializeEncoder(ENC(handle), encodeCLIOptions, eFormat);
return handle;
}
Expand Down
2 changes: 1 addition & 1 deletion src/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef struct
}videoEncodedBuffer;


videoEncoderHandle videoEncoder_init(int width, int height);
videoEncoderHandle videoEncoder_init(int width, int height, char* params);
int videoEncoder_destroy(videoEncoderHandle handle);
videoEncodedBuffer* videoEncoder_encode(videoEncoderHandle handle, u_int8_t* in);
videoEncodedBuffer* videoEncoder_encode_end(videoEncoderHandle handle);
Expand Down