This PR will implement new comprehensive support for both discarding key default FFmpeg parameters from Decoding pipeline simply by assigning them null string values, and concurrently using values extracted from Output Stream metadata properties (available only when FFmpeg filters are defined) for formulating Pipeline.
[x] I have updated the documentation files accordingly(if required).
Related Issue
31 #30
Context
Both Discarding default FFmpeg parameters and using FFmpeg Filters, are absolute necessity for decoding/transcoding video frames in GPU, as with FFmpeg commands like ffmpeg -y -vsync 0 -hwaccel_output_format cuda -hwaccel cuda -c:v h264_cuvid -i input.mp4 -vf "scale_npp=format=yuv420p,hwdownload,format=yuv420p,fps=25.0" -f rawvideo - fails to work with FFmpeg parameters -framerate, -pix_fmt, -size and throws Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scale_0' Error reinitializing filters! Failed to inject frame into filter network: Function not implemented error. Therefore, implementing both these features will resolves issue with decoding/transcoding with DeFFcode APIs automatically (thus resolving #30).
Types of changes
[ ] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[x] Breaking change (fix or feature that would cause existing functionality to change)
Miscellaneous (if available):
Bare-minimum Code to test this PR features:
# import the necessary packages
from deffcode import FFdecoder
import cv2
# define params and custom filters
ffparams = {
"-custom_resolution": "null", # discard `-custom_resolution`
"-framerate": "null", # discard `-framerate`
"-vf": "format=bgr24,scale=320:240,fps=60", # format=bgr24, scale=320x240, framerate=60fps
}
# initialize and formulate the decoder with params and custom filters
decoder = FFdecoder(
"t.mp4", frame_format="null", verbose=True, **ffparams # discard frame_format
).formulate()
# grab the BGR24 frames from decoder
for frame in decoder.generateFrame():
# check if frame is None
if frame is None:
break
# {do something with the frame here}
# Show output window
cv2.imshow("Output", frame)
# check for 'q' key if pressed
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
# close output window
cv2.destroyAllWindows()
# terminate the decoder
decoder.terminate()
Brief Description
This PR will implement new comprehensive support for both discarding key default FFmpeg parameters from Decoding pipeline simply by assigning them
null
string values, and concurrently using values extracted from Output Stream metadata properties (available only when FFmpeg filters are defined) for formulating Pipeline.Requirements / Checklist
Related Issue
31 #30
Context
Both Discarding default FFmpeg parameters and using FFmpeg Filters, are absolute necessity for decoding/transcoding video frames in GPU, as with FFmpeg commands like
ffmpeg -y -vsync 0 -hwaccel_output_format cuda -hwaccel cuda -c:v h264_cuvid -i input.mp4 -vf "scale_npp=format=yuv420p,hwdownload,format=yuv420p,fps=25.0" -f rawvideo -
fails to work with FFmpeg parameters-framerate
,-pix_fmt
,-size
and throwsImpossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scale_0' Error reinitializing filters! Failed to inject frame into filter network: Function not implemented
error. Therefore, implementing both these features will resolves issue with decoding/transcoding with DeFFcode APIs automatically (thus resolving #30).Types of changes
Miscellaneous (if available):
Bare-minimum Code to test this PR features: