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

FileNotFound after using FFmpegMerger #26832

Open
JAusm opened this issue Oct 7, 2020 · 2 comments
Open

FileNotFound after using FFmpegMerger #26832

JAusm opened this issue Oct 7, 2020 · 2 comments
Labels

Comments

@JAusm
Copy link

@JAusm JAusm commented Oct 7, 2020

Checklist

  • [ x] I'm asking a question
  • [ x] I've looked through the README and FAQ for similar questions
  • [ x] I've searched the bugtracker for similar questions including closed ones

Question

I'm using youtube-dl for a python script to download video and audio, then merge them as a post process. The issue I'm encountering is a FileNotFoundError that occurs after a successful merge. Can someone help me troubleshoot the issue? It appears to merge the files as expected, then delete the two files that were merged, then attempt a merge on a file that was deleted.

Here's the full output of the error:

[Reddit] llp4n1j69ir51: Downloading MPD manifest
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 24
[download] Destination: llp4n1j69ir51-llp4n1j69ir51.fhls-438.mp4
[download] 100% of 4.34MiB in 00:03
[download] Destination: llp4n1j69ir51-llp4n1j69ir51.fdash-audio_0_131726.m4a
[download] 100% of 2.41MiB in 00:00
[ffmpeg] Merging formats into "llp4n1j69ir51-llp4n1j69ir51.mp4"
Deleting original file llp4n1j69ir51-llp4n1j69ir51.fhls-438.mp4 (pass -k to keep)
Deleting original file llp4n1j69ir51-llp4n1j69ir51.fdash-audio_0_131726.m4a (pass -k to keep)
[ffmpeg] Merging formats into "llp4n1j69ir51-llp4n1j69ir51.mp4"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/code/download_videos/download_videos.py", line 60, in download_with_youtube_dl
    ydl.download([video[0]])
  File "/usr/local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 2018, in download
    res = self.extract_info(
  File "/usr/local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 808, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 863, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/usr/local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 1644, in process_video_result
    self.process_info(new_info)
  File "/usr/local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 2000, in process_info
    self.post_process(filename, info_dict)
  File "/usr/local/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 2065, in post_process
    files_to_delete, info = pp.run(info)
  File "/usr/local/lib/python3.8/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 523, in run
    self.run_ffmpeg_multiple_files(info['__files_to_merge'], temp_filename, args)
  File "/usr/local/lib/python3.8/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 209, in run_ffmpeg_multiple_files
    oldest_mtime = min(
  File "/usr/local/lib/python3.8/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 210, in <genexpr>
    os.stat(encodeFilename(path)).st_mtime for path in input_paths)
FileNotFoundError: [Errno 2] No such file or directory: 'llp4n1j69ir51-llp4n1j69ir51.fhls-438.mp4'

For reference, this is my code:

    def download_with_youtube_dl(self, video_data: list):

        os.chdir(self.video_directory)

        yt_dl_opts = {
            'format': 'bestvideo+bestaudio',
            'postprocessors': [{
                'key': 'FFmpegMerger',
            }]
        }

        for video in video_data:
            with YoutubeDL(yt_dl_opts) as ydl:
                ydl.download([video[0]])
@JAusm JAusm added the question label Oct 7, 2020
@Fetchinator7
Copy link

@Fetchinator7 Fetchinator7 commented Oct 11, 2020

On the 9th line it says it's deleting that file before the merge. Do you need the -k flag?

@JAusm
Copy link
Author

@JAusm JAusm commented Oct 11, 2020

On the 9th line it says it's deleting that file before the merge. Do you need the -k flag?

I'll walk through the log to answer question. Youtube-dl pulls the audio and video as two separate files. That happens here:

[download] Destination: llp4n1j69ir51-llp4n1j69ir51.fhls-438.mp4
[download] 100% of 4.34MiB in 00:03
[download] Destination: llp4n1j69ir51-llp4n1j69ir51.fdash-audio_0_131726.m4a
[download] 100% of 2.41MiB in 00:00

Then the files are merged into a new file. That happens here:

[ffmpeg] Merging formats into "llp4n1j69ir51-llp4n1j69ir51.mp4"

Then the files that were used for the merge are deleted. That happens here:

Deleting original file llp4n1j69ir51-llp4n1j69ir51.fhls-438.mp4 (pass -k to keep)
Deleting original file llp4n1j69ir51-llp4n1j69ir51.fdash-audio_0_131726.m4a (pass -k to keep)

Then it tries to merge again, but the files that were deleted. That happens here:

[ffmpeg] Merging formats into "llp4n1j69ir51-llp4n1j69ir51.mp4"

The question is: why does it try to merge again when the merge already occurred before deleting the original two files? I shouldn't have to keep the original two files around because the merge already happened. In testing, the merged video I get has the video and sound that I expect, so I'm not sure why a second merge needs to take place? It feels like a bug.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.