Recherche avancée

Médias (91)

Autres articles (54)

  • Contribute to a better visual interface

    13 avril 2011

    MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
    Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community.

  • Librairies et binaires spécifiques au traitement vidéo et sonore

    31 janvier 2010, par

    Les logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
    Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
    Binaires complémentaires et facultatifs flvtool2 : (...)

  • 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 (11095)

  • Merge commit ’470cd0c5fe6337b6cb5276b3f84400999450fc1b’

    14 juillet 2016, par Clément Bœsch
    Merge commit ’470cd0c5fe6337b6cb5276b3f84400999450fc1b’
    

    * commit ’470cd0c5fe6337b6cb5276b3f84400999450fc1b’ :
    Add TrueMotion 2.0 Real Time decoder

    Merged-by : Clément Bœsch <u@pkh.me>

    • [DH] doc/general.texi
    • [DH] libavcodec/truemotion2rt.c
  • FFmpeg - Audio encoding produces extra noise over audio

    17 mai 2020, par user3208915

    I am trying to use FFmpeg to take a video (MP4 in this case) and copy it as another MP4. This is so that I can get the hang of decoding/encoding a video and go on to doing other things in that process. My code basically takes a video file, decodes the video and audio streams, and encodes the video and audio streams to an output video file.

    &#xA;&#xA;

    As of now, my code only works for the video stream of the input file. The video part of the output file is exactly the same as the video part of the input file. However, the audio part is not. The audio part of the output contains the original audio, but with noise over it. Think of it as someone screaming into their mic or when audio gets too loud for a speaker to handle.

    &#xA;&#xA;

    The way I'm handling the decoding/encoding process for the video and audio streams is the same, except with a difference in AVCodecContext settings (video —> frame_rate, width, height, etc. ; audio —> sample_rate, channels, etc.).

    &#xA;&#xA;

    This is currently the code that I'm working with :

    &#xA;&#xA;

    The Video struct :

    &#xA;&#xA;

    typedef struct Video {&#xA;    AVFormatContext* inputContext;&#xA;    AVFormatContext* outputContext;&#xA;    AVCodec* videoCodec;&#xA;    AVCodec* audioCodec;&#xA;    AVStream* inputStream;&#xA;    AVStream* outputStream;&#xA;    AVCodecContext* videoCodecContext_I; // Input&#xA;    AVCodecContext* audioCodecContext_I; // Input&#xA;    AVCodecContext* videoCodecContext_O; // Output&#xA;    AVCodecContext* audioCodecContext_O; // Output&#xA;    int videoStream; // Video stream index&#xA;    int audioStream; // Audio stream index&#xA;} Video;&#xA;

    &#xA;&#xA;

    The main code that handles the encoding/decoding (I've only included the audio side since the video side is the same) :

    &#xA;&#xA;

    int openVideo(Video* video, char* filename, char* outputFile) {&#xA;    video->inputContext = avformat_alloc_context();&#xA;    if (!video->inputContext) {&#xA;        printf("[ERROR] Failed to allocate input format context\n");&#xA;        return -1;&#xA;    }&#xA;    if (avformat_open_input(&amp;(video->inputContext), filename, NULL, NULL) &lt; 0) {&#xA;        printf("[ERROR] Could not open the input file\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    if (avformat_find_stream_info(video->inputContext, NULL) &lt; 0) {&#xA;        printf("[ERROR] Failed to retrieve input stream info\n");&#xA;        return -1;&#xA;    }&#xA;    avformat_alloc_output_context2(&amp;(video->outputContext), NULL, NULL, outputFile);&#xA;    if (!video->outputContext) {&#xA;        printf("[ERROR] Failed to create output context\n");&#xA;        return -1;&#xA;    }&#xA;    printf("[OPEN] Video %s opened\n", filename);&#xA;    return 0;&#xA;}&#xA;&#xA;int prepareStreamInfo(AVCodecContext** codecContext, AVCodec** codec, AVStream* stream) {&#xA;    *codec = avcodec_find_decoder(stream->codecpar->codec_id);&#xA;    if (!*codec) {&#xA;        printf("[ERROR] Failed to find input codec\n");&#xA;        return -1;&#xA;    }&#xA;    *codecContext = avcodec_alloc_context3(*codec);&#xA;    if (!codecContext) {&#xA;        printf("[ERROR] Failed to allocate memory for input codec context\n");&#xA;        return -1;&#xA;    }&#xA;    if (avcodec_parameters_to_context(*codecContext, stream->codecpar) &lt; 0) {&#xA;        printf("[ERROR] Failed to fill input codec context\n");&#xA;        return -1;&#xA;    }&#xA;    if (avcodec_open2(*codecContext, *codec, NULL) &lt; 0) {&#xA;        printf("[ERROR] Failed to open input codec\n");&#xA;        return -1;&#xA;    }&#xA;    return 0;&#xA;}&#xA;&#xA;int findStreams(Video* video, char* filename, char* outputFile) {&#xA;    if (openVideo(video, filename, outputFile) &lt; 0) {&#xA;        printf("[ERROR] Video %s failed to open\n", filename);&#xA;        return -1;&#xA;    }&#xA;    for (int i = 0; i &lt; video->inputContext->nb_streams; i&#x2B;&#x2B;) {&#xA;        video->inputStream = video->inputContext->streams[i];&#xA;        if (video->inputContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {&#xA;            video->videoStream = i;&#xA;            if (prepareStreamInfo(&amp;(video->videoCodecContext_I), &amp;(video->videoCodec), video->inputStream) &lt; 0) {&#xA;                printf("[ERROR] Could not prepare video stream information\n");&#xA;                return -1;video->outputStream->time_base = video->audioCodecContext_O->time_base;&#xA;            }&#xA;        } else if (video->inputContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {&#xA;            video->audioStream = i;&#xA;            if (prepareStreamInfo(&amp;(video->audioCodecContext_I), &amp;(video->audioCodec), video->inputStream) &lt; 0) {&#xA;                printf("[ERROR] Could not prepare audio stream information\n");&#xA;                return -1;&#xA;            }&#xA;        }&#xA;        video->outputStream = avformat_new_stream(video->outputContext, NULL);&#xA;        if (!video->outputStream) {&#xA;            printf("[ERROR] Failed allocating output stream\n");&#xA;            return -1;&#xA;        }&#xA;        if (avcodec_parameters_copy(video->outputStream->codecpar, video->inputStream->codecpar) &lt; 0) {&#xA;            printf("[ERROR] Failed to copy codec parameters\n");&#xA;            return -1;&#xA;        }&#xA;    }&#xA;    if (video->videoStream == -1) {&#xA;        printf("[ERROR] Video stream for %s not found\n", filename);&#xA;        return -1;&#xA;    }&#xA;    if (video->audioStream == -1) {&#xA;        printf("[ERROR] Audio stream for %s not found\n", filename);&#xA;        return -1;&#xA;    }&#xA;    if (!(video->outputContext->oformat->flags &amp; AVFMT_NOFILE)) {&#xA;    if (avio_open(&amp;(video->outputContext->pb), outputFile, AVIO_FLAG_WRITE) &lt; 0) {&#xA;      printf("Could not open output file %s", outputFile);&#xA;      return -1;&#xA;    }&#xA;  }&#xA;    return 0;&#xA;}&#xA;&#xA;int prepareAudioOutStream(Video* video) {&#xA;    video->audioCodec = avcodec_find_encoder_by_name("mp2");&#xA;    if (!video->audioCodec) {&#xA;        printf("[ERROR] Failed to find audio output codec\n");&#xA;        return -1;&#xA;    }&#xA;    video->audioCodecContext_O = avcodec_alloc_context3(video->audioCodec);&#xA;    if (!video->audioCodecContext_O) {&#xA;        printf("[ERROR] Failed to allocate memory for audio output codec context\n");&#xA;        return -1;&#xA;    }&#xA;    // Quite possibly the issue&#xA;    video->audioCodecContext_O->channels = video->audioCodecContext_I->channels;&#xA;    video->audioCodecContext_O->channel_layout = av_get_default_channel_layout(video->audioCodecContext_O->channels);&#xA;    video->audioCodecContext_O->sample_rate = video->audioCodecContext_I->sample_rate;&#xA;    video->audioCodecContext_O->sample_fmt = video->audioCodec->sample_fmts[0];&#xA;    video->audioCodecContext_O->bit_rate = video->audioCodecContext_I->bit_rate;&#xA;    video->audioCodecContext_O->time_base = video->audioCodecContext_I->time_base;&#xA;    video->audioCodecContext_O->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;&#xA;    if (avcodec_open2(video->audioCodecContext_O, video->audioCodec, NULL) &lt; 0) {&#xA;        printf("[ERROR] Failed to open audio output codec\n");&#xA;        return -1;&#xA;    }&#xA;    if (avcodec_parameters_from_context(getAudioStream(video)->codecpar, video->audioCodecContext_O) &lt; 0) {&#xA;        printf("[ERROR] Failed to fill audio stream\n");&#xA;        return -1;&#xA;    }&#xA;    return 0;&#xA;}&#xA;&#xA;int decodeAudio(Video* video, AVPacket* packet, AVFrame* frame) {&#xA;    int response = avcodec_send_packet(video->audioCodecContext_I, packet);&#xA;    if (response &lt; 0) {&#xA;        printf("[ERROR] Failed to send audio packet to decoder\n");&#xA;        return response;&#xA;    }&#xA;    while (response >= 0) {&#xA;        response = avcodec_receive_frame(video->audioCodecContext_I, frame);&#xA;        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {&#xA;            break;&#xA;        } else if (response &lt; 0) {&#xA;            printf("[ERROR] Failed to receive audio frame from decoder\n");&#xA;            return response;&#xA;        }&#xA;        if (response >= 0) {&#xA;            // Do stuff and encode&#xA;            if (encodeAudio(video, frame) &lt; 0) {&#xA;                printf("[ERROR] Failed to encode new audio\n");&#xA;                return -1;&#xA;            }&#xA;        }&#xA;        av_frame_unref(frame);&#xA;    }&#xA;    return 0;&#xA;}&#xA;&#xA;int encodeAudio(Video* video, AVFrame* frame) {&#xA;    AVPacket* packet = av_packet_alloc();&#xA;    if (!packet) {&#xA;        printf("[ERROR] Could not allocate memory for audio output packet\n");&#xA;        return -1;&#xA;    }&#xA;    int response = avcodec_send_frame(video->audioCodecContext_O, frame);&#xA;    if (response &lt; 0) {&#xA;        printf("[ERROR] Failed to send audio frame for encoding\n");&#xA;        return response;&#xA;    }&#xA;    while (response >= 0) {&#xA;        response = avcodec_receive_packet(video->audioCodecContext_O, packet);&#xA;        if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {&#xA;            break;&#xA;        } else if (response &lt; 0) {&#xA;            printf("[ERROR] Failed to receive audio packet from encoder\n");&#xA;            return response;&#xA;        }&#xA;        packet->stream_index = video->audioStream;&#xA;        video->inputStream = getAudioStream(video);&#xA;        video->outputStream = video->outputContext->streams[packet->stream_index];&#xA;        packet->pts = av_rescale_q_rnd(packet->pts, video->inputStream->time_base, video->outputStream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);&#xA;        packet->dts = av_rescale_q_rnd(packet->dts, video->inputStream->time_base, video->outputStream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);&#xA;        packet->duration = av_rescale_q(packet->duration, video->inputStream->time_base, video->outputStream->time_base);&#xA;        packet->pos = -1;&#xA;        //av_packet_rescale_ts(packet, video->inputStream->time_base, video->outputStream->time_base);&#xA;&#xA;        response = av_interleaved_write_frame(video->outputContext, packet);&#xA;        if (response &lt; 0) {&#xA;            printf("[ERROR] Failed to write audio packet\n");&#xA;            break;&#xA;        }&#xA;    }&#xA;    av_packet_unref(packet);&#xA;    av_packet_free(&amp;packet);&#xA;    return 0;&#xA;}&#xA;&#xA;int readFrames(Video* video, AVPacket* packet, AVFrame* frame) {&#xA;    if (!packet) {&#xA;        printf("[ERROR] Packet not allocated to be read\n");&#xA;        return -1;&#xA;    }&#xA;    if (!frame) {&#xA;        printf("[ERROR] Frame not allocated to be read\n");&#xA;        return -1;&#xA;    }&#xA;    if (prepareVideoOutStream(video) &lt; 0) {&#xA;        printf("[ERROR] Failed to prepare output video stream\n");&#xA;        return -1;&#xA;    }&#xA;    if (prepareAudioOutStream(video) &lt; 0) {&#xA;        printf("[ERROR] Failed to prepare output audio stream\n");&#xA;        return -1;&#xA;    }&#xA;    int frameNum = 0;&#xA;    while (av_read_frame(video->inputContext, packet) >= 0) {&#xA;        printf("[READ] Reading frame %i\n", frameNum);&#xA;        if (packet->stream_index == video->videoStream) {&#xA;            if (decodeVideo(video, packet, frame) &lt; 0) {&#xA;                printf("[ERROR] Failed to decode and encode video\n");&#xA;                return -1;&#xA;            }&#xA;        } else if (packet->stream_index == video->audioStream) {&#xA;            if (decodeAudio(video, packet, frame) &lt; 0) {&#xA;                printf("[ERROR] Failed to decode and encode audio\n");&#xA;                return -1;&#xA;            }&#xA;        }&#xA;        av_packet_unref(packet);&#xA;        frameNum&#x2B;&#x2B;;&#xA;    }&#xA;    // Flush encoder&#xA;    encodeVideo(video, NULL);&#xA;    encodeAudio(video, NULL);&#xA;    av_write_trailer(video->outputContext);&#xA;    return 0;&#xA;}&#xA;

    &#xA;&#xA;

    My main method that runs all the functions :

    &#xA;&#xA;

    int main(int argc, char* argv[]) {&#xA;    Video* video = (Video*)malloc(sizeof(Video));&#xA;    initVideo(video);&#xA;    if (findStreams(video, argv[1], argv[2]) &lt; 0) {&#xA;        printf("[ERROR] Could not find streams\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    AVDictionary* dic = NULL;&#xA;    if (avformat_write_header(video->outputContext, &amp;dic) &lt; 0) {&#xA;        printf("[ERROR] Error while writing header to output file\n");&#xA;        return -1;&#xA;    }&#xA;    AVFrame* frame = av_frame_alloc();&#xA;    AVPacket* packet = av_packet_alloc();&#xA;    if (readFrames(video, packet, frame) &lt; 0) {&#xA;        printf("[ERROR] Failed to read and write new video\n");&#xA;        return -1;&#xA;    }&#xA;    freeVideo(video); // Frees all codecs and contexts and the video&#xA;    return 0;&#xA;}&#xA;

    &#xA;&#xA;

    I tried to lay out my code so that it can be read from top to bottom without needing to scroll up.

    &#xA;&#xA;

    I realize that when copying a video, I can just pass the AVPacket to write to the output file, but I wanted to be able to work with the AVFrame in the future, so I wrote it this way. I have a feeling that the issue with the way my audio is behaving is because of the audio output AVCodecContext from the prepareAudioOutStream() function.

    &#xA;&#xA;

    Reading the FFmpeg documentation has proved to be of little help with this issue as well as other online sources. I must be missing something (or have something unneeded) so anything that would point me in the right direction would be helpful.

    &#xA;&#xA;

    Thank you.

    &#xA;

  • avcodec/libzvbi-teletextdec : fix txt_default_region limits

    9 juin 2020, par Marton Balint
    avcodec/libzvbi-teletextdec : fix txt_default_region limits
    

    Max region ID is 87. Also the region affects not only the G0 charset but G2 and
    the national subset as well.

    Signed-off-by : Marton Balint <cus@passwd.hu>

    • [DH] doc/decoders.texi
    • [DH] libavcodec/libzvbi-teletextdec.c