Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program attempts to load frame that does not exist. #9

Open
WinterEx19 opened this issue Mar 16, 2023 · 10 comments
Open

Program attempts to load frame that does not exist. #9

WinterEx19 opened this issue Mar 16, 2023 · 10 comments

Comments

@WinterEx19
Copy link

This is my console output:
Separating video frames
copying audio
Error while decoding stream #0:0: Invalid data found when processing input
reading audio
analyzing audio
finding best matches
creating output audio
building output video
Traceback (most recent call last):
File "/Users/myname/Desktop/folder/stammer/stammer.py", line 254, in
main()
File "/Users/myname/Desktop/folder/stammer/stammer.py", line 247, in main
process(carrier_path, modulator_path, output_path)
File "/Users/myname/Desktop/folder/stammer/stammer.py", line 225, in process
build_output_video(frames_dir, outframes_dir, best_matches, 1/frame_length, output_path)
File "/Users/myname/Desktop/folder/stammer/stammer.py", line 105, in build_output_video
shutil.copy(frames_dir / f'frame{match_num+1:06d}.png', outframes_dir / f'frame{i:06d}.png')
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 419, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 256, in copyfile
with open(src, 'rb') as fsrc:
^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'temp/frames/frame017558.png'

It never creates the file frame017558.png when creating frames.

@Firepal
Copy link
Collaborator

Firepal commented Mar 18, 2023

copying audio
Error while decoding stream #0:0: Invalid data found when processing input <- This!
reading audio

Interesting. This is likely the culprit:

stammer/stammer.py

Lines 190 to 200 in 6de38a7

subprocess.run(
[
'ffmpeg',
'-loglevel', 'error',
'-i', carrier_path,
'-ac', '1',
'-ar', str(INTERNAL_SAMPLERATE),
TEMP_DIR / 'carrier.wav'
],
check=True
)

I think we need to add -vn -map 0:a:0 so that ffmpeg ignores the video and only picks one audio track.

@Firepal
Copy link
Collaborator

Firepal commented Mar 18, 2023

It is odd that, here, ffmpeg could get video frames, but couldn't get audio

@unaccountedFor
Copy link

I am not experiencing this "Error while decoding stream" but am experiencing this bug, so that's not the culprit. How do I make this thing work? Clearly others are using it and not running into this issue.

@earo16
Copy link

earo16 commented Mar 28, 2023

It's nothing to do with the audio, it's everything to do with how it's naming and calling the frame files

@earo16
Copy link

earo16 commented Mar 28, 2023

it's line 171. At least in the current build at the time of this comment--your post has it as line 105 but it's the same line of code

edit: looks like stammer has been updated, this fix is not applicable to the current ver

        shutil.copy(frames_dir / f'frame{match_num+1:06d}.png', outframes_dir / f'frame{i:06d}.png')

the match_num+1 part makes it look for a frame file one number above the last one created in the directory. Like, if it extracts 100 frames from the input video, it'll try to copy frame 101 into the output, which doesn't exist, so it's aborted

removing the +1 makes it look for frame 0 instead, which also doesn't exist. I fixed this by making it copy frame 1 as frame 0

change lines 169-171 (or wherever it is in your build) to

shutil.copy(frames_dir / f'frame000001.png', frames_dir / f'frame000000.png')     //added this line to copy the frame

if type(best_matches) == list:
    for i, match_num in enumerate(best_matches):
        shutil.copy(frames_dir / f'frame{match_num:06d}.png', outframes_dir / f'frame{i:06d}.png')

it's kind of a patchwork thing, it's like duct tape

@RaTheGod1
Copy link

shutil.copy(frames_dir / f'frame000001.png', frames_dir / f'frame000000.png')     //added this line to copy the frame

if type(best_matches) == list:
    for i, match_num in enumerate(best_matches):
        shutil.copy(frames_dir / f'frame{match_num:06d}.png', outframes_dir / f'frame{i:06d}.png')

Trying to implement this as a quick fix, (as someone who only knows a little python)... If I paste and replace the line quoted above, "Best_matches" isn't defined yet. Also, is the if statement inside the previous if statement? or a separate if statement?

@earo16
Copy link

earo16 commented Mar 31, 2023

it's separate. It looks like this

in the version of stammer I was using. Looks like it's been updated. The fix will not work with the current version

Screenshot_802

@herobrinecat

This comment was marked as outdated.

@Firepal
Copy link
Collaborator

Firepal commented Apr 10, 2023

I have a branch @ #65 (https://github.com/Firepal/stammer/tree/assert_fix_test) which at best attempts to fix the problem, and at worst reports more information when the problem arises.

Please try it, and if you get an error, report back here or in the sister issue #62 with the full STAMMER output. Thanks!

@Firepal
Copy link
Collaborator

Firepal commented Apr 21, 2023

This branch is now merged into main.
As far as I'm concerned, it should be impossible for the latest code to be able to read any bad frames.
@WinterEx19 @ArdenButterfield Thoughts on closing this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants