Recherche avancée

Médias (0)

Mot : - Tags -/tags

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (83)

  • Liste des distributions compatibles

    26 avril 2011, par

    Le tableau ci-dessous correspond à la liste des distributions Linux compatible avec le script d’installation automatique de MediaSPIP. Nom de la distributionNom de la versionNuméro de version Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    Si vous souhaitez nous aider à améliorer cette liste, vous pouvez nous fournir un accès à une machine dont la distribution n’est pas citée ci-dessus ou nous envoyer le (...)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (5417)

  • Playing RTP stream on Android 4.1.2 (Jelly Bean) [closed]

    27 décembre 2024, par Homie_Tomie

    I'll try to keep it quick. Using FFMPEG I started a stream on my PC. Here is the code :

    


    import subprocess

def start_stream():
    command = [
        'ffmpeg',
        '-f', 'gdigrab',  # Desktop capture (Windows)
        '-framerate', '15',  # Low framerate for higher performance
        '-i', 'desktop',  # Capture desktop
        '-c:v', 'libx264',  # Video codec (H.264)
        '-preset', 'ultrafast',  # Ultra-fast encoding preset for minimal latency
        '-tune', 'zerolatency',  # Zero latency for real-time streaming
        '-x264opts', 'keyint=15:min-keyint=15:no-scenecut',  # Frequent keyframes
        '-b:v', '500k',  # Low bitrate to minimize data usage and reduce latency
        '-s', '800x480',  # Resolution fits phone screen and helps performance
        '-max_delay', '0',  # No buffering, instant frame output
        '-flush_packets', '1',  # Flush packets immediately after encoding
        '-f', 'rtp',  # Use mpegts as the container for RTP stream
        'rtp://192.168.72.26:1234',  # Stream over UDP to localhost on port 1234
        '-sdp_file', 'stream.sdp'  # Create SDP file
    ]
    
    try:
        print("Starting stream...")
        subprocess.run(command, check=True)
    except subprocess.CalledProcessError as e:
        print(f"Error occurred: {e}")
    except KeyboardInterrupt:
        print("\nStream interrupted")

if __name__ == "__main__":
    print("Starting screen capture...")
    start_stream()


    


    Now, when I start the stream I can connect to it in VLC when I open up the stream.sdp file. Using the same method I can open up the stream on my iPhone, but when I try to open it on my old Android phone the stream connects but the screen is black. However, when I turn the screen I can see the first frame that was sent to the phone. Why does the stream not work ?

    


    I will be thankful for any and all advice :)

    


  • avcodec/amfenc : Implement async_depth option

    7 novembre 2024, par Cameron Gutman
    avcodec/amfenc : Implement async_depth option
    

    This option, which is also available on other FFmpeg hardware encoders,
    allows the user to trade throughput for reduced output latency. This is
    useful for ultra low latency applications like game streaming.

    Signed-off-by : Cameron Gutman <aicommander@gmail.com>

    • [DH] libavcodec/amfenc.c
    • [DH] libavcodec/amfenc_av1.c
    • [DH] libavcodec/amfenc_h264.c
    • [DH] libavcodec/amfenc_hevc.c
  • how to stream h.264 video with mp3 audio using libavcodec ?

    29 août 2020, par dasg

    I read h.264 frames from webcamera and capture audio from microphone. I need to stream live video to ffserver. During debug I read video from ffserver using ffmpeg with following command :

    &#xA;&#xA;

    ffmpeg -i http://127.0.0.1:12345/robot.avi -vcodec copy -acodec copy out.avi&#xA;

    &#xA;&#xA;

    My video in output file is slightly accelerated. If I add a audio stream it is accelerated several times. Sometimes there is no audio in the output file.

    &#xA;&#xA;

    Here is my code for encoding audio :

    &#xA;&#xA;

    #include "v_audio_encoder.h"&#xA;&#xA;extern "C" {&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;}&#xA;#include <cassert>&#xA;&#xA;struct VAudioEncoder::Private&#xA;{&#xA;    AVCodec *m_codec;&#xA;    AVCodecContext *m_context;&#xA;&#xA;    std::vector m_outBuffer;&#xA;};&#xA;&#xA;VAudioEncoder::VAudioEncoder( int sampleRate, int bitRate )&#xA;{&#xA;    d = new Private( );&#xA;    d->m_codec = avcodec_find_encoder( CODEC_ID_MP3 );&#xA;    assert( d->m_codec );&#xA;    d->m_context = avcodec_alloc_context3( d->m_codec );&#xA;&#xA;    // put sample parameters&#xA;    d->m_context->channels = 2;&#xA;    d->m_context->bit_rate = bitRate;&#xA;    d->m_context->sample_rate = sampleRate;&#xA;    d->m_context->sample_fmt = AV_SAMPLE_FMT_S16;&#xA;    strcpy( d->m_context->codec_name, "libmp3lame" );&#xA;&#xA;    // open it&#xA;    int res = avcodec_open2( d->m_context, d->m_codec, 0 );&#xA;    assert( res >= 0 );&#xA;&#xA;    d->m_outBuffer.resize( d->m_context->frame_size );&#xA;}&#xA;&#xA;VAudioEncoder::~VAudioEncoder( )&#xA;{&#xA;    avcodec_close( d->m_context );&#xA;    av_free( d->m_context );&#xA;    delete d;&#xA;}&#xA;&#xA;void VAudioEncoder::encode( const std::vector&amp; samples, std::vector&amp; outbuf )&#xA;{&#xA;    assert( (int)samples.size( ) == d->m_context->frame_size );&#xA;&#xA;    int outSize = avcodec_encode_audio( d->m_context, d->m_outBuffer.data( ),&#xA;                                        d->m_outBuffer.size( ), reinterpret_cast<const>( samples.data( ) ) );&#xA;    if( outSize ) {&#xA;        outbuf.resize( outSize );&#xA;        memcpy( outbuf.data( ), d->m_outBuffer.data( ), outSize );&#xA;    }&#xA;    else&#xA;        outbuf.clear( );&#xA;}&#xA;&#xA;int VAudioEncoder::getFrameSize( ) const&#xA;{&#xA;    return d->m_context->frame_size;&#xA;}&#xA;</const></cassert>

    &#xA;&#xA;

    Here is my code for streaming video :

    &#xA;&#xA;

    #include "v_out_video_stream.h"&#xA;&#xA;extern "C" {&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libavutil></libavutil>avstring.h>&#xA;#include <libavformat></libavformat>avio.h>&#xA;}&#xA;&#xA;#include <stdexcept>&#xA;#include <cassert>&#xA;&#xA;struct VStatticRegistrar&#xA;{&#xA;    VStatticRegistrar( )&#xA;    {&#xA;        av_register_all( );&#xA;        avformat_network_init( );&#xA;    }&#xA;};&#xA;&#xA;VStatticRegistrar __registrar;&#xA;&#xA;struct VOutVideoStream::Private&#xA;{&#xA;    AVFormatContext * m_context;&#xA;    int m_videoStreamIndex;&#xA;    int m_audioStreamIndex;&#xA;&#xA;    int m_videoBitrate;&#xA;    int m_width;&#xA;    int m_height;&#xA;    int m_fps;&#xA;    int m_bitrate;&#xA;&#xA;    bool m_waitKeyFrame;&#xA;};&#xA;&#xA;VOutVideoStream::VOutVideoStream( int width, int height, int fps, int bitrate )&#xA;{&#xA;    d = new Private( );&#xA;    d->m_width = width;&#xA;    d->m_height = height;&#xA;    d->m_fps = fps;&#xA;    d->m_context = 0;&#xA;    d->m_videoStreamIndex = -1;&#xA;    d->m_audioStreamIndex = -1;&#xA;    d->m_bitrate = bitrate;&#xA;    d->m_waitKeyFrame = true;&#xA;}&#xA;&#xA;bool VOutVideoStream::connectToServer( const std::string&amp; uri )&#xA;{&#xA;    assert( ! d->m_context );&#xA;&#xA;    // initalize the AV context&#xA;    d->m_context = avformat_alloc_context();&#xA;    if( !d->m_context )&#xA;        return false;&#xA;    // get the output format&#xA;    d->m_context->oformat = av_guess_format( "ffm", NULL, NULL );&#xA;    if( ! d->m_context->oformat )&#xA;        return false;&#xA;&#xA;    strcpy( d->m_context->filename, uri.c_str( ) );&#xA;&#xA;    // add an H.264 stream&#xA;    AVStream *stream = avformat_new_stream( d->m_context, NULL );&#xA;    if ( ! stream )&#xA;        return false;&#xA;    // initalize codec&#xA;    AVCodecContext* codec = stream->codec;&#xA;    if( d->m_context->oformat->flags &amp; AVFMT_GLOBALHEADER )&#xA;        codec->flags |= CODEC_FLAG_GLOBAL_HEADER;&#xA;    codec->codec_id = CODEC_ID_H264;&#xA;    codec->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    strcpy( codec->codec_name, "libx264" );&#xA;//    codec->codec_tag = ( unsigned(&#x27;4&#x27;) &lt;&lt; 24 ) &#x2B; (unsigned(&#x27;6&#x27;) &lt;&lt; 16 ) &#x2B; ( unsigned(&#x27;2&#x27;) &lt;&lt; 8 ) &#x2B; &#x27;H&#x27;;&#xA;    codec->width = d->m_width;&#xA;    codec->height = d->m_height;&#xA;    codec->time_base.den = d->m_fps;&#xA;    codec->time_base.num = 1;&#xA;    codec->bit_rate = d->m_bitrate;&#xA;    d->m_videoStreamIndex = stream->index;&#xA;&#xA;    // add an MP3 stream&#xA;    stream = avformat_new_stream( d->m_context, NULL );&#xA;    if ( ! stream )&#xA;        return false;&#xA;    // initalize codec&#xA;    codec = stream->codec;&#xA;    if( d->m_context->oformat->flags &amp; AVFMT_GLOBALHEADER )&#xA;        codec->flags |= CODEC_FLAG_GLOBAL_HEADER;&#xA;    codec->codec_id = CODEC_ID_MP3;&#xA;    codec->codec_type = AVMEDIA_TYPE_AUDIO;&#xA;    strcpy( codec->codec_name, "libmp3lame" );&#xA;    codec->sample_fmt = AV_SAMPLE_FMT_S16;&#xA;    codec->channels = 2;&#xA;    codec->bit_rate = 64000;&#xA;    codec->sample_rate = 44100;&#xA;    d->m_audioStreamIndex = stream->index;&#xA;&#xA;    // try to open the stream&#xA;    if( avio_open( &amp;d->m_context->pb, d->m_context->filename, AVIO_FLAG_WRITE ) &lt; 0 )&#xA;         return false;&#xA;&#xA;    // write the header&#xA;    return avformat_write_header( d->m_context, NULL ) == 0;&#xA;}&#xA;&#xA;void VOutVideoStream::disconnect( )&#xA;{&#xA;    assert( d->m_context );&#xA;&#xA;    avio_close( d->m_context->pb );&#xA;    avformat_free_context( d->m_context );&#xA;    d->m_context = 0;&#xA;}&#xA;&#xA;VOutVideoStream::~VOutVideoStream( )&#xA;{&#xA;    if( d->m_context )&#xA;        disconnect( );&#xA;    delete d;&#xA;}&#xA;&#xA;int VOutVideoStream::getVopType( const std::vector&amp; image )&#xA;{&#xA;    if( image.size( ) &lt; 6 )&#xA;        return -1;&#xA;    unsigned char *b = (unsigned char*)image.data( );&#xA;&#xA;    // Verify NAL marker&#xA;    if( b[ 0 ] || b[ 1 ] || 0x01 != b[ 2 ] ) {&#xA;        &#x2B;&#x2B;b;&#xA;        if ( b[ 0 ] || b[ 1 ] || 0x01 != b[ 2 ] )&#xA;            return -1;&#xA;    }&#xA;&#xA;    b &#x2B;= 3;&#xA;&#xA;    // Verify VOP id&#xA;    if( 0xb6 == *b ) {&#xA;        &#x2B;&#x2B;b;&#xA;        return ( *b &amp; 0xc0 ) >> 6;&#xA;    }&#xA;&#xA;    switch( *b ) {&#xA;    case 0x65: return 0;&#xA;    case 0x61: return 1;&#xA;    case 0x01: return 2;&#xA;    }&#xA;&#xA;    return -1;&#xA;}&#xA;&#xA;bool VOutVideoStream::sendVideoFrame( std::vector&amp; image )&#xA;{&#xA;    // Init packet&#xA;    AVPacket pkt;&#xA;    av_init_packet( &amp;pkt );&#xA;    pkt.flags |= ( 0 >= getVopType( image ) ) ? AV_PKT_FLAG_KEY : 0;&#xA;&#xA;    // Wait for key frame&#xA;    if ( d->m_waitKeyFrame ) {&#xA;        if( pkt.flags &amp; AV_PKT_FLAG_KEY )&#xA;            d->m_waitKeyFrame = false;&#xA;        else&#xA;            return true;&#xA;    }&#xA;&#xA;    pkt.stream_index = d->m_videoStreamIndex;&#xA;    pkt.data = image.data( );&#xA;    pkt.size = image.size( );&#xA;    pkt.pts = pkt.dts = AV_NOPTS_VALUE;&#xA;&#xA;    return av_write_frame( d->m_context, &amp;pkt ) >= 0;&#xA;}&#xA;&#xA;bool VOutVideoStream::sendAudioFrame( std::vector&amp; audio )&#xA;{&#xA;    // Init packet&#xA;    AVPacket pkt;&#xA;    av_init_packet( &amp;pkt );&#xA;    pkt.stream_index = d->m_audioStreamIndex;&#xA;    pkt.data = audio.data( );&#xA;    pkt.size = audio.size( );&#xA;    pkt.pts = pkt.dts = AV_NOPTS_VALUE;&#xA;&#xA;    return av_write_frame( d->m_context, &amp;pkt ) >= 0;&#xA;}&#xA;</cassert></stdexcept>

    &#xA;&#xA;

    Here is how I use it :

    &#xA;&#xA;

    BOOST_AUTO_TEST_CASE(testSendingVideo)&#xA;{&#xA;    const int framesToGrab = 90000;&#xA;&#xA;    VOutVideoStream stream( VIDEO_WIDTH, VIDEO_HEIGHT, FPS, VIDEO_BITRATE );&#xA;    if( stream.connectToServer( URI ) ) {&#xA;        VAudioEncoder audioEncoder( AUDIO_SAMPLE_RATE, AUDIO_BIT_RATE );&#xA;        VAudioCapture microphone( MICROPHONE_NAME, AUDIO_SAMPLE_RATE, audioEncoder.getFrameSize( ) );&#xA;&#xA;        VLogitecCamera camera( VIDEO_WIDTH, VIDEO_HEIGHT );&#xA;        BOOST_REQUIRE( camera.open( CAMERA_PORT ) );&#xA;        BOOST_REQUIRE( camera.startCapturing( ) );&#xA;&#xA;        std::vector image, encodedAudio;&#xA;        std::vector voice;&#xA;        boost::system_time startTime;&#xA;        int delta;&#xA;        for( int i = 0; i &lt; framesToGrab; &#x2B;&#x2B;i ) {&#xA;            startTime = boost::posix_time::microsec_clock::universal_time( );&#xA;&#xA;            BOOST_REQUIRE( camera.read( image ) );&#xA;            BOOST_REQUIRE( microphone.read( voice ) );&#xA;            audioEncoder.encode( voice, encodedAudio );&#xA;&#xA;            BOOST_REQUIRE( stream.sendVideoFrame( image ) );&#xA;            BOOST_REQUIRE( stream.sendAudioFrame( encodedAudio ) );&#xA;&#xA;            delta = ( boost::posix_time::microsec_clock::universal_time( ) - startTime ).total_milliseconds( );&#xA;            if( delta &lt; 1000 / FPS )&#xA;                boost::thread::sleep( startTime &#x2B; boost::posix_time::milliseconds( 1000 / FPS - delta ) );&#xA;        }&#xA;&#xA;        BOOST_REQUIRE( camera.stopCapturing( ) );&#xA;        BOOST_REQUIRE( camera.close( ) );&#xA;    }&#xA;    else&#xA;        std::cout &lt;&lt; "failed to connect to server" &lt;&lt; std::endl;&#xA;}&#xA;

    &#xA;&#xA;

    I think my problem is in PTS and DTS. Can anyone help me ?

    &#xA;