[Libav-user] Unable to register custom decoder

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] Unable to register custom decoder

Timothy Fleming

I’m creating a custom video decoder for ffmpeg.  The code compiles and links, my codec library is included.  However, when I attempt to play my file, the player (Nova player for Android though that shouldn’t matter) doesn’t find the decoder.

 

The decoder is for a matroska container and the stream is correctly tagged in the file.  The error message through the app says “Cannot play video. This video format (s_none) is not supported.”

 

I’ve reviewed the ffmpeg custom codec docs.  My starting point was an existing codec.  Does my code appear to be the correct way to register a customer codec?

 

Here are the places I modified libavcodec/libavformat code…

 

libavformat/matroska.c

const CodecTags ff_mkv_codec_tags[]={

    {"A_AAC"            , AV_CODEC_ID_AAC},

    {"A_AC3"            , AV_CODEC_ID_AC3},

    {"S_MKV/LANDMARK"   , AV_CODEC_ID_MPLM},     ///<<< my codec

    {""                 , AV_CODEC_ID_NONE}

};

 

libavcodec/allcodecs.c

extern AVCodec ff_libmplm_decoder;

 

libavcodec/avcodec.h

enum AVCodecID {

    AV_CODEC_ID_NONE,

    AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket

    AV_CODEC_ID_MPLM = 0x30000, ///< MediaPipe Landmark decoder

};

 

libavcodec/codec_desc.c

 

static const AVCodecDescriptor codec_descriptors[] = {

    /* video codecs */

    {

        .id         = AV_CODEC_ID_MPLM,

        .type       = AVMEDIA_TYPE_VIDEO,

        .name       = "mediapipe_landmark",

        .long_name  = NULL_IF_CONFIG_SMALL("MediaPipe Landmark")

    },

};

 

In my decoder…

libavcodec/libmplmdec.c

AVCodec ff_mplm_decoder = {

    .name           = LANDMARK_CODEC_NAME,

    .long_name      = NULL_IF_CONFIG_SMALL("MediaPipe Landmark decoder"),

    .type           = AVMEDIA_TYPE_VIDEO,

    .id             = AV_CODEC_ID_MPLM,

    .priv_data_size = sizeof(MPLMContext),

    .init           = mplm_decode_init,

    .close          = mplm_decode_end,

    .decode         = mplm_decode_frame,

    .capabilities   = AV_CODEC_CAP_DR1,

    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,

};

 

//                         fmt, subfmt, w, h, cpu, dec, name, mangler

STREAM_REGISTER_DEC_VIDEO( VIDEO_FORMAT_MJPG, 0, MAXW, MAXH, MPLMHW, new_dec, LANDMARK_CODEC_NAME, 0 );

 

libavcodec/libmplmdec.h

#define LANDMARK_CODEC_NAME "S_MKV/LANDMARK"

 

--

Tim Fleming

[hidden email]

 


_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Unable to register custom decoder

Carl Eugen Hoyos-2
Am Mi., 29. Jan. 2020 um 19:41 Uhr schrieb Timothy Fleming <[hidden email]>:

> I’m creating a custom video decoder for ffmpeg.  The code compiles and links,
> my codec library is included.  However, when I attempt to play my file, the
> player (Nova player for Android though that shouldn’t matter) doesn’t find the
> decoder.

Please provide your complete patch including the new decoder.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Unable to register custom decoder

Timothy Fleming
Attached...

-----Original Message-----
From: Libav-user <[hidden email]> On Behalf Of Carl Eugen Hoyos
Sent: Wednesday, January 29, 2020 6:13 PM
To: This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter. <[hidden email]>
Subject: Re: [Libav-user] Unable to register custom decoder

Am Mi., 29. Jan. 2020 um 19:41 Uhr schrieb Timothy Fleming <[hidden email]>:

> I’m creating a custom video decoder for ffmpeg.  The code compiles and
> links, my codec library is included.  However, when I attempt to play
> my file, the player (Nova player for Android though that shouldn’t
> matter) doesn’t find the decoder.

Please provide your complete patch including the new decoder.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email [hidden email] with subject "unsubscribe".

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

ff_mplm_decoder.zip (206K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Unable to register custom decoder

Carl Eugen Hoyos-2
Am Do., 30. Jan. 2020 um 03:17 Uhr schrieb Timothy Fleming <[hidden email]>:
>
> Attached...

Doesn't look like a patch...

It should be enough to add the new codec to allcodecs.c and its
codec_id to the demuxer
(as you did). Please compile ffmpeg (for the desktop) and run ffmpeg -i yourfile
to test your change.

Please find out what top-posting means and avoid it here.

Carl Eugen

PS: Friendly reminder to carefully read the license terms before
distributing your
video player.
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Unable to register custom decoder

Timothy Fleming
-----Original Message-----
From: Libav-user <[hidden email]> On Behalf Of Carl Eugen Hoyos
Sent: Wednesday, January 29, 2020 6:23 PM
To: This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter. <[hidden email]>
Subject: Re: [Libav-user] Unable to register custom decoder

Am Do., 30. Jan. 2020 um 03:17 Uhr schrieb Timothy Fleming <[hidden email]>:
>
> Attached...

Doesn't look like a patch...

It should be enough to add the new codec to allcodecs.c and its codec_id to the demuxer (as you did). Please compile ffmpeg (for the desktop) and run ffmpeg -i yourfile to test your change.

Please find out what top-posting means and avoid it here.

Carl Eugen

PS: Friendly reminder to carefully read the license terms before distributing your video player.
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email [hidden email] with subject "unsubscribe".


Ah, top posting, sorry.  It's been a long time since I've used a mailing list.  Thanks for the reminder.  My code is currently structured to fit into the Nova Player android app build process.  It's a pain.  It didn't occur to me to compile it into the tools and test there.   Thanks
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Unable to register custom decoder

Timothy Fleming
In reply to this post by Carl Eugen Hoyos-2


-----Original Message-----
From: Libav-user <[hidden email]> On Behalf Of Carl Eugen Hoyos
Sent: Wednesday, January 29, 2020 6:23 PM
To: This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter. <[hidden email]>
Subject: Re: [Libav-user] Unable to register custom decoder

Am Do., 30. Jan. 2020 um 03:17 Uhr schrieb Timothy Fleming <[hidden email]>:
>
> Attached...

Doesn't look like a patch...

It should be enough to add the new codec to allcodecs.c and its codec_id to the demuxer (as you did). Please compile ffmpeg (for the desktop) and run ffmpeg -i yourfile to test your change.

Please find out what top-posting means and avoid it here.

Carl Eugen

PS: Friendly reminder to carefully read the license terms before distributing your video player.
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email [hidden email] with subject "unsubscribe".

Here is the output:

tim@FFmpeg$ diff ../aos-ffmp./ffmpeg -i /mnt/c/tmp/piano_hands_1.vmkv
ffmpeg version N-96539-g3bce9e9b3e Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration:
  libavutil      56. 38.100 / 56. 38.100
  libavcodec     58. 67.100 / 58. 67.100
  libavformat    58. 36.100 / 58. 36.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 71.100 /  7. 71.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
[matroska,webm @ 0x7fffc0547540] Unknown/unsupported AVCodecID S_MKV/LANDMARK.
[matroska,webm @ 0x7fffc0547540] Could not find codec parameters for stream 0 (Video: none, none): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 0x7fffc0547540] Could not find codec parameters for stream 1 (Attachment: none): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from '/mnt/c/tmp/piano_hands_1.vmkv':
  Metadata:
    title           : Vidoni
    encoder         : libmatroska-1.5.2
    creation_time   : 2019-12-29T11:53:54.000000Z
  Duration: 00:00:00.03, start: 0.000000, bitrate: 320394 kb/s
    Stream #0:0(eng): Video: none, none, 1000k tbr, 1000k tbn, 1000k tbc (default)
    Metadata:
      title           : LANDMARKS
    Side data:
      stereo3d: 2D
    Stream #0:1: Attachment: none
    Metadata:
      filename        : SUBJECT_MODEL_FILE
      mimetype        : application/octet-stream
At least one output file must be specified

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Unable to register custom decoder

Timothy Fleming
In reply to this post by Carl Eugen Hoyos-2
> It should be enough to add the new codec to allcodecs.c and its codec_id to the demuxer (as you did). Please compile ffmpeg (for the desktop) and run ffmpeg -i > yourfile to test your change.

Turns out Matroska does it's own decoder lookup.  It needs to be defined in libavformat/matroska.c.
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".