title: Adding metadata informations with ffmpeg
body: <p>I am trying to read and most important to write metadata into file using ffmpeg. But I am getting sigseg.</p>
  
  <pre><code>int main(int argc, char **argv) {
  
      av_register_all();
  
      AVFormatContext* ctx;
      std::string path("/home/stefan/test_track.mp3");
  
      ctx = avformat_alloc_context();
  
      if (avformat_open_input(&amp;ctx, path.c_str(), 0, 0) &lt; 0)
          std::cout &lt;&lt; "error1" &lt;&lt; std::endl;
  
      if (avformat_find_stream_info(ctx, 0) &lt; 0)
          std::cout &lt;&lt; "error2" &lt;&lt; std::endl;
  
      AVDictionaryEntry *tag = nullptr;
      tag = av_dict_get(ctx-&gt;metadata, "artist", tag, AV_DICT_IGNORE_SUFFIX);
      std::cout &lt;&lt; tag-&gt;key &lt;&lt; " : " &lt;&lt; tag-&gt;value &lt;&lt; std::endl;
  
      av_dict_set(&amp;ctx-&gt;metadata, "TPFL", "testtest", 0);
  
      std::cout &lt;&lt; "test!" &lt;&lt; std::endl;
      int status = avformat_write_header(ctx, &amp;ctx-&gt;metadata);
  
      if(status == 0)
          std::cout &lt;&lt; "test1" &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>I also tried to make a entire copy of AVDictionary and than saving it with new addition of field I want to save. But still sigseg.</p>
  
  <p>What am I missing? </p>