Recherche avancée

Médias (1)

Mot : - Tags -/lev manovitch

Autres articles (105)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • Formulaire personnalisable

    21 juin 2013, par

    Cette page présente les champs disponibles dans le formulaire de publication d’un média et il indique les différents champs qu’on peut ajouter. Formulaire de création d’un Media
    Dans le cas d’un document de type média, les champs proposés par défaut sont : Texte Activer/Désactiver le forum ( on peut désactiver l’invite au commentaire pour chaque article ) Licence Ajout/suppression d’auteurs Tags
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire. (...)

  • Qu’est ce qu’un masque de formulaire

    13 juin 2013, par

    Un masque de formulaire consiste en la personnalisation du formulaire de mise en ligne des médias, rubriques, actualités, éditoriaux et liens vers des sites.
    Chaque formulaire de publication d’objet peut donc être personnalisé.
    Pour accéder à la personnalisation des champs de formulaires, il est nécessaire d’aller dans l’administration de votre MediaSPIP puis de sélectionner "Configuration des masques de formulaires".
    Sélectionnez ensuite le formulaire à modifier en cliquant sur sont type d’objet. (...)

Sur d’autres sites (6282)

  • missing audio of second video after combining video

    27 mai 2021, par JohnTerry

    I am trying to add xfade filter and the command is working but audio of second video is missing in output video.

    


    command is -

    


    ffmpeg -i 1.mp4 -i 1.mp4  -filter_complex "[0:v]scale=480:360:force_original_aspect_ratio=decrease,pad=480:360:-1:-1,setsar=1,fps=30,format=yuv420p[v0];[1:v]scale=480:360:force_original_aspect_ratio=decrease,pad=480:360:-1:-1,setsar=1,fps=30,format=yuv420p[v1];
[v0][v1]xfade=transition=pixelize:duration=1:offset=7,format=yuv420p" -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -c:a libopus -deadline good -cpu-used 8 output.webm


    


    the full log is below-

    


    ffmpeg version n4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: --prefix= --prefix=/usr --disable-debug --disable-doc - 
-disable-static --enable-cuda --enable-cuda-sdk --enable-cuvid -- 
enable-libdrm --enable-ffplay --enable-gnutls --enable-gpl --enable- 
libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype 
--enable-libmp3lame --enable-libnpp --enable-libopencore_amrnb -- 
enable-libopencore_amrwb --enable-libopus --enable-libpulse --enable-
sdl2 --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-nonfree --enable-nvenc --enable-omx --enable-openal --enable-opencl --enable-runtime-cpudetect --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-xlib
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:09.12, start: 0.000000, bitrate: 702 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 474x360, 568 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:08.75, start: 0.000000, bitrate: 2546 kb/s
    Stream #1:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x360, 2416 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 (h264) -> scale (graph 0)
  Stream #1:0 (h264) -> scale (graph 0)
  format (graph 0) -> Stream #0:0 (libvpx-vp9)
  Stream #0:1 -> #0:1 (mp3 (mp3float) -> opus (libopus))
Press [q] to stop, [?] for help
[libvpx-vp9 @ 0x561afcf3a280] v1.7.0
Output #0, webm, to 'output.webm':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
    Stream #0:0: Video: vp9 (libvpx-vp9), yuv420p, 480x360 [SAR 1:1 DAR 4:3], q=-1--1, 30 fps, 1k tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc58.91.100 libvpx-vp9
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
    Stream #0:1(und): Audio: opus (libopus), 48000 Hz, stereo, flt, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc58.91.100 libopus
frame=   87 fps=0.0 q=0.0 size=       1kB time=00:00:03.19 bitrate=   2.1kbits/sframe=  157 fps=156 q=0.0 size=     171kB time=00:00:05.51 bitrate= 254.3kbits/sframe=  227 fps=150 q=0.0 size=     171kB time=00:00:07.85 bitrate= 178.5kbits/sframe=  265 fps=131 q=0.0 size=     171kB time=00:00:08.31 bitrate= 168.7kbits/sframe=  303 fps=120 q=0.0 size=     256kB time=00:00:09.30 bitrate= 225.5kbits/sframe=  341 fps=113 q=0.0 size=     256kB time=00:00:10.56 bitrate= 198.4kbits/sframe=  379 fps=107 q=0.0 size=     256kB time=00:00:11.83 bitrate= 177.2kbits/sframe=  416 fps=103 q=0.0 size=     256kB time=00:00:13.06 bitrate= 160.5kbits/sframe=  454 fps=100 q=0.0 size=     256kB time=00:00:14.33 bitrate= 146.3kbits/sframe=  472 fps= 93 q=0.0 Lsize=    1168kB time=00:00:15.73 bitrate= 608.2kbits/s speed=3.09x    
video:1036kB audio:125kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.629681%


    


    when using online url which has no audio getting this error-
getting this error-

    


        ffmpeg version n4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --prefix= --prefix=/usr --disable-debug --disable-doc --disable-static --enable-cuda --enable-cuda-sdk --enable-cuvid --enable-libdrm --enable-ffplay --enable-gnutls --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libnpp --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopus --enable-libpulse --enable-sdl2 --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-nonfree --enable-nvenc --enable-omx --enable-openal --enable-opencl --enable-runtime-cpudetect --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-xlib
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://player.vimeo.com/external/183300180.sd.mp4?s=8d9b1561f39df586af49fe5ab105f57f5873854b&profile_id=164':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41isomavc1
    creation_time   : 2016-09-19T12:39:02.000000Z
  Duration: 00:00:10.00, start: 0.000000, bitrate: 489 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt470bg/smpte170m/bt470bg), 640x360 [SAR 1:1 DAR 16:9], 486 kb/s, 30 fps, 30 tbr, 30 tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2016-09-19T12:39:02.000000Z
      handler_name    : L-SMASH Video Handler
      encoder         : AVC Coding
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'https://player.vimeo.com/external/166335878.sd.mp4?s=828bf6e8594fab383d7ee6bac40d3f247cc40af9&profile_id=164':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41isomavc1
    creation_time   : 2016-05-12T09:34:11.000000Z
  Duration: 00:00:10.01, start: 0.000000, bitrate: 479 kb/s
    Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt470bg/smpte170m/bt470bg), 474x360 [SAR 1:1 DAR 79:60], 345 kb/s, 30 fps, 30 tbr, 30 tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2016-05-12T09:34:11.000000Z
      handler_name    : L-SMASH Video Handler
      encoder         : AVC Coding
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2016-05-12T09:34:11.000000Z
      handler_name    : L-SMASH Audio Handler
Stream specifier ':a' in filtergraph description [0:v]scale=614:360:force_original_aspect_ratio=decrease,pad=614:360:-1:-1,setsar=1,fps=30,format=yuv420p[v0];[1:v]scale=614:360:force_original_aspect_ratio=decrease,pad=614:360:-1:-1,setsar=1,fps=30,format=yuv420p[v1];[v0][v1]xfade=transition=pixelize:duration=1:offset=8,format=yuv420p;[0:a][1:a]acrossfade=d=0 matches no streams.


    


  • How to execute an ffmpeg function using ```ffmpeg-static-electron```

    4 avril 2021, par Radespy

    Thanks in advance.

    


    I'm creating an electron-react-app using electron-forge and want to crop a video file using child_process.execFile() from the main process.

    


    OS : Windows 10 Pro

    


    I've tried the following code in the main process after installing ffmpeg-static-electron package :

    


    const ffmpeg = require('ffmpeg-static-electron');
const { execFile, exec } = require("child_process");

exec(`${ffmpeg.path}`, (error, stdout, stderr) => {
      if (error) {
              console.log(error.message)
            }
            if (stderr) {
              console.log(stderr)
            }
           console.log(stdout)
    })


    


    I get the following output :

    


     'ffmpeg' is not recognized as an internal or external command,
operable program or batch file.
[1]
[1] Command failed: C:\Users\xxxx\Desktop\electron-forge-working-branch-1\node_modules\ffmpeg-static-electron\bin\win\x64\ffmpeg.exe


[1] ffmpeg version 3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
[1]   built with gcc 5.3.0 (GCC)
[1]   configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
[1]   libavutil      55. 17.103 / 55. 17.103
[1]   libavcodec     57. 24.102 / 57. 24.102
[1]   libavformat    57. 25.100 / 57. 25.100
[1]   libavdevice    57.  0.101 / 57.  0.101
[1]   libavfilter     6. 31.100 /  6. 31.100
[1]   libswscale      4.  0.100 /  4.  0.100
[1]   libswresample   2.  0.101 /  2.  0.101
[1]   libpostproc    54.  0.100 / 54.  0.100
[1] Hyper fast Audio and Video encoder
[1] usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
[1]
[1] Use -h to get full help or, even better, run 'man ffmpeg'
[1]
[1] ffmpeg version 3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
[1]   built with gcc 5.3.0 (GCC)
[1]   configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
[1]   libavutil      55. 17.103 / 55. 17.103
[1]   libavcodec     57. 24.102 / 57. 24.102
[1]   libavformat    57. 25.100 / 57. 25.100
[1]   libavdevice    57.  0.101 / 57.  0.101
[1]   libavfilter     6. 31.100 /  6. 31.100
[1]   libswscale      4.  0.100 /  4.  0.100
[1]   libswresample   2.  0.101 /  2.  0.101
[1]   libpostproc    54.  0.100 / 54.  0.100
[1] Hyper fast Audio and Video encoder
[1] usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
[1]
[1] Use -h to get full help or, even better, run 'man ffmpeg'


    


    The command appears to be failing however, the correct output from ffmpeg is subsequently shown.

    


    Can anyone explain whats happening here ?

    


    I've also run a test function :

    


    execFile(`${ffmpeg.path}`, 
    ['ffmpeg -i test_video.mp4 -vf test_video.webm'], 
    {cwd: './temp'}, 
    (error, stdout, stderr) => {
        if (error) {
          console.log(error.message)
        }
        if (stderr) {
          console.log(stderr)
        }
       console.log(stdout)
      })


    


    and am getting the following message :

    


    [1] 'ffmpeg' is not recognized as an internal or external command,
[1] operable program or batch file.
[1] 
[1] Command failed: C:\Users\xxxx\Desktop\electron-forge-working-branch-1\node_modules\ffmpeg-static-electron\bin\win\x64\ffmpeg.exe ffmpeg -i test_video.mp4 -vf test_video.webm

[1] ffmpeg version 3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
[1]   built with gcc 5.3.0 (GCC)
[1]   configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
[1]   libavutil      55. 17.103 / 55. 17.103
[1]   libavcodec     57. 24.102 / 57. 24.102
[1]   libavformat    57. 25.100 / 57. 25.100
[1]   libavdevice    57.  0.101 / 57.  0.101
[1]   libavfilter     6. 31.100 /  6. 31.100
[1]   libswscale      4.  0.100 /  4.  0.100
[1]   libswresample   2.  0.101 /  2.  0.101
[1]   libpostproc    54.  0.100 / 54.  0.100


[1] Output #0, webm, to 'ffmpeg -i test_video.mp4 -vf test_video.webm':
[1] 

Output file #0 does not contain any stream
[1]
[1] ffmpeg version 3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
[1]   built with gcc 5.3.0 (GCC)
[1]   configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
[1]   libavutil      55. 17.103 / 55. 17.103
[1]   libavcodec     57. 24.102 / 57. 24.102
[1]   libavformat    57. 25.100 / 57. 25.100
[1]   libavdevice    57.  0.101 / 57.  0.101
[1]   libavfilter     6. 31.100 /  6. 31.100
[1]   libswscale      4.  0.100 /  4.  0.100
[1]   libswresample   2.  0.101 /  2.  0.101
[1]   libpostproc    54.  0.100 / 54.  0.100
[1] Output #0, webm, to 'ffmpeg -i test_video.mp4 -vf test_video.webm':
[1] Output file #0 does not contain any stream


    


    Again, not sure what I'm doing wrong.

    


    Any help with being able to execute ffmpeg functions from within the Main process would be very much appreciated.

    


    Thanks.

    


  • Why does adding audio stream to ffmpeg's libavcodec output container cause a crash ?

    29 mars 2021, par Sniggerfardimungus

    As it stands, my project correctly uses libavcodec to decode a video, where each frame is manipulated (it doesn't matter how) and output to a new video. I've cobbled this together from examples found online, and it works. The result is a perfect .mp4 of the manipulated frames, minus the audio.

    


    My problem is, when I try to add an audio stream to the output container, I get a crash in mux.c that I can't explain. It's in static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *pkt). Where st->internal->priv_pts->val = pkt->dts; is attempted, priv_pts is nullptr.

    


    I don't recall the version number, but this is from a November 4, 2020 ffmpeg build from git.

    


    My MediaContentMgr is much bigger than what I have here. I'm stripping out everything to do with the frame manipulation, so if I'm missing anything, please let me know and I'll edit.

    


    The code that, when added, triggers the nullptr exception, is called out inline

    


    The .h :

    


    #ifndef _API_EXAMPLE_H&#xA;#define _API_EXAMPLE_H&#xA;&#xA;#include <glad></glad>glad.h>&#xA;#include <glfw></glfw>glfw3.h>&#xA;#include "glm/glm.hpp"&#xA;&#xA;extern "C" {&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>avutil.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;}&#xA;&#xA;#include "shader_s.h"&#xA;&#xA;class MediaContainerMgr {&#xA;public:&#xA;    MediaContainerMgr(const std::string&amp; infile, const std::string&amp; vert, const std::string&amp; frag, &#xA;                      const glm::vec3* extents);&#xA;    ~MediaContainerMgr();&#xA;    void render();&#xA;    bool recording() { return m_recording; }&#xA;&#xA;    // Major thanks to "shi-yan" who helped make this possible:&#xA;    // https://github.com/shi-yan/videosamples/blob/master/libavmp4encoding/main.cpp&#xA;    bool init_video_output(const std::string&amp; video_file_name, unsigned int width, unsigned int height);&#xA;    bool output_video_frame(uint8_t* buf);&#xA;    bool finalize_output();&#xA;&#xA;private:&#xA;    AVFormatContext*   m_format_context;&#xA;    AVCodec*           m_video_codec;&#xA;    AVCodec*           m_audio_codec;&#xA;    AVCodecParameters* m_video_codec_parameters;&#xA;    AVCodecParameters* m_audio_codec_parameters;&#xA;    AVCodecContext*    m_codec_context;&#xA;    AVFrame*           m_frame;&#xA;    AVPacket*          m_packet;&#xA;    uint32_t           m_video_stream_index;&#xA;    uint32_t           m_audio_stream_index;&#xA;    &#xA;    void init_rendering(const glm::vec3* extents);&#xA;    int decode_packet();&#xA;&#xA;    // For writing the output video:&#xA;    void free_output_assets();&#xA;    bool                   m_recording;&#xA;    AVOutputFormat*        m_output_format;&#xA;    AVFormatContext*       m_output_format_context;&#xA;    AVCodec*               m_output_video_codec;&#xA;    AVCodecContext*        m_output_video_codec_context;&#xA;    AVFrame*               m_output_video_frame;&#xA;    SwsContext*            m_output_scale_context;&#xA;    AVStream*              m_output_video_stream;&#xA;    &#xA;    AVCodec*               m_output_audio_codec;&#xA;    AVStream*              m_output_audio_stream;&#xA;    AVCodecContext*        m_output_audio_codec_context;&#xA;};&#xA;&#xA;#endif&#xA;

    &#xA;

    And, the hellish .cpp :

    &#xA;

    #include &#xA;#include &#xA;#include &#xA;#include &#xA;#include &#xA;&#xA;#include "media_container_manager.h"&#xA;&#xA;MediaContainerMgr::MediaContainerMgr(const std::string&amp; infile, const std::string&amp; vert, const std::string&amp; frag,&#xA;    const glm::vec3* extents) :&#xA;    m_video_stream_index(-1),&#xA;    m_audio_stream_index(-1),&#xA;    m_recording(false),&#xA;    m_output_format(nullptr),&#xA;    m_output_format_context(nullptr),&#xA;    m_output_video_codec(nullptr),&#xA;    m_output_video_codec_context(nullptr),&#xA;    m_output_video_frame(nullptr),&#xA;    m_output_scale_context(nullptr),&#xA;    m_output_video_stream(nullptr)&#xA;{&#xA;    // AVFormatContext holds header info from the format specified in the container:&#xA;    m_format_context = avformat_alloc_context();&#xA;    if (!m_format_context) {&#xA;        throw "ERROR could not allocate memory for Format Context";&#xA;    }&#xA;    &#xA;    // open the file and read its header. Codecs are not opened here.&#xA;    if (avformat_open_input(&amp;m_format_context, infile.c_str(), NULL, NULL) != 0) {&#xA;        throw "ERROR could not open input file for reading";&#xA;    }&#xA;&#xA;    printf("format %s, duration %lldus, bit_rate %lld\n", m_format_context->iformat->name, m_format_context->duration, m_format_context->bit_rate);&#xA;    //read avPackets (?) from the avFormat (?) to get stream info. This populates format_context->streams.&#xA;    if (avformat_find_stream_info(m_format_context, NULL) &lt; 0) {&#xA;        throw "ERROR could not get stream info";&#xA;    }&#xA;&#xA;    for (unsigned int i = 0; i &lt; m_format_context->nb_streams; i&#x2B;&#x2B;) {&#xA;        AVCodecParameters* local_codec_parameters = NULL;&#xA;        local_codec_parameters = m_format_context->streams[i]->codecpar;&#xA;        printf("AVStream->time base before open coded %d/%d\n", m_format_context->streams[i]->time_base.num, m_format_context->streams[i]->time_base.den);&#xA;        printf("AVStream->r_frame_rate before open coded %d/%d\n", m_format_context->streams[i]->r_frame_rate.num, m_format_context->streams[i]->r_frame_rate.den);&#xA;        printf("AVStream->start_time %" PRId64 "\n", m_format_context->streams[i]->start_time);&#xA;        printf("AVStream->duration %" PRId64 "\n", m_format_context->streams[i]->duration);&#xA;        printf("duration(s): %lf\n", (float)m_format_context->streams[i]->duration / m_format_context->streams[i]->time_base.den * m_format_context->streams[i]->time_base.num);&#xA;        AVCodec* local_codec = NULL;&#xA;        local_codec = avcodec_find_decoder(local_codec_parameters->codec_id);&#xA;        if (local_codec == NULL) {&#xA;            throw "ERROR unsupported codec!";&#xA;        }&#xA;&#xA;        if (local_codec_parameters->codec_type == AVMEDIA_TYPE_VIDEO) {&#xA;            if (m_video_stream_index == -1) {&#xA;                m_video_stream_index = i;&#xA;                m_video_codec = local_codec;&#xA;                m_video_codec_parameters = local_codec_parameters;&#xA;            }&#xA;            m_height = local_codec_parameters->height;&#xA;            m_width = local_codec_parameters->width;&#xA;            printf("Video Codec: resolution %dx%d\n", m_width, m_height);&#xA;        }&#xA;        else if (local_codec_parameters->codec_type == AVMEDIA_TYPE_AUDIO) {&#xA;            if (m_audio_stream_index == -1) {&#xA;                m_audio_stream_index = i;&#xA;                m_audio_codec = local_codec;&#xA;                m_audio_codec_parameters = local_codec_parameters;&#xA;            }&#xA;            printf("Audio Codec: %d channels, sample rate %d\n", local_codec_parameters->channels, local_codec_parameters->sample_rate);&#xA;        }&#xA;&#xA;        printf("\tCodec %s ID %d bit_rate %lld\n", local_codec->name, local_codec->id, local_codec_parameters->bit_rate);&#xA;    }&#xA;&#xA;    m_codec_context = avcodec_alloc_context3(m_video_codec);&#xA;    if (!m_codec_context) {&#xA;        throw "ERROR failed to allocate memory for AVCodecContext";&#xA;    }&#xA;&#xA;    if (avcodec_parameters_to_context(m_codec_context, m_video_codec_parameters) &lt; 0) {&#xA;        throw "ERROR failed to copy codec params to codec context";&#xA;    }&#xA;&#xA;    if (avcodec_open2(m_codec_context, m_video_codec, NULL) &lt; 0) {&#xA;        throw "ERROR avcodec_open2 failed to open codec";&#xA;    }&#xA;&#xA;    m_frame = av_frame_alloc();&#xA;    if (!m_frame) {&#xA;        throw "ERROR failed to allocate AVFrame memory";&#xA;    }&#xA;&#xA;    m_packet = av_packet_alloc();&#xA;    if (!m_packet) {&#xA;        throw "ERROR failed to allocate AVPacket memory";&#xA;    }&#xA;}&#xA;&#xA;MediaContainerMgr::~MediaContainerMgr() {&#xA;    avformat_close_input(&amp;m_format_context);&#xA;    av_packet_free(&amp;m_packet);&#xA;    av_frame_free(&amp;m_frame);&#xA;    avcodec_free_context(&amp;m_codec_context);&#xA;&#xA;&#xA;    glDeleteVertexArrays(1, &amp;m_VAO);&#xA;    glDeleteBuffers(1, &amp;m_VBO);&#xA;}&#xA;&#xA;&#xA;bool MediaContainerMgr::advance_frame() {&#xA;    while (true) {&#xA;        if (av_read_frame(m_format_context, m_packet) &lt; 0) {&#xA;            // Do we actually need to unref the packet if it failed?&#xA;            av_packet_unref(m_packet);&#xA;            continue;&#xA;            //return false;&#xA;        }&#xA;        else {&#xA;            if (m_packet->stream_index == m_video_stream_index) {&#xA;                //printf("AVPacket->pts %" PRId64 "\n", m_packet->pts);&#xA;                int response = decode_packet();&#xA;                av_packet_unref(m_packet);&#xA;                if (response != 0) {&#xA;                    continue;&#xA;                    //return false;&#xA;                }&#xA;                return true;&#xA;            }&#xA;            else {&#xA;                printf("m_packet->stream_index: %d\n", m_packet->stream_index);&#xA;                printf("  m_packet->pts: %lld\n", m_packet->pts);&#xA;                printf("  mpacket->size: %d\n", m_packet->size);&#xA;                if (m_recording) {&#xA;                    int err = 0;&#xA;                    //err = avcodec_send_packet(m_output_video_codec_context, m_packet);&#xA;                    printf("  encoding error: %d\n", err);&#xA;                }&#xA;            }&#xA;        }&#xA;&#xA;        // We&#x27;re done with the packet (it&#x27;s been unpacked to a frame), so deallocate &amp; reset to defaults:&#xA;/*&#xA;        if (m_frame == NULL)&#xA;            return false;&#xA;&#xA;        if (m_frame->data[0] == NULL || m_frame->data[1] == NULL || m_frame->data[2] == NULL) {&#xA;            printf("WARNING: null frame data");&#xA;            continue;&#xA;        }&#xA;*/&#xA;    }&#xA;}&#xA;&#xA;int MediaContainerMgr::decode_packet() {&#xA;    // Supply raw packet data as input to a decoder&#xA;    // https://ffmpeg.org/doxygen/trunk/group__lavc__decoding.html#ga58bc4bf1e0ac59e27362597e467efff3&#xA;    int response = avcodec_send_packet(m_codec_context, m_packet);&#xA;&#xA;    if (response &lt; 0) {&#xA;        char buf[256];&#xA;        av_strerror(response, buf, 256);&#xA;        printf("Error while receiving a frame from the decoder: %s\n", buf);&#xA;        return response;&#xA;    }&#xA;&#xA;    // Return decoded output data (into a frame) from a decoder&#xA;    // https://ffmpeg.org/doxygen/trunk/group__lavc__decoding.html#ga11e6542c4e66d3028668788a1a74217c&#xA;    response = avcodec_receive_frame(m_codec_context, m_frame);&#xA;    if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {&#xA;        return response;&#xA;    } else if (response &lt; 0) {&#xA;        char buf[256];&#xA;        av_strerror(response, buf, 256);&#xA;        printf("Error while receiving a frame from the decoder: %s\n", buf);&#xA;        return response;&#xA;    } else {&#xA;        printf(&#xA;            "Frame %d (type=%c, size=%d bytes) pts %lld key_frame %d [DTS %d]\n",&#xA;            m_codec_context->frame_number,&#xA;            av_get_picture_type_char(m_frame->pict_type),&#xA;            m_frame->pkt_size,&#xA;            m_frame->pts,&#xA;            m_frame->key_frame,&#xA;            m_frame->coded_picture_number&#xA;        );&#xA;    }&#xA;    return 0;&#xA;}&#xA;&#xA;&#xA;bool MediaContainerMgr::init_video_output(const std::string&amp; video_file_name, unsigned int width, unsigned int height) {&#xA;    if (m_recording)&#xA;        return true;&#xA;    m_recording = true;&#xA;&#xA;    advance_to(0L); // I&#x27;ve deleted the implmentation. Just seeks to beginning of vid. Works fine.&#xA;&#xA;    if (!(m_output_format = av_guess_format(nullptr, video_file_name.c_str(), nullptr))) {&#xA;        printf("Cannot guess output format.\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    int err = avformat_alloc_output_context2(&amp;m_output_format_context, m_output_format, nullptr, video_file_name.c_str());&#xA;    if (err &lt; 0) {&#xA;        printf("Failed to allocate output context.\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    //TODO(P0): Break out the video and audio inits into their own methods.&#xA;    m_output_video_codec = avcodec_find_encoder(m_output_format->video_codec);&#xA;    if (!m_output_video_codec) {&#xA;        printf("Failed to create video codec.\n");&#xA;        return false;&#xA;    }&#xA;    m_output_video_stream = avformat_new_stream(m_output_format_context, m_output_video_codec);&#xA;    if (!m_output_video_stream) {&#xA;        printf("Failed to find video format.\n");&#xA;        return false;&#xA;    } &#xA;    m_output_video_codec_context = avcodec_alloc_context3(m_output_video_codec);&#xA;    if (!m_output_video_codec_context) {&#xA;        printf("Failed to create video codec context.\n");&#xA;        return(false);&#xA;    }&#xA;    m_output_video_stream->codecpar->codec_id = m_output_format->video_codec;&#xA;    m_output_video_stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    m_output_video_stream->codecpar->width = width;&#xA;    m_output_video_stream->codecpar->height = height;&#xA;    m_output_video_stream->codecpar->format = AV_PIX_FMT_YUV420P;&#xA;    // Use the same bit rate as the input stream.&#xA;    m_output_video_stream->codecpar->bit_rate = m_format_context->streams[m_video_stream_index]->codecpar->bit_rate;&#xA;    m_output_video_stream->avg_frame_rate = m_format_context->streams[m_video_stream_index]->avg_frame_rate;&#xA;    avcodec_parameters_to_context(m_output_video_codec_context, m_output_video_stream->codecpar);&#xA;    m_output_video_codec_context->time_base = m_format_context->streams[m_video_stream_index]->time_base;&#xA;    &#xA;    //TODO(P1): Set these to match the input stream?&#xA;    m_output_video_codec_context->max_b_frames = 2;&#xA;    m_output_video_codec_context->gop_size = 12;&#xA;    m_output_video_codec_context->framerate = m_format_context->streams[m_video_stream_index]->r_frame_rate;&#xA;    //m_output_codec_context->refcounted_frames = 0;&#xA;    if (m_output_video_stream->codecpar->codec_id == AV_CODEC_ID_H264) {&#xA;        av_opt_set(m_output_video_codec_context, "preset", "ultrafast", 0);&#xA;    } else if (m_output_video_stream->codecpar->codec_id == AV_CODEC_ID_H265) {&#xA;        av_opt_set(m_output_video_codec_context, "preset", "ultrafast", 0);&#xA;    } else {&#xA;        av_opt_set_int(m_output_video_codec_context, "lossless", 1, 0);&#xA;    }&#xA;    avcodec_parameters_from_context(m_output_video_stream->codecpar, m_output_video_codec_context);&#xA;&#xA;    m_output_audio_codec = avcodec_find_encoder(m_output_format->audio_codec);&#xA;    if (!m_output_audio_codec) {&#xA;        printf("Failed to create audio codec.\n");&#xA;        return false;&#xA;    }&#xA;

    &#xA;

    I've commented out all of the audio stream init beyond this next line, because this is where&#xA;the trouble begins. Creating this output stream causes the null reference I mentioned. If I&#xA;uncomment everything below here, I still get the null deref. If I comment out this line, the&#xA;deref exception vanishes. (IOW, I commented out more and more code until I found that this&#xA;was the trigger that caused the problem.)

    &#xA;

    I assume that there's something I'm doing wrong in the rest of the commented out code, that,&#xA;when fixed, will fix the nullptr and give me a working audio stream.

    &#xA;

        m_output_audio_stream = avformat_new_stream(m_output_format_context, m_output_audio_codec);&#xA;    if (!m_output_audio_stream) {&#xA;        printf("Failed to find audio format.\n");&#xA;        return false;&#xA;    }&#xA;    /*&#xA;    m_output_audio_codec_context = avcodec_alloc_context3(m_output_audio_codec);&#xA;    if (!m_output_audio_codec_context) {&#xA;        printf("Failed to create audio codec context.\n");&#xA;        return(false);&#xA;    }&#xA;    m_output_audio_stream->codecpar->codec_id = m_output_format->audio_codec;&#xA;    m_output_audio_stream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;&#xA;    m_output_audio_stream->codecpar->format = m_format_context->streams[m_audio_stream_index]->codecpar->format;&#xA;    m_output_audio_stream->codecpar->bit_rate = m_format_context->streams[m_audio_stream_index]->codecpar->bit_rate;&#xA;    m_output_audio_stream->avg_frame_rate = m_format_context->streams[m_audio_stream_index]->avg_frame_rate;&#xA;    avcodec_parameters_to_context(m_output_audio_codec_context, m_output_audio_stream->codecpar);&#xA;    m_output_audio_codec_context->time_base = m_format_context->streams[m_audio_stream_index]->time_base;&#xA;    */&#xA;&#xA;    //TODO(P2): Free assets that have been allocated.&#xA;    err = avcodec_open2(m_output_video_codec_context, m_output_video_codec, nullptr);&#xA;    if (err &lt; 0) {&#xA;        printf("Failed to open codec.\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    if (!(m_output_format->flags &amp; AVFMT_NOFILE)) {&#xA;        err = avio_open(&amp;m_output_format_context->pb, video_file_name.c_str(), AVIO_FLAG_WRITE);&#xA;        if (err &lt; 0) {&#xA;            printf("Failed to open output file.");&#xA;            return false;&#xA;        }&#xA;    }&#xA;&#xA;    err = avformat_write_header(m_output_format_context, NULL);&#xA;    if (err &lt; 0) {&#xA;        printf("Failed to write header.\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    av_dump_format(m_output_format_context, 0, video_file_name.c_str(), 1);&#xA;&#xA;    return true;&#xA;}&#xA;&#xA;&#xA;//TODO(P2): make this a member. (Thanks to https://emvlo.wordpress.com/2016/03/10/sws_scale/)&#xA;void PrepareFlipFrameJ420(AVFrame* pFrame) {&#xA;    for (int i = 0; i &lt; 4; i&#x2B;&#x2B;) {&#xA;        if (i)&#xA;            pFrame->data[i] &#x2B;= pFrame->linesize[i] * ((pFrame->height >> 1) - 1);&#xA;        else&#xA;            pFrame->data[i] &#x2B;= pFrame->linesize[i] * (pFrame->height - 1);&#xA;        pFrame->linesize[i] = -pFrame->linesize[i];&#xA;    }&#xA;}&#xA;

    &#xA;

    This is where we take an altered frame and write it to the output container. This works fine&#xA;as long as we haven't set up an audio stream in the output container.

    &#xA;

    bool MediaContainerMgr::output_video_frame(uint8_t* buf) {&#xA;    int err;&#xA;&#xA;    if (!m_output_video_frame) {&#xA;        m_output_video_frame = av_frame_alloc();&#xA;        m_output_video_frame->format = AV_PIX_FMT_YUV420P;&#xA;        m_output_video_frame->width = m_output_video_codec_context->width;&#xA;        m_output_video_frame->height = m_output_video_codec_context->height;&#xA;        err = av_frame_get_buffer(m_output_video_frame, 32);&#xA;        if (err &lt; 0) {&#xA;            printf("Failed to allocate output frame.\n");&#xA;            return false;&#xA;        }&#xA;    }&#xA;&#xA;    if (!m_output_scale_context) {&#xA;        m_output_scale_context = sws_getContext(m_output_video_codec_context->width, m_output_video_codec_context->height, &#xA;                                                AV_PIX_FMT_RGB24,&#xA;                                                m_output_video_codec_context->width, m_output_video_codec_context->height, &#xA;                                                AV_PIX_FMT_YUV420P, SWS_BICUBIC, nullptr, nullptr, nullptr);&#xA;    }&#xA;&#xA;    int inLinesize[1] = { 3 * m_output_video_codec_context->width };&#xA;    sws_scale(m_output_scale_context, (const uint8_t* const*)&amp;buf, inLinesize, 0, m_output_video_codec_context->height,&#xA;              m_output_video_frame->data, m_output_video_frame->linesize);&#xA;    PrepareFlipFrameJ420(m_output_video_frame);&#xA;    //TODO(P0): Switch m_frame to be m_input_video_frame so I don&#x27;t end up using the presentation timestamp from&#xA;    //          an audio frame if I threadify the frame reading.&#xA;    m_output_video_frame->pts = m_frame->pts;&#xA;    printf("Output PTS: %d, time_base: %d/%d\n", m_output_video_frame->pts,&#xA;        m_output_video_codec_context->time_base.num, m_output_video_codec_context->time_base.den);&#xA;    err = avcodec_send_frame(m_output_video_codec_context, m_output_video_frame);&#xA;    if (err &lt; 0) {&#xA;        printf("  ERROR sending new video frame output: ");&#xA;        switch (err) {&#xA;        case AVERROR(EAGAIN):&#xA;            printf("AVERROR(EAGAIN): %d\n", err);&#xA;            break;&#xA;        case AVERROR_EOF:&#xA;            printf("AVERROR_EOF: %d\n", err);&#xA;            break;&#xA;        case AVERROR(EINVAL):&#xA;            printf("AVERROR(EINVAL): %d\n", err);&#xA;            break;&#xA;        case AVERROR(ENOMEM):&#xA;            printf("AVERROR(ENOMEM): %d\n", err);&#xA;            break;&#xA;        }&#xA;&#xA;        return false;&#xA;    }&#xA;&#xA;    AVPacket pkt;&#xA;    av_init_packet(&amp;pkt);&#xA;    pkt.data = nullptr;&#xA;    pkt.size = 0;&#xA;    pkt.flags |= AV_PKT_FLAG_KEY;&#xA;    int ret = 0;&#xA;    if ((ret = avcodec_receive_packet(m_output_video_codec_context, &amp;pkt)) == 0) {&#xA;        static int counter = 0;&#xA;        printf("pkt.key: 0x%08x, pkt.size: %d, counter:\n", pkt.flags &amp; AV_PKT_FLAG_KEY, pkt.size, counter&#x2B;&#x2B;);&#xA;        uint8_t* size = ((uint8_t*)pkt.data);&#xA;        printf("sizes: %d %d %d %d %d %d %d %d %d\n", size[0], size[1], size[2], size[2], size[3], size[4], size[5], size[6], size[7]);&#xA;        av_interleaved_write_frame(m_output_format_context, &amp;pkt);&#xA;    }&#xA;    printf("push: %d\n", ret);&#xA;    av_packet_unref(&amp;pkt);&#xA;&#xA;    return true;&#xA;}&#xA;&#xA;bool MediaContainerMgr::finalize_output() {&#xA;    if (!m_recording)&#xA;        return true;&#xA;&#xA;    AVPacket pkt;&#xA;    av_init_packet(&amp;pkt);&#xA;    pkt.data = nullptr;&#xA;    pkt.size = 0;&#xA;&#xA;    for (;;) {&#xA;        avcodec_send_frame(m_output_video_codec_context, nullptr);&#xA;        if (avcodec_receive_packet(m_output_video_codec_context, &amp;pkt) == 0) {&#xA;            av_interleaved_write_frame(m_output_format_context, &amp;pkt);&#xA;            printf("final push:\n");&#xA;        } else {&#xA;            break;&#xA;        }&#xA;    }&#xA;&#xA;    av_packet_unref(&amp;pkt);&#xA;&#xA;    av_write_trailer(m_output_format_context);&#xA;    if (!(m_output_format->flags &amp; AVFMT_NOFILE)) {&#xA;        int err = avio_close(m_output_format_context->pb);&#xA;        if (err &lt; 0) {&#xA;            printf("Failed to close file. err: %d\n", err);&#xA;            return false;&#xA;        }&#xA;    }&#xA;&#xA;    return true;&#xA;}&#xA;

    &#xA;

    EDIT&#xA;The call stack on the crash (which I should have included in the original question) :

    &#xA;

    avformat-58.dll!compute_muxer_pkt_fields(AVFormatContext * s, AVStream * st, AVPacket * pkt) Line 630   C&#xA;avformat-58.dll!write_packet_common(AVFormatContext * s, AVStream * st, AVPacket * pkt, int interleaved) Line 1122  C&#xA;avformat-58.dll!write_packets_common(AVFormatContext * s, AVPacket * pkt, int interleaved) Line 1186    C&#xA;avformat-58.dll!av_interleaved_write_frame(AVFormatContext * s, AVPacket * pkt) Line 1241   C&#xA;CamBot.exe!MediaContainerMgr::output_video_frame(unsigned char * buf) Line 553  C&#x2B;&#x2B;&#xA;CamBot.exe!main() Line 240  C&#x2B;&#x2B;&#xA;

    &#xA;

    If I move the call to avformat_write_header so it's immediately before the audio stream initialization, I still get a crash, but in a different place. The crash happens on line 6459 of movenc.c, where we have :

    &#xA;

    /* Non-seekable output is ok if using fragmentation. If ism_lookahead&#xA; * is enabled, we don&#x27;t support non-seekable output at all. */&#xA;if (!(s->pb->seekable &amp; AVIO_SEEKABLE_NORMAL) &amp;&amp;  //  CRASH IS HERE&#xA;    (!(mov->flags &amp; FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) {&#xA;    av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n");&#xA;    return AVERROR(EINVAL);&#xA;}&#xA;

    &#xA;

    The exception is a nullptr exception, where s->pb is NULL. The call stack is :

    &#xA;

    avformat-58.dll!mov_init(AVFormatContext * s) Line 6459 C&#xA;avformat-58.dll!init_muxer(AVFormatContext * s, AVDictionary * * options) Line 407  C&#xA;[Inline Frame] avformat-58.dll!avformat_init_output(AVFormatContext *) Line 489 C&#xA;avformat-58.dll!avformat_write_header(AVFormatContext * s, AVDictionary * * options) Line 512   C&#xA;CamBot.exe!MediaContainerMgr::init_video_output(const std::string &amp; video_file_name, unsigned int width, unsigned int height) Line 424  C&#x2B;&#x2B;&#xA;CamBot.exe!main() Line 183  C&#x2B;&#x2B;&#xA;

    &#xA;