Recherche avancée

Médias (3)

Mot : - Tags -/pdf

Autres articles (63)

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

  • Use, discuss, criticize

    13 avril 2011, par

    Talk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
    The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
    A discussion list is available for all exchanges between users.

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

  • Revision 104133 : On est en 2017 et version 3.6.9

    30 avril 2017, par kent1@… — Log

    On est en 2017 et version 3.6.9

  • Errors in compiling FFmpeg for windows10/aarch64 using Microsoft Visual Studio 2017 Preview edition

    29 octobre 2018, par Narsinga

    I am trying to compile FFmpeg (the Chromium version) for Windows10/Aarch64 configuration using Microsoft Visual Studio 2017 Preview community edition. I am running into errors in the assembly files as copied below (highlighted few errors). I believe FFmpeg is working for Linux/Aarch64 configuration (probably using GNU assembler) already in which case the same assembly code should also work for Microsoft ARM Macro Assembler as well. Please let me know if I am missing anything here and any pointers to help resolve the errors.

    D :\Work\Chromium_FFmpeg\chromium\src>ninja -C out\ARM64V8 third_party\ffmpeg
    ninja : Entering directory `out\ARM64V8’
    [2/9] ASM obj/third_party/ffmpeg/ffmpeg_internal/autorename_libavcodec_aarch64_fft_neon.obj
    FAILED : obj/third_party/ffmpeg/ffmpeg_internal/autorename_libavcodec_aarch64_fft_neon.obj
    D :/Work/Chromium_FFmpeg/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe ../../build/toolchain/win/tool_wrapper.py asm-wrapper environment.arm64 armasm64.exe /Foobj/third_party/ffmpeg/ffmpeg_internal/autorename_libavcodec_aarch64_fft_neon.obj ../../third_party/ffmpeg/libavcodec/aarch64/autorename_libavcodec_aarch64_fft_neon.S
    Microsoft (R) ARM Macro Assembler Version 14.16.26926.0 for 64 bits
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\autorename_libavcodec_aarch64_fft_neon.S(1) : error A2003 : improper line syntax : /
    // File automatically generated. See crbug.com/495833.
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\autorename_libavcodec_aarch64_fft_neon.S(2) : error A2230 : Illegal preprocessor directive ; only "#line [filename]" is recognized
    include "fft_neon.S"
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\autorename_libavcodec_aarch64_fft_neon.S(3) : warning A4045 : missing END directive
    include "fft_neon.S"
    .
    .
    .
    [6/9] ASM obj/third_party/ffmpeg/ffmpeg_internal/mpegaudiodsp_neon.obj
    FAILED : obj/third_party/ffmpeg/ffmpeg_internal/mpegaudiodsp_neon.obj
    D :/Work/Chromium_FFmpeg/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe ../../build/toolchain/win/tool_wrapper.py asm-wrapper environment.arm64 armasm64.exe /Foobj/third_party/ffmpeg/ffmpeg_internal/mpegaudiodsp_neon.obj ../../third_party/ffmpeg/libavcodec/aarch64/mpegaudiodsp_neon.S
    Microsoft (R) ARM Macro Assembler Version 14.16.26926.0 for 64 bits
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(1) : error A2003 : improper line syntax : /
    /*
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(2) : error A2079 : improper line syntax ; symbol expected
    * Copyright (c) 2014 Janne Grunau
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(3) : error A2079 : improper line syntax ; symbol expected
    *
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(4) : error A2079 : improper line syntax ; symbol expected
    * This file is part of FFmpeg.
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(5) : error A2079 : improper line syntax ; symbol expected
    *
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(6) : error A2079 : improper line syntax ; symbol expected
    * FFmpeg is free software ; you can redistribute it and/or
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(7) : error A2079 : improper line syntax ; symbol expected
    * modify it under the terms of the GNU Lesser General Public
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(8) : error A2079 : improper line syntax ; symbol expected
    * License as published by the Free Software Foundation ; either
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(9) : error A2079 : improper line syntax ; symbol expected
    * version 2.1 of the License, or (at your option) any later version.
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(10) : error A2079 : improper line syntax ; symbol expected
    *
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(11) : error A2079 : improper line syntax ; symbol expected
    * FFmpeg is distributed in the hope that it will be useful,
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(12) : error A2079 : improper line syntax ; symbol expected
    * but WITHOUT ANY WARRANTY ; without even the implied warranty of
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(13) : error A2079 : improper line syntax ; symbol expected
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(14) : error A2079 : improper line syntax ; symbol expected
    * Lesser General Public License for more details.
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(15) : error A2079 : improper line syntax ; symbol expected
    *
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(16) : error A2079 : improper line syntax ; symbol expected
    * You should have received a copy of the GNU Lesser General Public
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(17) : error A2079 : improper line syntax ; symbol expected
    * License along with FFmpeg ; if not, write to the Free Software
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(18) : error A2079 : improper line syntax ; symbol expected
    * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(19) : error A2079 : improper line syntax ; symbol expected
    */
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(21) : error A2230 : Illegal preprocessor directive ; only "#line [filename]" is recognized
    include "libavutil/aarch64/asm.S"
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(23) : error A2230 : Illegal preprocessor directive ; only "#line [filename]" is recognized
    define FRAC_BITS 23 // fractional bits for sb_samples and dct
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(24) : error A2230 : Illegal preprocessor directive ; only "#line [filename]" is recognized
    define WFRAC_BITS 16 // fractional bits for window
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(25) : error A2230 : Illegal preprocessor directive ; only "#line [filename]" is recognized
    define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(27) : error A2034 : unknown opcode : tbl_rev128_s
    const tbl_rev128_s, align=4
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(28) : error A2034 : unknown opcode : .
    .byte 12, 13, 14, 15
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(29) : error A2034 : unknown opcode : .
    .byte 8, 9, 10, 11
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(30) : error A2034 : unknown opcode : .
    .byte 4, 5, 6, 7
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(31) : error A2034 : unknown opcode : .
    .byte 0, 1, 2, 3
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(34) : error A2003 : improper line syntax : .
    .macro apply_window type, st
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(35) : error A2034 : unknown opcode : ff_mpadsp_apply_window_
    function ff_mpadsp_apply_window_\type()_neon, export=1
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(42) : error A2034 : unknown opcode : movrel
    movrel x15, tbl_rev128_s
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(44) : error A2003 : improper line syntax : .
    .ifc \type, fixed
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(46) : error A2003 : improper line syntax : .
    .else
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(48) : error A2003 : improper line syntax : .
    .endif
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(53) : error A2173 : syntax error in expression
    sub x5, x5, x4 // samples2
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(53) : error A2003 : improper line syntax : Trouble parsing operands
    sub x5, x5, x4 // samples2
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(54) : error A2173 : syntax error in expression
    neg x13, x4 // -incr
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(54) : error A2003 : improper line syntax : Trouble parsing operands
    neg x13, x4 // -incr
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(56) : error A2003 : improper line syntax : .
    .ifc \type, fixed
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(57) : error A2173 : syntax error in expression
    ld1r v16.2s, [x2] // dither_state
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(57) : error A2003 : improper line syntax : Trouble parsing operands
    ld1r v16.2s, [x2] // dither_state
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(60) : error A2061 : illegal expression type ; expected absolute numeric
    movi v30.2d, #(1/ 64 * 8 * sizeof(int32_t)
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(101) : error A2003 : improper line syntax : Trouble parsing operands
    sub x10, x10, #64<<5 // 64 * 8 * sizeof(int32_t)
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(103) : error A2003 : improper line syntax : .
    .ifc \type, fixed
    D :\Work\Chromium_FFmpeg\chromium\src\third_party\ffmpeg\libavcodec\aarch64\mpegaudiodsp_neon.S(105) : error A2034 : unknown opcode : ext
    ext v28.16b, v29.16b, v28.16b, #8
    .
    .
    .

  • ffmpeg record video plays too fast

    29 avril 2023, par Kris Xia

    I'm a college student and I am studying FFmpeg now.

    &#xA;&#xA;

    I have wrote a software that can record desktops and audio('virtual-audio-capturer') with FFmpeg.And I am now writing Audio and Video Synchronization.&#xA;I met some problems that video recording plays too fast.

    &#xA;&#xA;

    When I look for audio and video synchronization help on the Internet,I find a formula for calculating PTS :

    &#xA;&#xA;

    pts = n * ((1 / timbase)/ fps)

    &#xA;&#xA;

    When I use this formula,I find a phenomenon.

    &#xA;&#xA;

    1.The higher frame rate is,the faster the video playback speed.

    &#xA;&#xA;

    2.The slower the frame rate, the faster the video playback.

    &#xA;&#xA;

    Also I find while the framerate is 10,the video playback speed will be right.

    &#xA;&#xA;

    Why has this situation happened ?

    &#xA;&#xA;

    I have thought this question for three days. I really hope someone can help me solve this problem.

    &#xA;&#xA;

    I really appreciate the help.

    &#xA;&#xA;

    #include "stdafx.h"&#xA;&#xA;#ifdef  __cplusplus&#xA;extern "C"&#xA;{&#xA;#endif&#xA;#include "libavcodec/avcodec.h"&#xA;#include "libavformat/avformat.h"&#xA;#include "libswscale/swscale.h"&#xA;#include "libavdevice/avdevice.h"&#xA;#include "libavutil/audio_fifo.h"&#xA;&#xA;#include "libavfilter/buffersink.h"&#xA;#include "libavfilter/buffersrc.h"&#xA;#include "libavutil/imgutils.h"&#xA;#include "libavutil/mathematics.h"&#xA;#include "libavutil/samplefmt.h"&#xA;#include "libavutil/time.h"&#xA;#include "libavutil/opt.h"&#xA;#include "libavutil/pixdesc.h"&#xA;#include "libavutil/file.h"&#xA;#include "libavutil/mem.h"&#xA;#include "libavutil/frame.h"&#xA;#include "libavfilter/avfilter.h"&#xA;#include "libswresample/swresample.h"&#xA;&#xA;#pragma comment(lib, "avcodec.lib")&#xA;#pragma comment(lib, "avformat.lib")&#xA;#pragma comment(lib, "avutil.lib")&#xA;#pragma comment(lib, "avdevice.lib")&#xA;#pragma comment(lib, "avfilter.lib")&#xA;&#xA;#pragma comment(lib, "avfilter.lib")&#xA;#pragma comment(lib, "postproc.lib")&#xA;#pragma comment(lib, "swresample.lib")&#xA;#pragma comment(lib, "swscale.lib")&#xA;#ifdef __cplusplus&#xA;};&#xA;#endif&#xA;&#xA;AVFormatContext *pFormatCtx_Video = NULL, *pFormatCtx_Audio = NULL, *pFormatCtx_Out = NULL;&#xA;&#xA;AVCodecContext *outVideoCodecCtx = NULL;&#xA;AVCodecContext *outAudioCodecCtx = NULL;&#xA;&#xA;AVStream *pVideoStream = NULL, *pAudioStream = NULL;&#xA;&#xA;AVCodec *outAVCodec;&#xA;AVCodec *outAudioCodec;&#xA;&#xA;AVCodecContext  *pCodecCtx_Video;&#xA;AVCodec         *pCodec_Video;&#xA;AVFifoBuffer    *fifo_video = NULL;&#xA;AVAudioFifo     *fifo_audio = NULL;&#xA;int VideoIndex, AudioIndex;&#xA;int codec_id;&#xA;&#xA;CRITICAL_SECTION AudioSection, VideoSection;&#xA;&#xA;&#xA;&#xA;SwsContext *img_convert_ctx;&#xA;int frame_size = 0;&#xA;&#xA;uint8_t *picture_buf = NULL, *frame_buf = NULL;&#xA;&#xA;bool bCap = true;&#xA;&#xA;DWORD WINAPI ScreenCapThreadProc( LPVOID lpParam );&#xA;DWORD WINAPI AudioCapThreadProc( LPVOID lpParam );&#xA;&#xA;int OpenVideoCapture()&#xA;{&#xA;    AVInputFormat *ifmt=av_find_input_format("gdigrab");&#xA;    AVDictionary *options = NULL;&#xA;    av_dict_set(&amp;options, "framerate", "60", NULL);&#xA;    if(avformat_open_input(&amp;pFormatCtx_Video, "desktop", ifmt, &amp;options)!=0)&#xA;    {&#xA;        printf("Couldn&#x27;t open input stream.(无法打开视频输入流)\n");&#xA;        return -1;&#xA;    }&#xA;    if(avformat_find_stream_info(pFormatCtx_Video,NULL)&lt;0)&#xA;    {&#xA;        printf("Couldn&#x27;t find stream information.(无法获取视频流信息)\n");&#xA;        return -1;&#xA;    }&#xA;    if (pFormatCtx_Video->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO)&#xA;    {&#xA;        printf("Couldn&#x27;t find video stream information.(无法获取视频流信息)\n");&#xA;        return -1;&#xA;    }&#xA;    pCodecCtx_Video = pFormatCtx_Video->streams[0]->codec;&#xA;    pCodec_Video = avcodec_find_decoder(pCodecCtx_Video->codec_id);&#xA;    if(pCodec_Video == NULL)&#xA;    {&#xA;        printf("Codec not found.(没有找到解码器)\n");&#xA;        return -1;&#xA;    }&#xA;    if(avcodec_open2(pCodecCtx_Video, pCodec_Video, NULL) &lt; 0)&#xA;    {&#xA;        printf("Could not open codec.(无法打开解码器)\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    av_dump_format(pFormatCtx_Video, 0, NULL, 0);&#xA;&#xA;    img_convert_ctx = sws_getContext(pCodecCtx_Video->width, pCodecCtx_Video->height, pCodecCtx_Video->pix_fmt, &#xA;        pCodecCtx_Video->width, pCodecCtx_Video->height, PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL); &#xA;&#xA;    frame_size = avpicture_get_size(pCodecCtx_Video->pix_fmt, pCodecCtx_Video->width, pCodecCtx_Video->height);&#xA;    fifo_video = av_fifo_alloc(30 * avpicture_get_size(AV_PIX_FMT_YUV420P, pCodecCtx_Video->width, pCodecCtx_Video->height));&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;static char *dup_wchar_to_utf8(wchar_t *w)&#xA;{&#xA;    char *s = NULL;&#xA;    int l = WideCharToMultiByte(CP_UTF8, 0, w, -1, 0, 0, 0, 0);&#xA;    s = (char *) av_malloc(l);&#xA;    if (s)&#xA;        WideCharToMultiByte(CP_UTF8, 0, w, -1, s, l, 0, 0);&#xA;    return s;&#xA;}&#xA;&#xA;int OpenAudioCapture()&#xA;{&#xA;    AVInputFormat *pAudioInputFmt = av_find_input_format("dshow");&#xA;    char * psDevName = dup_wchar_to_utf8(L"audio=virtual-audio-capturer");&#xA;&#xA;    if (avformat_open_input(&amp;pFormatCtx_Audio, psDevName, pAudioInputFmt,NULL) &lt; 0)&#xA;    {&#xA;        printf("Couldn&#x27;t open input stream.(无法打开音频输入流)\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    if(avformat_find_stream_info(pFormatCtx_Audio,NULL)&lt;0)  &#xA;        return -1; &#xA;&#xA;    if(pFormatCtx_Audio->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO)&#xA;    {&#xA;        printf("Couldn&#x27;t find video stream information.(无法获取音频流信息)\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    AVCodec *tmpCodec = avcodec_find_decoder(pFormatCtx_Audio->streams[0]->codec->codec_id);&#xA;    if(0 > avcodec_open2(pFormatCtx_Audio->streams[0]->codec, tmpCodec, NULL))&#xA;    {&#xA;        printf("can not find or open audio decoder!\n");&#xA;    }&#xA;&#xA;    av_dump_format(pFormatCtx_Audio, 0, NULL, 0);&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;int OpenOutPut()&#xA;{&#xA;    AVStream *pVideoStream = NULL, *pAudioStream = NULL;&#xA;    const char *outFileName = "test.mp4";&#xA;    avformat_alloc_output_context2(&amp;pFormatCtx_Out, NULL, NULL, outFileName);&#xA;&#xA;    if (pFormatCtx_Video->streams[0]->codec->codec_type == AVMEDIA_TYPE_VIDEO)&#xA;    {&#xA;        VideoIndex = 0;&#xA;        pVideoStream = avformat_new_stream(pFormatCtx_Out, NULL);&#xA;        if (!pVideoStream)&#xA;        {&#xA;            printf("can not new stream for output!\n");&#xA;            return -1;&#xA;        }&#xA;&#xA;        outVideoCodecCtx = avcodec_alloc_context3(outAVCodec);&#xA;        if ( !outVideoCodecCtx )&#xA;        {&#xA;            printf("Error : avcodec_alloc_context3()\n");&#xA;            return -1;&#xA;        }&#xA;&#xA;        //set codec context param&#xA;        outVideoCodecCtx = pVideoStream->codec;&#xA;        outVideoCodecCtx->codec_id = AV_CODEC_ID_MPEG4;&#xA;        outVideoCodecCtx->width = pFormatCtx_Video->streams[0]->codec->width;&#xA;        outVideoCodecCtx->height = pFormatCtx_Video->streams[0]->codec->height;&#xA;        outVideoCodecCtx->time_base = pFormatCtx_Video->streams[0]->codec->time_base;&#xA;        outVideoCodecCtx->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;        outVideoCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;&#xA;        if (codec_id == AV_CODEC_ID_H264)&#xA;        {&#xA;            av_opt_set(outVideoCodecCtx->priv_data, "preset", "slow", 0);&#xA;        }&#xA;&#xA;        outAVCodec = avcodec_find_encoder(AV_CODEC_ID_MPEG4);&#xA;        if( !outAVCodec )&#xA;        {&#xA;            printf("\n\nError : avcodec_find_encoder()");&#xA;            return -1;&#xA;        }&#xA;        if (pFormatCtx_Out->oformat->flags &amp; AVFMT_GLOBALHEADER)&#xA;            outVideoCodecCtx->flags |=CODEC_FLAG_GLOBAL_HEADER;&#xA;&#xA;        if ((avcodec_open2(outVideoCodecCtx,outAVCodec, NULL)) &lt; 0)&#xA;        {&#xA;            printf("can not open the encoder\n");&#xA;            return -1;&#xA;        }&#xA;    }&#xA;&#xA;    if(pFormatCtx_Audio->streams[0]->codec->codec_type == AVMEDIA_TYPE_AUDIO)&#xA;    {&#xA;        AVCodecContext *pOutputCodecCtx;&#xA;        AudioIndex = 1;&#xA;        pAudioStream = avformat_new_stream(pFormatCtx_Out, NULL);&#xA;&#xA;        pAudioStream->codec->codec = avcodec_find_encoder(pFormatCtx_Out->oformat->audio_codec);&#xA;&#xA;        pOutputCodecCtx = pAudioStream->codec;&#xA;&#xA;        pOutputCodecCtx->sample_rate = pFormatCtx_Audio->streams[0]->codec->sample_rate;&#xA;        pOutputCodecCtx->channel_layout = pFormatCtx_Out->streams[0]->codec->channel_layout;&#xA;        pOutputCodecCtx->channels = av_get_channel_layout_nb_channels(pAudioStream->codec->channel_layout);&#xA;        if(pOutputCodecCtx->channel_layout == 0)&#xA;        {&#xA;            pOutputCodecCtx->channel_layout = AV_CH_LAYOUT_STEREO;&#xA;            pOutputCodecCtx->channels = av_get_channel_layout_nb_channels(pOutputCodecCtx->channel_layout);&#xA;&#xA;        }&#xA;        pOutputCodecCtx->sample_fmt = pAudioStream->codec->codec->sample_fmts[0];&#xA;        AVRational time_base={1, pAudioStream->codec->sample_rate};&#xA;        pAudioStream->time_base = time_base;&#xA;        //audioCodecCtx->time_base = time_base;&#xA;&#xA;        pOutputCodecCtx->codec_tag = 0;  &#xA;        if (pFormatCtx_Out->oformat->flags &amp; AVFMT_GLOBALHEADER)  &#xA;            pOutputCodecCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;&#xA;&#xA;        if (avcodec_open2(pOutputCodecCtx, pOutputCodecCtx->codec, 0) &lt; 0)&#xA;        {&#xA;            printf("编码器打开失败,退出程序\n");&#xA;            return -1;&#xA;        }&#xA;    }&#xA;&#xA;    if (!(pFormatCtx_Out->oformat->flags &amp; AVFMT_NOFILE))&#xA;    {&#xA;        if(avio_open(&amp;pFormatCtx_Out->pb, outFileName, AVIO_FLAG_WRITE) &lt; 0)&#xA;        {&#xA;            printf("can not open output file handle!\n");&#xA;            return -1;&#xA;        }&#xA;    }&#xA;&#xA;    if(avformat_write_header(pFormatCtx_Out, NULL) &lt; 0)&#xA;    {&#xA;        printf("can not write the header of the output file!\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;int _tmain(int argc, _TCHAR* argv[])&#xA;{&#xA;    av_register_all();&#xA;    avdevice_register_all();&#xA;    if (OpenVideoCapture() &lt; 0)&#xA;    {&#xA;        return -1;&#xA;    }&#xA;    if (OpenAudioCapture() &lt; 0)&#xA;    {&#xA;        return -1;&#xA;    }&#xA;    if (OpenOutPut() &lt; 0)&#xA;    {&#xA;        return -1;&#xA;    }&#xA;//  int fps;&#xA;    /*printf("输入帧率:");&#xA;    scanf_s("%d",&amp;fps);&#xA;    if ( NULL == fps)&#xA;    {&#xA;        fps = 10;&#xA;    }*/&#xA;&#xA;    InitializeCriticalSection(&amp;VideoSection);&#xA;    InitializeCriticalSection(&amp;AudioSection);&#xA;&#xA;    AVFrame *picture = av_frame_alloc();&#xA;    int size = avpicture_get_size(pFormatCtx_Out->streams[VideoIndex]->codec->pix_fmt, &#xA;        pFormatCtx_Out->streams[VideoIndex]->codec->width, pFormatCtx_Out->streams[VideoIndex]->codec->height);&#xA;    picture_buf = new uint8_t[size];&#xA;&#xA;    avpicture_fill((AVPicture *)picture, picture_buf, &#xA;        pFormatCtx_Out->streams[VideoIndex]->codec->pix_fmt, &#xA;        pFormatCtx_Out->streams[VideoIndex]->codec->width, &#xA;        pFormatCtx_Out->streams[VideoIndex]->codec->height);&#xA;&#xA;&#xA;&#xA;    //star cap screen thread&#xA;    CreateThread( NULL, 0, ScreenCapThreadProc, 0, 0, NULL);&#xA;    //star cap audio thread&#xA;    CreateThread( NULL, 0, AudioCapThreadProc, 0, 0, NULL);&#xA;    int64_t cur_pts_v=0,cur_pts_a=0;&#xA;    int VideoFrameIndex = 0, AudioFrameIndex = 0;&#xA;&#xA;    while(1)&#xA;    {&#xA;        if (_kbhit() != 0 &amp;&amp; bCap)&#xA;        {&#xA;            bCap = false;&#xA;            Sleep(2000);&#xA;        }&#xA;        if (fifo_audio &amp;&amp; fifo_video)&#xA;        {&#xA;            int sizeAudio = av_audio_fifo_size(fifo_audio);&#xA;            int sizeVideo = av_fifo_size(fifo_video);&#xA;            //缓存数据写完就结束循环&#xA;            if (av_audio_fifo_size(fifo_audio) &lt;= pFormatCtx_Out->streams[AudioIndex]->codec->frame_size &amp;&amp; &#xA;                av_fifo_size(fifo_video) &lt;= frame_size &amp;&amp; !bCap)&#xA;            {&#xA;                break;&#xA;            }&#xA;        }&#xA;&#xA;        if(av_compare_ts(cur_pts_v, pFormatCtx_Out->streams[VideoIndex]->time_base, &#xA;                         cur_pts_a,pFormatCtx_Out->streams[AudioIndex]->time_base) &lt;= 0)&#xA;        {&#xA;            if (av_fifo_size(fifo_video) &lt; frame_size &amp;&amp; !bCap)&#xA;            {&#xA;                cur_pts_v = 0x7fffffffffffffff;&#xA;            }&#xA;            if(av_fifo_size(fifo_video) >= size)&#xA;            {&#xA;                EnterCriticalSection(&amp;VideoSection);&#xA;                av_fifo_generic_read(fifo_video, picture_buf, size, NULL); //将数据从avfifobuffer馈送到用户提供的回调。&#xA;                LeaveCriticalSection(&amp;VideoSection);&#xA;&#xA;                avpicture_fill((AVPicture *)picture, picture_buf,&#xA;                    pFormatCtx_Out->streams[VideoIndex]->codec->pix_fmt,&#xA;                    pFormatCtx_Out->streams[VideoIndex]->codec->width,&#xA;                    pFormatCtx_Out->streams[VideoIndex]->codec->height); //根据指定的图像参数和提供的图像数据缓冲区设置图片字段。&#xA;&#xA;                //pts = n * ((1 / timbase)/ fps);&#xA;                //picture->pts = VideoFrameIndex * ((pFormatCtx_Video->streams[0]->time_base.den / pFormatCtx_Video->streams[0]->time_base.num) / 24);&#xA;                picture->pts = VideoFrameIndex * ((outVideoCodecCtx->time_base.den * 100000 / outVideoCodecCtx->time_base.num) / 180);&#xA;&#xA;                int got_picture = 0;&#xA;                AVPacket pkt;&#xA;                av_init_packet(&amp;pkt);&#xA;&#xA;                pkt.data = NULL;&#xA;                pkt.size = 0;&#xA;                //从帧中获取输入的原始视频数据&#xA;                int ret = avcodec_encode_video2(pFormatCtx_Out->streams[VideoIndex]->codec, &amp;pkt, picture, &amp;got_picture);&#xA;                if(ret &lt; 0)&#xA;                {&#xA;                    continue;&#xA;                }&#xA;&#xA;                if (got_picture==1)&#xA;                {&#xA;                    pkt.stream_index = VideoIndex;&#xA;                    /*int count = 1;&#xA;                    pkt.pts = pkt.dts = count * ((pFormatCtx_Video->streams[0]->time_base.den / pFormatCtx_Video->streams[0]->time_base.num) / 15);&#xA;                    count&#x2B;&#x2B;;*/&#xA;&#xA;                    //x = pts * (timebase1.num / timebase1.den )* (timebase2.den / timebase2.num);&#xA;&#xA;                    pkt.pts = av_rescale_q_rnd(pkt.pts, pFormatCtx_Video->streams[0]->time_base, &#xA;                        pFormatCtx_Out->streams[VideoIndex]->time_base, (AVRounding)(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX));  &#xA;                    pkt.dts = av_rescale_q_rnd(pkt.dts,  pFormatCtx_Video->streams[0]->time_base, &#xA;                        pFormatCtx_Out->streams[VideoIndex]->time_base, (AVRounding)(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX)); &#xA;&#xA;&#xA;                    pkt.duration = ((pFormatCtx_Out->streams[0]->time_base.den / pFormatCtx_Out->streams[0]->time_base.num) / 60);&#xA;                    //pkt.duration = 1000/60;&#xA;                    //pkt.pts = pkt.dts = Count * (ofmt_ctx->streams[stream_index]->time_base.den) /ofmt_ctx->streams[stream_index]->time_base.num / 10;&#xA;&#xA;                    //Count&#x2B;&#x2B;;&#xA;&#xA;&#xA;                    cur_pts_v = pkt.pts;&#xA;&#xA;                    ret = av_interleaved_write_frame(pFormatCtx_Out, &amp;pkt);&#xA;                    //delete[] pkt.data;&#xA;                    av_free_packet(&amp;pkt);&#xA;                }&#xA;                VideoFrameIndex&#x2B;&#x2B;;&#xA;            }&#xA;        }&#xA;        else&#xA;        {&#xA;            if (NULL == fifo_audio)&#xA;            {&#xA;                continue;//还未初始化fifo&#xA;            }&#xA;            if (av_audio_fifo_size(fifo_audio) &lt; pFormatCtx_Out->streams[AudioIndex]->codec->frame_size &amp;&amp; !bCap)&#xA;            {&#xA;                cur_pts_a = 0x7fffffffffffffff;&#xA;            }&#xA;            if(av_audio_fifo_size(fifo_audio) >= &#xA;                (pFormatCtx_Out->streams[AudioIndex]->codec->frame_size > 0 ? pFormatCtx_Out->streams[AudioIndex]->codec->frame_size : 1024))&#xA;            {&#xA;                AVFrame *frame;&#xA;                frame = av_frame_alloc();&#xA;                frame->nb_samples = pFormatCtx_Out->streams[AudioIndex]->codec->frame_size>0 ? pFormatCtx_Out->streams[AudioIndex]->codec->frame_size: 1024;&#xA;                frame->channel_layout = pFormatCtx_Out->streams[AudioIndex]->codec->channel_layout;&#xA;                frame->format = pFormatCtx_Out->streams[AudioIndex]->codec->sample_fmt;&#xA;                frame->sample_rate = pFormatCtx_Out->streams[AudioIndex]->codec->sample_rate;&#xA;                av_frame_get_buffer(frame, 0);&#xA;&#xA;                EnterCriticalSection(&amp;AudioSection);&#xA;                av_audio_fifo_read(fifo_audio, (void **)frame->data, &#xA;                    (pFormatCtx_Out->streams[AudioIndex]->codec->frame_size > 0 ? pFormatCtx_Out->streams[AudioIndex]->codec->frame_size : 1024));&#xA;                LeaveCriticalSection(&amp;AudioSection);&#xA;&#xA;                AVPacket pkt_out;&#xA;                av_init_packet(&amp;pkt_out);&#xA;                int got_picture = -1;&#xA;                pkt_out.data = NULL;&#xA;                pkt_out.size = 0;&#xA;&#xA;                frame->pts = AudioFrameIndex * pFormatCtx_Out->streams[AudioIndex]->codec->frame_size;&#xA;                if (avcodec_encode_audio2(pFormatCtx_Out->streams[AudioIndex]->codec, &amp;pkt_out, frame, &amp;got_picture) &lt; 0)&#xA;                {&#xA;                    printf("can not decoder a frame");&#xA;                }&#xA;                av_frame_free(&amp;frame);&#xA;                if (got_picture) &#xA;                {&#xA;                    pkt_out.stream_index = AudioIndex;&#xA;                    pkt_out.pts = AudioFrameIndex * pFormatCtx_Out->streams[AudioIndex]->codec->frame_size;&#xA;                    pkt_out.dts = AudioFrameIndex * pFormatCtx_Out->streams[AudioIndex]->codec->frame_size;&#xA;                    pkt_out.duration = pFormatCtx_Out->streams[AudioIndex]->codec->frame_size;&#xA;&#xA;                    cur_pts_a = pkt_out.pts;&#xA;&#xA;                    int ret = av_interleaved_write_frame(pFormatCtx_Out, &amp;pkt_out);&#xA;                    av_free_packet(&amp;pkt_out);&#xA;                }&#xA;                AudioFrameIndex&#x2B;&#x2B;;&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    delete[] picture_buf;&#xA;&#xA;    av_fifo_free(fifo_video);&#xA;    av_audio_fifo_free(fifo_audio);&#xA;&#xA;    av_write_trailer(pFormatCtx_Out);&#xA;&#xA;    avio_close(pFormatCtx_Out->pb);&#xA;    avformat_free_context(pFormatCtx_Out);&#xA;&#xA;    if (pFormatCtx_Video != NULL)&#xA;    {&#xA;        avformat_close_input(&amp;pFormatCtx_Video);&#xA;        pFormatCtx_Video = NULL;&#xA;    }&#xA;    if (pFormatCtx_Audio != NULL)&#xA;    {&#xA;        avformat_close_input(&amp;pFormatCtx_Audio);&#xA;        pFormatCtx_Audio = NULL;&#xA;    }&#xA;&#xA;    return 0;&#xA;}&#xA;&#xA;DWORD WINAPI ScreenCapThreadProc( LPVOID lpParam )&#xA;{&#xA;    AVPacket packet;&#xA;    int got_picture;&#xA;    AVFrame *pFrame;&#xA;    pFrame=av_frame_alloc();&#xA;&#xA;    AVFrame *picture = av_frame_alloc();&#xA;    int size = avpicture_get_size(pFormatCtx_Out->streams[VideoIndex]->codec->pix_fmt, &#xA;        pFormatCtx_Out->streams[VideoIndex]->codec->width, &#xA;        pFormatCtx_Out->streams[VideoIndex]->codec->height);&#xA;&#xA;    avpicture_fill((AVPicture *)picture, picture_buf, &#xA;        pFormatCtx_Out->streams[VideoIndex]->codec->pix_fmt, &#xA;        pFormatCtx_Out->streams[VideoIndex]->codec->width, &#xA;        pFormatCtx_Out->streams[VideoIndex]->codec->height);&#xA;&#xA;    FILE *p = NULL;&#xA;    p = fopen("proc_test.yuv", "wb&#x2B;");&#xA;    av_init_packet(&amp;packet);&#xA;    int height = pFormatCtx_Out->streams[VideoIndex]->codec->height;&#xA;    int width = pFormatCtx_Out->streams[VideoIndex]->codec->width;&#xA;    int y_size=height*width;&#xA;    while(bCap)&#xA;    {&#xA;        packet.data = NULL;&#xA;        packet.size = 0;&#xA;        if (av_read_frame(pFormatCtx_Video, &amp;packet) &lt; 0)&#xA;        {&#xA;            continue;&#xA;        }&#xA;        if(packet.stream_index == 0)&#xA;        {&#xA;            if (avcodec_decode_video2(pCodecCtx_Video, pFrame, &amp;got_picture, &amp;packet) &lt; 0)&#xA;            {&#xA;                printf("Decode Error.(解码错误)\n");&#xA;                continue;&#xA;            }&#xA;            if (got_picture)&#xA;            {&#xA;                sws_scale(img_convert_ctx, &#xA;                    (const uint8_t* const*)pFrame->data,&#xA;                    pFrame->linesize, &#xA;                    0, &#xA;                    pFormatCtx_Out->streams[VideoIndex]->codec->height,&#xA;                    picture->data,&#xA;                    picture->linesize);&#xA;&#xA;                if (av_fifo_space(fifo_video) >= size)&#xA;                {&#xA;                    EnterCriticalSection(&amp;VideoSection);                    &#xA;                    av_fifo_generic_write(fifo_video, picture->data[0], y_size, NULL);&#xA;                    av_fifo_generic_write(fifo_video, picture->data[1], y_size/4, NULL);&#xA;                    av_fifo_generic_write(fifo_video, picture->data[2], y_size/4, NULL);&#xA;                    LeaveCriticalSection(&amp;VideoSection);&#xA;                }&#xA;            }&#xA;        }&#xA;        av_free_packet(&amp;packet);&#xA;    }&#xA;    av_frame_free(&amp;pFrame);&#xA;    av_frame_free(&amp;picture);&#xA;    return 0;&#xA;}&#xA;&#xA;DWORD WINAPI AudioCapThreadProc( LPVOID lpParam )&#xA;{&#xA;    AVPacket pkt;&#xA;    AVFrame *frame;&#xA;    frame = av_frame_alloc();&#xA;    int gotframe;&#xA;    while(bCap)&#xA;    {&#xA;        pkt.data = NULL;&#xA;        pkt.size = 0;&#xA;        if(av_read_frame(pFormatCtx_Audio,&amp;pkt) &lt; 0)&#xA;        {&#xA;            continue;&#xA;        }&#xA;&#xA;        if (avcodec_decode_audio4(pFormatCtx_Audio->streams[0]->codec, frame, &amp;gotframe, &amp;pkt) &lt; 0)&#xA;        {&#xA;            av_frame_free(&amp;frame);&#xA;            printf("can not decoder a frame");&#xA;            break;&#xA;        }&#xA;        av_free_packet(&amp;pkt);&#xA;&#xA;        if (!gotframe)&#xA;        {&#xA;            printf("没有获取到数据,继续下一次");&#xA;            continue;&#xA;        }&#xA;&#xA;        if (NULL == fifo_audio)&#xA;        {&#xA;            fifo_audio = av_audio_fifo_alloc(pFormatCtx_Audio->streams[0]->codec->sample_fmt, &#xA;                pFormatCtx_Audio->streams[0]->codec->channels, 30 * frame->nb_samples);&#xA;        }&#xA;&#xA;        int buf_space = av_audio_fifo_space(fifo_audio);&#xA;        if (av_audio_fifo_space(fifo_audio) >= frame->nb_samples)&#xA;        {&#xA;            EnterCriticalSection(&amp;AudioSection);&#xA;            av_audio_fifo_write(fifo_audio, (void **)frame->data, frame->nb_samples);&#xA;            LeaveCriticalSection(&amp;AudioSection);&#xA;        }&#xA;    }&#xA;    av_frame_free(&amp;frame);&#xA;    return 0;&#xA;}&#xA;

    &#xA;&#xA;

    Maybe there is another way to calculate PTS and DTS

    &#xA;&#xA;

    I hope whatever the frame rate is,video playback speed is right.Not too fast or too slow.

    &#xA;