WyattBlue / auto-editor

Auto-Editor: Efficient media analysis and rendering
https://auto-editor.com
The Unlicense
2.82k stars 413 forks source link

struct.error: unpack requires a buffer of 4 bytes #351

Closed Aelerity closed 1 year ago

Aelerity commented 1 year ago

Bug description

Video editing doesn't complete, gives error

Traceback (most recent call last):                                                            |  1.8%  ETA 11:13 PM
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\talkp\AppData\Local\Programs\Python\Python311\Scripts\auto-editor.exe\__main__.py", line 7, in <module>  File "C:\Users\talkp\AppData\Local\Programs\Python\Python311\Lib\site-packages\auto_editor\__main__.py", line 347, in main
    edit_media(paths, ffmpeg, args, temp, log)
  File "C:\Users\talkp\AppData\Local\Programs\Python\Python311\Lib\site-packages\auto_editor\edit.py", line 378, in edit_media
    make_media(tl, output)
  File "C:\Users\talkp\AppData\Local\Programs\Python\Python311\Lib\site-packages\auto_editor\edit.py", line 309, in make_media
    audio_output = make_new_audio(tl, ensure, args, ffmpeg, bar, temp, log)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\talkp\AppData\Local\Programs\Python\Python311\Lib\site-packages\auto_editor\render\audio.py", line 258, in make_new_audio
    clip_arr = read(f"{af_out}")[1]
               ^^^^^^^^^^^^^^^^^
  File "C:\Users\talkp\AppData\Local\Programs\Python\Python311\Lib\site-packages\auto_editor\wavfile.py", line 222, in read
    _skip_unknown_chunk(fid, en)
  File "C:\Users\talkp\AppData\Local\Programs\Python\Python311\Lib\site-packages\auto_editor\wavfile.py", line 125, in _skip_unknown_chunk
    size = struct.unpack(f"{en}I", data)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: unpack requires a buffer of 4 bytes

What's your platform?

Python Version: 3.11.2 64-bit
Platform: Windows 10 amd64
FFmpeg Version: N-105325-g7512293cf9
FFmpeg Path: C:\Users\talkp\AppData\Local\Programs\Python\Python311\Lib\site-packages\ae_ffmpeg\Windows\ffmpeg.exe
Auto-Editor Version: 23w20b

What command did you use

auto-editor C:\Users\talkp\OneDrive\Documents\auto_editor_vids\alien.mp4 -v 2.5

Input Properties

Input video properties
 - video:
   - track 0:
     - codec: h264
     - fps: 60
     - resolution: 1280x720
     - aspect ratio: 16:9
     - pixel aspect ratio: 1:1
     - duration: 788.783333
     - pix fmt: yuv420p
     - color range: tv
     - color space: bt709
     - color primaries: bt709
     - color transfer: bt709
     - timebase: 1/90000
     - bitrate: 527506
     - lang: und
 - audio:
   - track 0:
     - codec: aac
     - samplerate: 44100
     - channels: 2
     - duration: 788.851519
     - bitrate: 127999
     - lang: und
 - container:
   - duration: 788.852000
   - bitrate: 667692
It also doesn't work on this other video.
- video:
   - track 0:
     - codec: h264
     - fps: 30000/1001
     - resolution: 1280x720
     - aspect ratio: 16:9
     - pixel aspect ratio: 1:1
     - duration: 2657.988667
     - pix fmt: yuv420p
     - color range: tv
     - color space: bt709
     - color primaries: bt709
     - color transfer: bt709
     - timebase: 1/90000
     - bitrate: 73172
     - lang: und
 - audio:
   - track 0:
     - codec: aac
     - samplerate: 44100
     - channels: 2
     - duration: 2658.034649
     - bitrate: 127999
     - lang: und
 - container:
   - duration: 2658.035000
   - bitrate: 209218
Aelerity commented 1 year ago
It works on other videos, such as this one for instance:
- video:
   - track 0:
     - codec: h264
     - fps: 30000/1001
     - resolution: 1280x720
     - aspect ratio: 16:9
     - pixel aspect ratio: 1:1
     - duration: 1064.096367
     - pix fmt: yuv420p
     - color range: tv
     - color space: bt709
     - color primaries: bt709
     - color transfer: bt709
     - timebase: 1/90000
     - bitrate: 761575
     - lang: und
 - audio:
   - track 0:
     - codec: aac
     - samplerate: 44100
     - channels: 2
     - duration: 1064.147302
     - bitrate: 128003
     - lang: und
 - container:
   - duration: 1064.148000
   - bitrate: 897972
 
WyattBlue commented 1 year ago

Hi, I would like for you to send a file to me. First run:

auto-editor your-vid.mp4 --temp-dir temp

then when it fails, send the temp/0-0.wav file.

Aelerity commented 1 year ago

It did not fail/get the error when I did that and just returned the expected output video.

I tried a few other tests.

auto-editor C:\Users\talkp\OneDrive\Documents\auto_editor_vids\sup.mp4 <- dont get the error auto-editor C:\Users\talkp\OneDrive\Documents\auto_editor_vids\sup.mp4 -v 2.5 <- get the error auto-editor C:\Users\talkp\OneDrive\Documents\auto_editor_vids\sup.mp4 --temp-dir temp <- dont get the error and also for some reason? auto-editor C:\Users\talkp\OneDrive\Documents\auto_editor_vids\sup.mp4 -v 2 <- dont get the error

Aelerity commented 1 year ago

I have 7 different vids in my auto_editor_vids folder and I ran the command in powershell

$files = "C:\Users\talkp\OneDrive\Documents\auto_editorvids" $filteredFiles = Get-ChildItem $files -Filter *.mp4 | Where-Object { $.Name -notlike "*_ALTERED.mp4" } foreach ($f in $filteredFiles) { auto-editor $(Join-Path -Path $files -ChildPath $f) -v 2.5 --no-open } 4/7 of the vids were successfully altered without error

$files = "C:\Users\talkp\OneDrive\Documents\auto_editorvids" $filteredFiles = Get-ChildItem $files -Filter *.mp4 | Where-Object { $.Name -notlike "*_ALTERED.mp4" } foreach ($f in $filteredFiles) { auto-editor $(Join-Path -Path $files -ChildPath $f) -v 2 --no-open } 5/7 of the vids were successfully altered without error

$files = "C:\Users\talkp\OneDrive\Documents\auto_editorvids" $filteredFiles = Get-ChildItem $files -Filter *.mp4 | Where-Object { $.Name -notlike "*_ALTERED.mp4" } foreach ($f in $filteredFiles) { auto-editor $(Join-Path -Path $files -ChildPath $f) --no-open } 7/7 of the vids were successfully altered without error

$files = "C:\Users\talkp\OneDrive\Documents\auto_editorvids" $filteredFiles = Get-ChildItem $files -Filter *.mp4 | Where-Object { $.Name -notlike "*_ALTERED.mp4" } foreach ($f in $filteredFiles) { auto-editor $(Join-Path -Path $files -ChildPath $f) -v 2.5 } 4/7 of the vids were successfully altered without error

$files = "C:\Users\talkp\OneDrive\Documents\auto_editorvids" $filteredFiles = Get-ChildItem $files -Filter *.mp4 | Where-Object { $.Name -notlike "*_ALTERED.mp4" } foreach ($f in $filteredFiles) { auto-editor $(Join-Path -Path $files -ChildPath $f) -v 2 } 5/7 of the vids were successfully altered without error

WyattBlue commented 1 year ago

I confirmed that this happens on Windows (but not MacOS) with:

auto-editor example.mp4 -s 2

Thank you @Aelerity for making a bug report. No further action is needed.

WyattBlue commented 1 year ago

Fixed in 23w21a