Sometimes the recorded video is corrupted
Unity:2021.3.29
- AVPro Movie Capture version: AVPro Movie Capture Ultra Edition 5.0.4
- Operating system version: Windows10
- Capture component used: Capture from screen
- Capture settings (resolution, frame-rate, codec):
- resolution:1920*1080
- frame-rate:30
- codec:H264(I haven't changed the default settings, should this be it?) -Average and Max Bitrate:I set it to zero I'm using AVPro to record video, under realtime, and this error occurs both in the editor and in the packaged program, sometimes I can record normally, and sometimes the recorded video is corrupt. Trying to close the program/trying to exit PlayMode when a corrupt video is recorded causes the program/Unity editor to get stuck. I've tried waiting a long time after the video recording ends without doing anything in case it interrupts its work of writing files or something, but the exported video is still corrupt. The "CompletedFileWritingAction" doesn't seem to be called when the video is corrupt (or so it seems). I have sent a copy of the corrupted video to your email address. I've been struggling with this problem for a long time now, and I appreciate you taking the time to read my question! I look forward to your answer. (This is a mechanical translation because I'm a Chinese speaker)
- Are you able to update to the latest version of AVPro Movie Capture please and retest?
- Are you able to reproduce this in a fresh project running just the AVPro Movie Capture demo scenes?
- Are you having the same issue on another computer?
1.Okay, I'll try to update it 2.The Demo scenario didn't have a similar problem in my testing, but I think I'm doing the same thing I should be doing in the Demo scenario, and here's my code:
using RenderHeads.Media.AVProMovieCapture; using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ScreenCapture : MonoSingleton<ScreenCapture> { public CaptureFromScreen _capture; private List<FileWritingHandler> _fileWritingHandlers = new List<FileWritingHandler>(4); string exportPath;
private IEnumerator Start()
{
if (_capture != null)
{
_capture.BeginFinalFileWritingAction += OnBeginFinalFileWriting;
_capture.CompletedFileWritingAction += OnCompleteFinalFileWriting;
}
yield return null;
}
private void OnBeginFinalFileWriting(FileWritingHandler handler)
{
_fileWritingHandlers.Add(handler);
}
private void OnCompleteFinalFileWriting(FileWritingHandler handler)
{
DialoguePanel.Show("导出完毕!", $"视频已经保存到{exportPath}!", null, null, "OK!", null);
}
private void Update()
{
if (FileWritingHandler.Cleanup(_fileWritingHandlers))
{
if (_fileWritingHandlers.Count == 0)
{
Debug.Log("All pending file writes completed");
}
}
}
void OnDestroy()
{
foreach (FileWritingHandler handler in _fileWritingHandlers)
{
handler.Dispose();
}
}
public void SetOutputPath(string path) { exportPath = path; _capture.OutputFolderPath = FileUtility.GetFileFolder(path); _capture.FilenamePrefix = FileUtility.GetRealFileName(path); _capture.FilenameExtension = FileUtility.GetExtension(path, false); }
public void StartRecord() { _capture.StartCapture(); }
public void StopRecord(bool save = true) { if (save) { //完成录制了! _capture.StopCapture(true, false, !save); } else { _capture.CancelCapture(); } } }
3.Yes, I have about 5,000 users of my software and many of them have fed back the same problem
------------------ 原始邮件 ------------------ 发件人: "RenderHeads/UnityPlugin-AVProMovieCapture" @.>; 发送时间: 2023年9月15日(星期五) 下午4:47 @.>; @.@.>; 主题: Re: [RenderHeads/UnityPlugin-AVProMovieCapture] Sometimes the recorded video is corrupted (Issue #325)
Are you able to update to the latest version of AVPro Movie Capture please and retest?
Are you able to reproduce this in a fresh project running just the AVPro Movie Capture demo scenes?
Are you having the same issue on another computer?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
Hi, regarding the first question, I just updated to 1.5.8 and then still have the same problem, I answered the other questions in my last email, waiting for your reply, thank you very much for your time.
I have the same issue. There is a random chance that my video file will be corrupt. Probably about 10% of the time. I tried a video repair software solution called Wondershare and it made the video playable, so I don't think that the data is fundamentally bad. Using wondershare is not workable for a client using my system though.
- Could you perhaps supply a bit more information as to what is happening when the files are corrupted.
- Can you reproduce this in the demo scene?
- Windows version?
- AVPro version?
- Unity version?
- Details of capture
1/2.It doesn't break in the demo scene, also if I press the StopCapture button in the inspector, it doesn't break, but it breaks when I end it using my own written code. (The code is attached above) 3.I've tried both win10 and win11 and both get corrupted. 4.I update often, but I get this problem from very old versions to the latest version. 5.This problem occurs with both 2021 and 2022 (I'm currently using 2022.3.13f1, which is the latest LTS version) 6.I've emailed corrupted files before, I'm not quite sure what other information you specifically need, but I can provide it all. p.s I think I might be doing something wrong, after all, the Demo scene and the UI manipulation through Inspector are not corrupted, but at the same time I think I'm doing exactly the same thing as they are doing (you can see the code I gave before) thanks very much!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi,
We think we've identified the issue and it's linked to passing the first parameter of 'StopCapture()' as 'true' when it should be 'false'.
We're looking into a more permanent solution but the above workaround should help and will close this ticket in favour of posting updated in the more recent https://github.com/RenderHeads/UnityPlugin-AVProMovieCapture/issues/343.
Cheers,