@@ -97,6 +97,7 @@ type TranscodeOptionsIn struct {
97
97
Accel Acceleration
98
98
Device string
99
99
Transmuxing bool
100
+ Profile VideoProfile
100
101
}
101
102
102
103
type TranscodeOptions struct {
@@ -649,6 +650,11 @@ func createCOutputParams(input *TranscodeOptionsIn, ps []TranscodeOptions) ([]C.
649
650
// needed for hw dec -> hw rescale -> sw enc
650
651
filters = filters + ",hwdownload,format=nv12"
651
652
}
653
+ if p .Accel == Nvidia && filepath .Ext (input .Fname ) == ".png" {
654
+ // If the input is PNG image(s) and we are scaling on a Nvidia device
655
+ // we need to first convert to a pixel format that the scale_npp filter supports
656
+ filters = "format=nv12," + filters
657
+ }
652
658
// set FPS denominator to 1 if unset by user
653
659
if param .FramerateDen == 0 {
654
660
param .FramerateDen = 1
@@ -955,8 +961,34 @@ func (t *Transcoder) Transcode(input *TranscodeOptionsIn, ps []TranscodeOptions)
955
961
defer C .free (unsafe .Pointer (fname ))
956
962
xcoderParams := C .CString ("" )
957
963
defer C .free (unsafe .Pointer (xcoderParams ))
964
+
965
+ var demuxerOpts C.component_opts
966
+
967
+ ext := filepath .Ext (input .Fname )
968
+ // If the input has an image file extension setup the image2 demuxer
969
+ if ext == ".png" {
970
+ image2 := C .CString ("image2" )
971
+ defer C .free (unsafe .Pointer (image2 ))
972
+
973
+ demuxerOpts = C.component_opts {
974
+ name : image2 ,
975
+ }
976
+
977
+ if input .Profile .Framerate > 0 {
978
+ if input .Profile .FramerateDen == 0 {
979
+ input .Profile .FramerateDen = 1
980
+ }
981
+
982
+ // Do not try tofree in this function because in the C code avformat_open_input()
983
+ // will destroy this
984
+ demuxerOpts .opts = newAVOpts (map [string ]string {
985
+ "framerate" : fmt .Sprintf ("%d/%d" , input .Profile .Framerate , input .Profile .FramerateDen ),
986
+ })
987
+ }
988
+ }
989
+
958
990
inp := & C.input_params {fname : fname , hw_type : hw_type , device : device , xcoderParams : xcoderParams ,
959
- handle : t .handle }
991
+ handle : t .handle , demuxer : demuxerOpts }
960
992
if input .Transmuxing {
961
993
inp .transmuxe = 1
962
994
}
0 commit comments