Recherche avancée

Médias (91)

Autres articles (52)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Gestion de la ferme

    2 mars 2010, par

    La ferme est gérée dans son ensemble par des "super admins".
    Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
    Dans un premier temps il utilise le plugin "Gestion de mutualisation"

Sur d’autres sites (8213)

  • 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;