Skip to content

VideoWriter from file results in 0 bytes file #388

@letisoft

Description

@letisoft

VideoWriter.fromFile seems not working?

following code:
` Future processVideo(String filePath,String destFolder) async{
cv.VideoCapture cap = cv.VideoCapture.fromFile(filePath);
double width = cap.get(cv.CAP_PROP_FRAME_WIDTH);
double height = cap.get(cv.CAP_PROP_FRAME_HEIGHT);
double fps = cap.get(cv.CAP_PROP_FPS);

String newFilePath = PathUtils.join(destFolder,"processed_${PathUtils.basename(filePath)}");
File f = File(newFilePath);

if(!f.existsSync()){
  f.createSync(recursive: true);
}

cv.VideoWriter writer = cv.VideoWriter.fromFile(newFilePath,"MP4V", fps, (width.toInt(),height.toInt()));

while(cap.isOpened){
  var (success, frame) = cap.read();
  if(!success){
    break;
  }

  if(frame.isEmpty){
    print("empty frame");
  }
  else {
    await writer.writeAsync(frame);
  }
}

writer.release();

if(f.existsSync()){
  int len = await f.length();
  print(len);
}

return newFilePath;

}
`
file should not be empty, I have checked that await writer.writeAsync(frame); is called and frames are not empty

Android 14

Any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions