Recherche avancée

Médias (91)

Autres articles (23)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

Sur d’autres sites (5775)

  • ffmpeg api : av_interleaved_write_frame return error broken pipe under linux

    23 juin 2021, par guoyanzhang

    I just came into contact with the ffmpeg function, and I encountered a problem, av_interleaved_write_frame function fails and returns broken pipe. I don't know what the problem is ? Someone on the Internet said there was a disconnect in the client or server,but what causes the disconnection ? Please help me, thank you

    


    #include "/usr/local/include/libavcodec/avcodec.h"
#include "/usr/local/include/libavformat/avformat.h"
#include "/usr/local/include/libavfilter/avfilter.h"
#include "/usr/local/include/libavutil/mathematics.h"
#include "/usr/local/include/libavutil/time.h"

extern VideoDataStruct *VideoDataListHeader;
extern PushVideoStruct PushVideoInfo;
extern enum IsPushingVideo IsPushingVideoFlag;
extern UCHAR ChangeAnotherVideo;
typedef long long int64;


#define READ_BUF_LEN       1024*12

extern enum IsStopPushVideo StopPushVideoFlag;  

static int read_packet(void *opaque, uint8_t *buf, int buf_size)
{
    int64 dataLen = 0;

    while (dataLen < buf_size)
    {
        if ((VideoDataListHeader != NULL) && (VideoDataListHeader->flag == 1))
        {
            memcpy(&buf[dataLen], VideoDataListHeader->buf, sizeof(VideoDataListHeader->buf));
            dataLen += sizeof(VideoDataListHeader->buf);

            VideoDataListHeader->flag = 0;
            VideoDataListHeader = VideoDataListHeader->next;
        }
        else 
        {
            usleep(10000);
        }
    }
    return buf_size;
}

void *PushVideoFunction(void *arg)
{
    AVFormatContext *m_pFmtCtx = NULL;
    AVPacket pkt;   
    AVIOContext *m_pIOCtx = NULL;
    AVInputFormat *in_fmt = NULL;
    int ret = 0;
    unsigned int i = 0;
    int vid_idx =-1;
    unsigned char *m_pIOBuf = NULL;
    int m_pIOBuf_size = READ_BUF_LEN;
    int64 start_time = 0;
    int frame_index = 0;
    //const char *rtmp_url = "rtmp://192.168.1.108/mytv/01";
    char rtmp_url[140] = {0};
    memset(rtmp_url, 0, sizeof(rtmp_url));
    strcpy(rtmp_url, PushVideoInfo.VideoServer);
    CHAR fileName[64] = {0};

    avformat_network_init(); 
    if (strcmp(PushVideoInfo.VideoType, REAL_VIDEO) == 0) 
    {
        m_pIOBuf = (unsigned char*)av_malloc(m_pIOBuf_size);
        if(m_pIOBuf == NULL)
        {
            printf("av malloc failed!\n");
            goto end;
        }

    
        m_pIOCtx = avio_alloc_context(m_pIOBuf, m_pIOBuf_size, 0, NULL, read_packet, NULL, NULL);       
        if (!m_pIOCtx) 
        {
            printf("avio alloc context failed!\n");
            goto end;
        }

    
        m_pFmtCtx = avformat_alloc_context();
        if (!m_pFmtCtx)  
        {
            printf("avformat alloc context failed!\n");
            goto end;
        }


        //m_pFmtCtx->probesize = BYTES_PER_FRAME * 8;
        m_pFmtCtx->pb = m_pIOCtx;  
        ret = avformat_open_input(&m_pFmtCtx, "", in_fmt, NULL);
    }
    else if (strcmp(PushVideoInfo.VideoType, HISTORY_VIDEO) == 0) 
    {
        sprintf(fileName, "%s", VIDEO_FILE_FOLDER);
        sprintf(fileName+strlen(fileName), "%s", PushVideoInfo.VideoFile);
        ret = avformat_open_input(&m_pFmtCtx, fileName, NULL, NULL);
    }
    if (ret < 0)
    {
        printf("avformat open failed!\n");
        goto end;           
    }

    ret = avformat_find_stream_info(m_pFmtCtx, 0);
    if (ret < 0)
    {
        printf("could not find stream info!\n");
        goto end;           
    }       
    for(i = 0; i < m_pFmtCtx->nb_streams; i++)
    {
        if((m_pFmtCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && (vid_idx < 0))
        {
            vid_idx = i;
        }
    }

    AVFormatContext *octx = NULL;

    ret = avformat_alloc_output_context2(&octx, 0, "flv", rtmp_url);
    if (ret < 0)
    {
        printf("avformat alloc output context2 failed!\n");
        goto end;
    }   

    av_init_packet(&pkt);    

    
    for (i = 0;i < m_pFmtCtx->nb_streams; i++)
    {
        AVCodec *codec = avcodec_find_decoder(m_pFmtCtx->streams[i]->codecpar->codec_id);
        AVStream *out = avformat_new_stream(octx, codec);
        ret = avcodec_parameters_copy(out->codecpar, m_pFmtCtx->streams[i]->codecpar);
        out->codecpar->codec_tag = 0;
    }

    ret = avio_open(&octx->pb, rtmp_url, AVIO_FLAG_WRITE);
    if (!octx->pb)
    {
        printf("avio open failed!\n");
        goto end;       
    }

    ret = avformat_write_header(octx, 0);
    if (ret < 0)
    {
        printf("avformat write header failed!\n");
        goto end;           
    }

    start_time = av_gettime();
    AVStream *in_stream, *out_stream;
    AVRational time_base1;
    AVRational time_base;
    AVRational time_base_q;
    int64 calc_duration;
    int64 pts_time;
    int64 now_time;
    
    ChangeAnotherVideo = 0;
    while((!StopPushVideoFlag) && (ChangeAnotherVideo == 0))
    {
        ret = av_read_frame(m_pFmtCtx, &pkt);
        if (ret < 0)
        {
            break;
        }
        if (pkt.pts == AV_NOPTS_VALUE)
        {
            time_base1 = m_pFmtCtx->streams[vid_idx]->time_base;
            calc_duration = (double)AV_TIME_BASE/av_q2d(m_pFmtCtx->streams[vid_idx]->r_frame_rate);
            
            pkt.pts = (double)(frame_index*calc_duration)/(double)(av_q2d(time_base1)*AV_TIME_BASE);
            pkt.dts = pkt.pts;
            pkt.duration = (double)calc_duration/(double)(av_q2d(time_base1)*AV_TIME_BASE);
        }
        if (pkt.stream_index == vid_idx)
        {
            time_base = m_pFmtCtx->streams[vid_idx]->time_base;
            time_base_q = (AVRational){1, AV_TIME_BASE};            
            pts_time = av_rescale_q(pkt.dts, time_base, time_base_q);
            now_time = av_gettime() - start_time;
            if (pts_time > now_time)
            {
                av_usleep(pts_time - now_time);
            }
        }
        in_stream  = m_pFmtCtx->streams[pkt.stream_index];
        out_stream = octx->streams[pkt.stream_index];
        pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, (enum AVRounding)(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX));
        pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, (enum AVRounding)(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX));
        pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);
        pkt.pos = -1;
        if(pkt.stream_index == vid_idx)
        {
            printf("Send %8d video frames to output URL\n",frame_index);
            frame_index++;
        }
        ret = av_interleaved_write_frame(octx, &pkt);
        if (ret < 0)
        {
            goto end;
        }
        av_packet_unref(&pkt);
    }
    
end:
    printf("---------------------------------stop push video -------------------------------------------\n");
    StopPushVideoFlag = NO_STOP_PUSH;
    IsPushingVideoFlag = NO_PUSHING;    
    ChangeAnotherVideo = 0;
    avformat_close_input(&m_pFmtCtx);
    if (octx)
    {
        avio_closep(&octx->pb);
        avformat_free_context(octx);
    }
    /* note: the internal buffer could have changed, and be != avio_ctx_buffer */
    if (m_pIOCtx) 
    {
        av_freep(&m_pIOCtx->buffer);
        av_freep(&m_pIOCtx);
    }

    if (ret < 0) 
    {
        printf("Error occured : %s\n", av_err2str(ret));
        //return 1;
    }
    pthread_exit((void*)"push video end!"); 
    
}


void PushVideo(void)
{
    int ret = 0;
    pthread_t pushVideoThread;

    ret = pthread_create(&pushVideoThread, NULL, PushVideoFunction, NULL);
    if(ret != 0)
    {
        printf("error : push video thread create failed!\n");
        exit(-1);
    }
    else
    {
        printf("(debug) push video thread create success!\n");
    } 
} 


    


  • Python pipe ffmpeg FileNotFoundError : [WinError 2]

    14 juin 2021, par Fayssal K

    I want to decimate a video by keeping only one frame /10 using the line

    


    from subprocess import Popen, PIPE

p = Popen(['ffmpeg', '-i', './video/myvideo.mp4', '-vf', "select='not(mod(n\,10))'", './decimated.mp4 '], stdin=PIPE)  


    


    It's my first time using ffmpeg, and I unfortunately can't get the problem with subprocess.
Thanks for your help

    


      File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 997, in _execute_child
    startupinfo)

FileNotFoundError: [WinError 2] The system cannot find the file specified


    


  • Recording livestream from m3u8 to pipe using ffmpeg results in video with no audio

    30 juillet 2021, par jcvamp

    I'm not very good with ffmpeg, so this code is something I've created through trial and error.
I'm using ffmpeg from VB.net with the arguments :

    


    Dim CL As String = "-y -i " & Chr(34) & URL & Chr(34) & " -t " & Time & " -acodec copy -vcodec copy -f mpeg pipe:pipe1"

    


    The videos end up having no audio. I tried removing '-acodec copy' and '-vcodec copy' and using '-map 0', which creates a video with audio, but the quality is substantially lower. I'd like to retain the quality and still have audio.