ソースを参照

fixing averror

Nicolas Winkler 5 年 前
コミット
e217cccca2
1 ファイル変更3 行追加8 行削除
  1. 3 8
      libalmond/src/VideoStream.cpp

+ 3 - 8
libalmond/src/VideoStream.cpp

@@ -86,18 +86,10 @@ VideoStream::VideoStream(int width, int height, const std::string& filename, int
     if (avformat_write_header(formatContext, nullptr) < 0) {
         throw VideoExportException{ "error writing header" };
     }
-    /*file = fopen(filename.c_str(), "wb");
-    if (!file) {
-        fprintf(stderr, "could not open %s\n", filename.c_str());
-        exit(1);
-    }*/
 
     picture = av_frame_alloc();
     if (!picture)
         throw VideoExportException{ "error allocating frame" };
-    if (av_frame_make_writable(picture) < 0) {
-        throw VideoExportException{ "error making frame writeable" };
-    }
     picture->format = codecContext->pix_fmt;
     picture->width  = codecContext->width;
     picture->height = codecContext->height;
@@ -106,6 +98,9 @@ VideoStream::VideoStream(int width, int height, const std::string& filename, int
     if (retval < 0) {
         throw VideoExportException{ "could not allocate frame data" };
     }
+    if (av_frame_make_writable(picture) < 0) {
+        throw VideoExportException{ "error making frame writeable" };
+    }
     //av_image_alloc(picture->data, picture->linesize, width, height, codecContext->pix_fmt, 32);
 
     swsContext = sws_getContext(width, height,