Recherche avancée

Médias (3)

Mot : - Tags -/plugin

Autres articles (74)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

Sur d’autres sites (6483)

  • Go / Cgo - How to access a field of a Cstruct ?

    17 août 2021, par ChrisG

    I develope an application in Go for transcode an audio file from one format to another one :

    


    I use the goav library that use Cgo to bind the FFmpeg C-libs :
https://github.com/giorgisio/goav/

    



    


    The goav library ; package avformat has a typedef that cast the original FFmpeg lib C-Struct AVOutputFormat :

    


    type ( 
   OutputFormat               C.struct_AVOutputFormat
)


    


    In my code i have a variable called outputF of the type OutputFormat that is a C.struct_AVOutputFormat.

    


    The C real AVOutputFormat struct has fields :

    


    name, long_name, mime_type, extensions, audio_codec, video_codec, subtitle_codec,..


    


    and many fields more.

    


    See : https://ffmpeg.org/doxygen/2.6/structAVOutputFormat.html

    



    


    I verified the situation by fmt.Println(outputF) and reached :

    


    {0x7ffff7f23383 0x7ffff7f23907 0x7ffff7f13c33 0x7ffff7f23383 86017 61 0 128 <nil> 0x7ffff7f8cfa0 <nil> 3344 0x7ffff7e3ec10 0x7ffff7e3f410 0x7ffff7e3ecc0 <nil> 0x7ffff7e3dfc0 <nil> <nil> <nil> <nil> <nil> <nil> 0 0x7ffff7e3e070 0x7ffff7e3e020 <nil>}&#xA;</nil></nil></nil></nil></nil></nil></nil></nil></nil></nil>

    &#xA;

    The audio codec field is on position 5 and contains 86017

    &#xA;

    I verified the field name by using the package reflect :

    &#xA;

    val := reflect.Indirect(reflect.ValueOf(outputF))&#xA;fmt.Println(val)&#xA;fmt.Println("Fieldname: ", val.Type().Field(4).Name)&#xA;&#xA;Output:&#xA;Fieldname:  audio_codec&#xA;

    &#xA;


    &#xA;

    I try to access the field audio_codec of the original AVOutputFormat using :

    &#xA;

    fmt.Println(outputF.audio_codec)&#xA;ERROR: outputF.audio_codec undefined (cannot refer to unexported field or method audio_codec)&#xA;&#xA;&#xA;fmt.Println(outputF._audio_codec)&#xA;ERROR: outputF._audio_codec undefined (type *avformat.OutputFormat has no field or method _audio_codec)&#xA;

    &#xA;

    &#xA;

    As i read in the Cgo documentation :&#xA;Within the Go file, C's struct field names that are keywords in Go can be accessed by prefixing them with an underscore : if x points at a C struct with a field named "type", x._type accesses the field. C struct fields that cannot be expressed in Go, such as bit fields or misaligned data, are omitted in the Go struct, replaced by appropriate padding to reach the next field or the end of the struct.

    &#xA;

    &#xA;

    But I have no idea what im doing wrong.

    &#xA;

    Edit :&#xA;Okay for sure no underscore is required as audio_codec is not a keyword in Go. This i understood for now. But still there is the question why im not able to access the CStruct field "audio_codec".

    &#xA;

  • Go / Cgo - How to access a field of a Cstruct - could not make it

    15 août 2021, par ChrisG

    I develope an application in Go for transcode an audio file from one format to another one :

    &#xA;

    I use the goav library that use Cgo to bind the FFmpeg C-libs :&#xA;https://github.com/giorgisio/goav/

    &#xA;


    &#xA;

    The goav library ; package avformat has a typedef that cast the original FFmpeg lib C-Struct AVOutputFormat :

    &#xA;

    type ( &#xA;   OutputFormat               C.struct_AVOutputFormat&#xA;)&#xA;

    &#xA;

    In my code i have a variable called outputF of the type OutputFormat that is a C.struct_AVOutputFormat.

    &#xA;

    The C real AVOutputFormat struct has fields :

    &#xA;

    name, long_name, mime_type, extensions, audio_codec, video_codec, subtitle_codec,..&#xA;

    &#xA;

    and many fields more.

    &#xA;

    See : https://ffmpeg.org/doxygen/2.6/structAVOutputFormat.html

    &#xA;


    &#xA;

    I verified the situation by fmt.Println(outputF) and reached :

    &#xA;

    {0x7ffff7f23383 0x7ffff7f23907 0x7ffff7f13c33 0x7ffff7f23383 86017 61 0 128 <nil> 0x7ffff7f8cfa0 <nil> 3344 0x7ffff7e3ec10 0x7ffff7e3f410 0x7ffff7e3ecc0 <nil> 0x7ffff7e3dfc0 <nil> <nil> <nil> <nil> <nil> <nil> 0 0x7ffff7e3e070 0x7ffff7e3e020 <nil>}&#xA;</nil></nil></nil></nil></nil></nil></nil></nil></nil></nil>

    &#xA;

    The audio codec field is on position 5 and contains 86017

    &#xA;

    I verified the field name by using the package reflect :

    &#xA;

    val := reflect.Indirect(reflect.ValueOf(outputF))&#xA;fmt.Println(val)&#xA;fmt.Println("Fieldname: ", val.Type().Field(4).Name)&#xA;&#xA;Output:&#xA;Fieldname:  audio_codec&#xA;

    &#xA;


    &#xA;

    I try to access the field audio_codec of the original AVOutputFormat using :

    &#xA;

    fmt.Println(outputF.audio_codec)&#xA;ERROR: outputF.audio_codec undefined (cannot refer to unexported field or method audio_codec)&#xA;&#xA;&#xA;fmt.Println(outputF._audio_codec)&#xA;ERROR: outputF._audio_codec undefined (type *avformat.OutputFormat has no field or method _audio_codec)&#xA;

    &#xA;

    &#xA;

    As i read in the Cgo documentation :&#xA;Within the Go file, C's struct field names that are keywords in Go can be accessed by prefixing them with an underscore : if x points at a C struct with a field named "type", x._type accesses the field. C struct fields that cannot be expressed in Go, such as bit fields or misaligned data, are omitted in the Go struct, replaced by appropriate padding to reach the next field or the end of the struct.

    &#xA;

    &#xA;

    But I have no idea what im doing wrong.

    &#xA;

    Edit :&#xA;Okay for sure no underscore is required as audio_codec is not a keyword in Go. This i understood for now. But still there is the question why im not able to access the CStruct field "audio_codec".

    &#xA;

  • avformat_seek_file timestamps not using the correct time base

    19 juin 2021, par Charlie

    I am in the process of creating a memory loader for ffmpeg to add more functionality. I have audio playing and working, but am having an issue with avformat_seek_file timestamps using the wrong format.

    &#xA;

    avformat.avformat_seek_file(file.context, -1, 0, timestamp, timestamp, 0)&#xA;

    &#xA;

    From looking at the docs it says if the stream index is -1 that the time should be based on AV_TIME_BASE. When I load the file through avformat_open_input with a null AVFormatContext and a filename, this works as expected.

    &#xA;

    However when I create my own AVIOContext and AVFormatContext through avio_alloc_context and avformat_alloc_context respectively, the timestamps are no longer based on AV_TIME_BASE. When testing I received an access violation when I first tried seeking, and upon investigating, it seems that the timestamps are based on actual seconds now. How can I make these custom contexts time based on AV_TIME_BASE ?

    &#xA;

    The only difference between the two are the custom loading of AVIOContext and AVFormatContext :

    &#xA;

        data = fileobject.read()&#xA;&#xA;    ld = len(data)&#xA;&#xA;    buf = libavutil.avutil.av_malloc(ld)&#xA;    ptr_buf = cast(buf, c_char_p)&#xA;&#xA;    ptr = ctypes.create_string_buffer(ld)&#xA;    memmove(ptr, data, ld)&#xA;&#xA;    seeker = libavformat.ffmpeg_seek_func(seek_data)&#xA;    reader = libavformat.ffmpeg_read_func(read_data)&#xA;    writer = libavformat.ffmpeg_read_func(write_data)&#xA;&#xA;    format = libavformat.avformat.avio_alloc_context(ptr_buf, buf_size, 0,&#xA;                                                     ptr_data,&#xA;                                                     reader,&#xA;                                                     writer,&#xA;                                                     seeker&#xA;                                                     )&#xA;&#xA;    file.context = libavformat.avformat.avformat_alloc_context()&#xA;    file.context.contents.pb = format&#xA;    file.context.contents.flags |= AVFMT_FLAG_CUSTOM_IO&#xA;&#xA;    result = avformat.avformat_open_input(byref(file.context),&#xA;                                          b"",&#xA;                                          None,&#xA;                                          None)&#xA;&#xA;    if result != 0:&#xA;        raise FFmpegException(&#x27;avformat_open_input in ffmpeg_open_filename returned an error opening file &#x27;&#xA;                              &#x2B; filename.decode("utf8")&#xA;                              &#x2B; &#x27; Error code: &#x27; &#x2B; str(result))&#xA;&#xA;    result = avformat.avformat_find_stream_info(file.context, None)&#xA;    if result &lt; 0:&#xA;        raise FFmpegException(&#x27;Could not find stream info&#x27;)&#xA;&#xA;    return file&#xA;&#xA;

    &#xA;

    Here is the filename code that does work :

    &#xA;

        result = avformat.avformat_open_input(byref(file.context),&#xA;                                          filename,&#xA;                                          None,&#xA;                                          None)&#xA;    if result != 0:&#xA;        raise FFmpegException(&#x27;avformat_open_input in ffmpeg_open_filename returned an error opening file &#x27;&#xA;                              &#x2B; filename.decode("utf8")&#xA;                              &#x2B; &#x27; Error code: &#x27; &#x2B; str(result))&#xA;&#xA;    result = avformat.avformat_find_stream_info(file.context, None)&#xA;    if result &lt; 0:&#xA;        raise FFmpegException(&#x27;Could not find stream info&#x27;)&#xA;&#xA;    return file&#xA;

    &#xA;

    I am new to ffmpeg, but any help fixing this discrepancy is greatly appreciated.

    &#xA;