Recherche avancée

Médias (91)

Autres articles (37)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

  • Les thèmes de MediaSpip

    4 juin 2013

    3 thèmes sont proposés à l’origine par MédiaSPIP. L’utilisateur MédiaSPIP peut rajouter des thèmes selon ses besoins.
    Thèmes MediaSPIP
    3 thèmes ont été développés au départ pour MediaSPIP : * SPIPeo : thème par défaut de MédiaSPIP. Il met en avant la présentation du site et les documents média les plus récents ( le type de tri peut être modifié - titre, popularité, date) . * Arscenic : il s’agit du thème utilisé sur le site officiel du projet, constitué notamment d’un bandeau rouge en début de page. La structure (...)

  • Dépôt de média et thèmes par FTP

    31 mai 2013, par

    L’outil MédiaSPIP traite aussi les média transférés par la voie FTP. Si vous préférez déposer par cette voie, récupérez les identifiants d’accès vers votre site MédiaSPIP et utilisez votre client FTP favori.
    Vous trouverez dès le départ les dossiers suivants dans votre espace FTP : config/ : dossier de configuration du site IMG/ : dossier des média déjà traités et en ligne sur le site local/ : répertoire cache du site web themes/ : les thèmes ou les feuilles de style personnalisées tmp/ : dossier de travail (...)

Sur d’autres sites (3976)

  • FFMPEG : Overlay Capture Time (w/Counter)

    27 juin 2022, par AdamK

    I am using the Shutter Encoder application on Windows to batch convert .MOV files, which provides the option of injecting custom FFMPEG commands for each file. The app natively offers overlay (drawtext) of timecode starting at 00:00:00:00. I also see that it knows and preserves the metadata time for each file as this is included in the commands "-metadata creation_time="2022-06-27T16:00:30.730888500Z"

    


    I would like to have the timecode start at the creation time, and was wondering how I might be able to offset the timecode as such. Or...is there another way of overlaying (drawtext-ing) a time counter, starting at creation time ? I would also like to overlay the creation date as well. Thanks in advance for your advice.

    


  • FFMPEG - rewarp MPEGDash to MP4 changes audio bitrate mode

    30 juin 2022, par Matthieu Ducorps

    I'm rewrapping some MPEGDash to MP4 wrapper and some files are outputed with variable audio bitrate where others with constant bitrate,and both sources looks exactly the same.

    


    For reference :

    


    I'm using FFMPEG 5.0 for the rewrapping

    


    ffmpeg version 5.0-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
    built with gcc 11.2.0 (Rev5, Built by MSYS2 project)
    configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
    libavutil      57. 17.100 / 57. 17.100
    libavcodec     59. 18.100 / 59. 18.100
    libavformat    59. 16.100 / 59. 16.100
    libavdevice    59.  4.100 / 59.  4.100
    libavfilter     8. 24.100 /  8. 24.100
    libswscale      6.  4.100 /  6.  4.100
    libswresample   4.  3.100 /  4.  3.100
    libpostproc    56.  3.100 / 56.  3.100


    


    And MediaInfo 22.09 to check the medias.

    


    MediaInfoVersion

    


    I'm using this command to rewrap the media :

    


    ffmpeg.exe -y -i MPEGDash.mpd -map 0:v -map 0:a -c copy OutFile.mp4


    


    This source MPEGDASH with constant audio bitrate

    


    General
Complete name                            : \\Constant\PROXY\A0002_30sec\MPEGDash_A0002_30sec.mpd
Format                                   : DASH MPD
File size                                : 4.14 MiB
Duration                                 : 30 s 80 ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 1 154 kb/s

Video
ID                                       : 0-1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3.1
Format settings                          : CABAC / 2 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 2 frames
Format settings, GOP                     : M=3, N=30
Muxing mode                              : dash
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 30 s 30 ms
Bit rate mode                            : Constant
Bit rate                                 : 640 kb/s
Width                                    : 640 pixels
Height                                   : 360 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.093
Stream size                              : 2.28 MiB (55%)
Language                                 : English
Encoded date                             : UTC 2022-06-30 08:20:16
Tagged date                              : UTC 2022-06-30 08:20:16
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Source                                   : V0_360p_640000/V0_360p_640000_init.mp4
Codec configuration box                  : avcC

Audio #1
ID                                       : 160-1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Muxing mode                              : dash
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Encoded date                             : UTC 2022-06-30 08:20:16
Tagged date                              : UTC 2022-06-30 08:20:16
Source                                   : A0_48000_128000/A0_48000_128000_init.mp4

Audio #2
ID                                       : 161-1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Muxing mode                              : dash
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Encoded date                             : UTC 2022-06-30 08:20:16
Tagged date                              : UTC 2022-06-30 08:20:16
Source                                   : A1_48000_128000/A1_48000_128000_init.mp4

Audio #3
ID                                       : 162-1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Muxing mode                              : dash
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Encoded date                             : UTC 2022-06-30 08:20:16
Tagged date                              : UTC 2022-06-30 08:20:16
Source                                   : A2_48000_128000/A2_48000_128000_init.mp4

Audio #4
ID                                       : 163-1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Muxing mode                              : dash
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Encoded date                             : UTC 2022-06-30 08:20:16
Tagged date                              : UTC 2022-06-30 08:20:16
Source                                   : A3_48000_128000/A3_48000_128000_init.mp4


    


    Has the expected output with constant audio bitrate on the MP4

    


    General
Complete name                            : \\Constant\PROXY\A0002_30sec\A0002_30sec.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 4.13 MiB
Duration                                 : 30 s 96 ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 1 152 kb/s
Movie name                               : MPEGDash_A0002_30sec.mpd
Writing application                      : Lavf59.16.100

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3.1
Format settings                          : CABAC / 2 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 2 frames
Format settings, GOP                     : M=3, N=30
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 30 s 96 ms
Source duration                          : 29 s 997 ms
Bit rate mode                            : Constant
Bit rate                                 : 590 kb/s
Nominal bit rate                         : 640 kb/s
Maximum bit rate                         : 636 kb/s
Width                                    : 640 pixels
Height                                   : 360 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.085
Stream size                              : 2.12 MiB (51%)
Source stream size                       : 2.28 MiB (55%)
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
mdhd_Duration                            : 30030
Codec configuration box                  : avcC

Audio #1
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 125 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Default                                  : Yes
Alternate group                          : 1

Audio #2
ID                                       : 3
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 125 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Default                                  : Yes
Alternate group                          : 2

Audio #3
ID                                       : 4
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 125 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Default                                  : Yes
Alternate group                          : 3

Audio #4
ID                                       : 5
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 125 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Default                                  : Yes
Alternate group                          : 4


    


    But this source MPEGDASH which has the same characteristics :

    


    General
Complete name                            : \\Variable\PROXY\A0005_30sec\MPEGDash_A0005_30sec.mpd
Format                                   : DASH MPD
File size                                : 4.15 MiB
Duration                                 : 30 s 80 ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 1 157 kb/s

Video
ID                                       : 0-1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3.1
Format settings                          : CABAC / 2 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 2 frames
Format settings, GOP                     : M=3, N=30
Muxing mode                              : dash
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 30 s 30 ms
Bit rate mode                            : Constant
Bit rate                                 : 640 kb/s
Width                                    : 640 pixels
Height                                   : 360 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.093
Stream size                              : 2.29 MiB (55%)
Language                                 : English
Encoded date                             : UTC 2022-06-30 08:24:03
Tagged date                              : UTC 2022-06-30 08:24:03
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Source                                   : V0_360p_640000/V0_360p_640000_init.mp4
Codec configuration box                  : avcC

Audio #1
ID                                       : 160-1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Muxing mode                              : dash
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 461 KiB (11%)
Language                                 : English
Encoded date                             : UTC 2022-06-30 08:24:03
Tagged date                              : UTC 2022-06-30 08:24:03
Source                                   : A0_48000_128000/A0_48000_128000_init.mp4

Audio #2
ID                                       : 161-1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Muxing mode                              : dash
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Encoded date                             : UTC 2022-06-30 08:24:03
Tagged date                              : UTC 2022-06-30 08:24:03
Source                                   : A1_48000_128000/A1_48000_128000_init.mp4

Audio #3
ID                                       : 162-1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Muxing mode                              : dash
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Encoded date                             : UTC 2022-06-30 08:24:03
Tagged date                              : UTC 2022-06-30 08:24:03
Source                                   : A2_48000_128000/A2_48000_128000_init.mp4

Audio #4
ID                                       : 163-1
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Muxing mode                              : dash
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Encoded date                             : UTC 2022-06-30 08:24:03
Tagged date                              : UTC 2022-06-30 08:24:03
Source                                   : A3_48000_128000/A3_48000_128000_init.mp4


    


    Has this output where the MP4 have the first audio with variable bitrate

    


    General
Complete name                            : \\Variable\PROXY\A0005_30sec\A0005_30sec.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 4.14 MiB
Duration                                 : 30 s 96 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 155 kb/s
Movie name                               : MPEGDash_A0005_30sec.mpd
Writing application                      : Lavf59.16.100

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3.1
Format settings                          : CABAC / 2 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 2 frames
Format settings, GOP                     : M=3, N=30
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 30 s 96 ms
Source duration                          : 29 s 997 ms
Bit rate mode                            : Constant
Bit rate                                 : 593 kb/s
Nominal bit rate                         : 640 kb/s
Maximum bit rate                         : 640 kb/s
Width                                    : 640 pixels
Height                                   : 360 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.086
Stream size                              : 2.13 MiB (51%)
Source stream size                       : 2.29 MiB (55%)
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
mdhd_Duration                            : 30030
Codec configuration box                  : avcC

Audio #1
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Variable
Bit rate                                 : 126 kb/s
Maximum bit rate                         : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 461 KiB (11%)
Language                                 : English
Default                                  : Yes
Alternate group                          : 1

Audio #2
ID                                       : 3
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 125 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Default                                  : Yes
Alternate group                          : 2

Audio #3
ID                                       : 4
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 125 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Default                                  : Yes
Alternate group                          : 3

Audio #4
ID                                       : 5
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 30 s 80 ms
Bit rate mode                            : Constant
Bit rate                                 : 125 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 460 KiB (11%)
Language                                 : English
Default                                  : Yes
Alternate group                          : 4


    


    Maybe I'm missing something but,I don't see what.

    


  • ffmpeg concat doesn't sync to manual frame by frame concatenation

    5 juillet 2022, par memo

    I have hundreds of short (10-120seconds) videos (H264 mp4) with audio (aac). (let's call these 'clips'). All identical video and audio codecs, resolution, framerate, crf, pixel format, sample rate etc.

    


    concat_demux :

    


    If I concat these with ffmpeg concat (demuxer), I get a single nice H264 mp4 with audio perfectly synced to the video (as expected).

    


    cmd_args = ['ffmpeg',
            '-f concat',
            '-safe 0',
            f'-i "{output_filelist_path}"',
            '-c copy',
            '-y',
            '-r 30', # trying this out of desperation
            f'"{output_concat_demux}"'
            ]

cmd = ' '.join(cmd_args)
r = subprocess.call(cmd, shell=True, cwd=args.output_dir)


    


    frame_by_frame :

    


    However, if I manually iterate every frame of every clip video and write the frames to an mp4 using skvideo.io, this video drifts out of sync with the concat_demux version.

    


    input_dict = { '-r':str(fps) } 
output_dict = { '-r':str(fps), '-pix_fmt':'yuv420p', '-vcodec':'libx264', '-crf':'18' }
video_writer = skvideo.io.FFmpegWriter(output_path, inputdict=input_dict, outputdict=output_dict) 

for video_path in video_paths:
   video = skvideo.io.vread(video_path) # read all frames into np.array
   for frame in video:
      video_writer.writeFrame(frame)
video_writer.close()


    


    When I compare these two files in a video editor (e.g. AfterEffects) and step through frame by frame, I can see that with every new clip, the frame_by_frame version slips 1 or 2 frames ahead of the ffmpeg concat_demux version. What is going on ? How can I fix - or at least debug - this ?

    


    On a side note, I do need to concatenate manually frame by frame, as I'm also doing a ton of other stuff (triggering events on clip change, overlaying additional elements etc). And I need to be able to sync a concatenated audio. I was hoping to concatenate the video manually frame by frame and do my post-processing, and then mux with the audio from the ffmpeg concat_demux version. But alas they drift out of sync.

    



    


    (I've found quite a few posts on SO where the problem is using ffmpeg concat results in videos which are out of sync with the audio. However, this is not my problem. My video created with ffmpeg concat is perfectly in sync with the audio, but it's out of sync with a manually frame-by-frame concatenated video.)

    



    


    Update - concat_protocol

    


    I've tried using the concat protocol. Now the output of this gives a file where the video is frame synced to the frame_by_frame version, BUT the audio is synced to the audio of the concat_demux version. So its audio is out of sync with the video.

    


    intermediate_paths = []
for p in clip_file_list:
    intermediate_path = os.path.join(args.output_dir, 'intermediate', os.path.basename(p) + '.ts')
    intermediate_paths.append(intermediate_path)
    cmd_args = ['ffmpeg',
        f'-i "{p}"',
        '-c copy -bsf:v h264_mp4toannexb -f mpegts -y',
        f'"{intermediate_path}"'
        ]

    cmd = ' '.join(cmd_args)
    r = subprocess.call(cmd, shell=True, cwd=args.output_dir)


intermediate_paths = '|'.join(intermediate_paths)
cmd_args = ['ffmpeg',
            f'-i "concat:{intermediate_paths}"',
            '-c copy -bsf:a aac_adtstoasc',
            f'"{output_concat_path}"'
            ]

cmd = ' '.join(cmd_args)
r = subprocess.call(cmd, shell=True, cwd=args.output_dir)


    


    I am getting loads of errors like below

    


        corrupt input packet in stream 0
[mp4 @ 0x137e043d0] Non-monotonous DTS in output stream 0:1; previous: 83027966, current: 83027198; changing to 83027967. This may result in incorrect timestamps in the output file.


    



    


    here's the info on the two output files. Input #0 is the ffmpeg concat_demux. Input #1 is the manual frame-by-frame. Note the concat.mp4 has a framerate of 29.94 fps. I'm not sure if this is the problem. I couldn't figure out how to make this 30 (see '-r 30' in the ffmpeg concat command above)

    


    ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with Apple clang version 13.1.6 (clang-1316.0.21.2.5)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.0.1_2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'clips_concat.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf59.16.100
  Duration: 00:01:43.22, start: 0.000000, bitrate: 5412 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1080 [SAR 1:1 DAR 1:1], 5276 kb/s, 29.94 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'clips_frames.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf59.16.100
  Duration: 00:01:43.00, start: 0.000000, bitrate: 4917 kb/s
  Stream #1:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1080, 4914 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]


    



    


    here's info on first few clips (the manual concat is already 2 frames out of sync with the ffmpeg concat version by the second clip !)

    


    ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with Apple clang version 13.1.6 (clang-1316.0.21.2.5)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.0.1_2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'clip_1080px_0.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:05.02, start: 0.000000, bitrate: 3944 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1080 [SAR 1:1 DAR 1:1], 3818 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 131 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'clip_1080px_1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:05.02, start: 0.000000, bitrate: 4557 kb/s
  Stream #1:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1080 [SAR 1:1 DAR 1:1], 4438 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #1:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'clip_1080px_2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:11.02, start: 0.000000, bitrate: 5447 kb/s
  Stream #2:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1080 [SAR 1:1 DAR 1:1], 5320 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #2:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Input #3, mov,mp4,m4a,3gp,3g2,mj2, from 'clip_1080px_3.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:11.02, start: 0.000000, bitrate: 5978 kb/s
  Stream #3:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1080 [SAR 1:1 DAR 1:1], 5851 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #3:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Input #4, mov,mp4,m4a,3gp,3g2,mj2, from 'clip_1080px_4.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:16.02, start: 0.000000, bitrate: 6570 kb/s
  Stream #4:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1080 [SAR 1:1 DAR 1:1], 6441 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #4:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Input #5, mov,mp4,m4a,3gp,3g2,mj2, from 'clip_1080px_5.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:13.02, start: 0.000000, bitrate: 5069 kb/s
  Stream #5:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1080 [SAR 1:1 DAR 1:1], 4940 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #5:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Input #6, mov,mp4,m4a,3gp,3g2,mj2, from 'clip_1080px_6.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:22.02, start: 0.000000, bitrate: 4775 kb/s
  Stream #6:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1080 [SAR 1:1 DAR 1:1], 4642 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #6:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Input #7, mov,mp4,m4a,3gp,3g2,mj2, from 'clip_1080px_7.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:22.02, start: 0.000000, bitrate: 5402 kb/s
  Stream #7:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1080x1080 [SAR 1:1 DAR 1:1], 5269 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #7:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]