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

ERROR: FFmpeg cannot edit existing files in-place. #22023

Closed
sam-ulrich1 opened this issue Aug 6, 2019 · 5 comments
Closed

ERROR: FFmpeg cannot edit existing files in-place. #22023

sam-ulrich1 opened this issue Aug 6, 2019 · 5 comments
Labels

Comments

@sam-ulrich1
Copy link

@sam-ulrich1 sam-ulrich1 commented Aug 6, 2019

Checklist

  • I'm reporting a broken site support issue
  • I've verified that I'm running youtube-dl version 2019.08.02
  • I've checked that all provided URLs are alive and playable in a browser
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • I've searched the bugtracker for similar bug reports including closed ones
  • I've read bugs section in FAQ

Verbose log

/home/user/.conda/envs/EXAMPLEPROJECT/bin/python /home/user/Development/Projects/EXAMPLEPROJECT/Misc/ManualDownloader.py
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2019.08.02
[debug] Python version 3.6.8 (CPython) - Linux-5.0.0-23-generic-x86_64-with-debian-buster-sid
[debug] exe versions: ffmpeg 4.1.3, ffprobe 4.1.3, phantomjs 2.1.1, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] polXDtvYXLU: Downloading webpage
[youtube] polXDtvYXLU: Downloading video info webpage
[info] Writing video description metadata as JSON to: /home/user/Desktop/EXAMPLEPROJECT/WAPO-CW-Putin-Interview.mp4.info.json
[debug] Invoking downloader on 'https://r3---sn-q4flrnl7.googlevideo.com/videoplayback?expire=1565115390&ei=nm9JXZeyD4WRwQHVopzICQ&ip=38.65.78.4&id=o-AI7H6q_uyplNu2tctTc-vQFAScrgH82Wic6Y1ZsUO5Ko&itag=43&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-q4flrnl7%2Csn-q4f7sn7z&ms=au%2Crdu&mv=u&mvi=2&pl=24&mime=video%2Fwebm&gir=yes&clen=10085385&ratebypass=yes&dur=0.000&lmt=1531800320202159&mt=1565092790&fvip=4&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=ALgxI2wwRQIhAI_3d7r2XFx094FXyroQDbnpVZmTB-BUq36fbAbiuKYwAiAiRV25srhMX_VEpcXsuXWlRdEssORBpfQSsNm78B4cig%3D%3D&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl&lsig=AHylml4wRQIgKPR5Ah8Z5ZGBV6w8PceAuNrL6W2umDRjyWziGjeTB9gCIQCLGebYU3iLDfgIrxUz4_Cf6AAbhgEVQpnNBP0Qpxy1hw%3D%3D'
[download] /home/user/Desktop/EXAMPLEPROJECT/WAPO-CW-Putin-Interview.mp4 has already been downloaded
[download] 100% of 9.62MiB
[ffmpeg] Converting video from webm to mp4, Destination: /home/user/Desktop/EXAMPLEPROJECT/WAPO-CW-Putin-Interview.mp4
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i file:/home/user/Desktop/EXAMPLEPROJECT/WAPO-CW-Putin-Interview.mp4 file:/home/user/Desktop/EXAMPLEPROJECT/WAPO-CW-Putin-Interview.mp4
ERROR: FFmpeg cannot edit existing files in-place.
Traceback (most recent call last):
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 2054, in post_process
    files_to_delete, info = pp.run(info)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 368, in run
    self.run_ffmpeg(path, outpath, options)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 239, in run_ffmpeg
    self.run_ffmpeg_multiple_files([path], out_path, opts)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 235, in run_ffmpeg_multiple_files
    raise FFmpegPostProcessorError(msg)
youtube_dl.postprocessor.ffmpeg.FFmpegPostProcessorError: FFmpeg cannot edit existing files in-place.

Traceback (most recent call last):
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 2054, in post_process
    files_to_delete, info = pp.run(info)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 368, in run
    self.run_ffmpeg(path, outpath, options)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 239, in run_ffmpeg
    self.run_ffmpeg_multiple_files([path], out_path, opts)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 235, in run_ffmpeg_multiple_files
    raise FFmpegPostProcessorError(msg)
youtube_dl.postprocessor.ffmpeg.FFmpegPostProcessorError: FFmpeg cannot edit existing files in-place.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/Development/Projects/EXAMPLEPROJECT/Misc/ManualDownloader.py", line 84, in <module>
    audio=True,
  File "/home/user/Development/Projects/EXAMPLEPROJECT/Misc/ManualDownloader.py", line 60, in get_video
    y.extract_info(url=link, download=download)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 807, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 861, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 1642, in process_video_result
    self.process_info(new_info)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 1989, in process_info
    self.post_process(filename, info_dict)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 2056, in post_process
    self.report_error(e.msg)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 624, in report_error
    self.trouble(error_message, tb)
  File "/home/user/.conda/envs/EXAMPLEPROJECT/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 594, in trouble
    raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: FFmpeg cannot edit existing files in-place.

Description

If the video is downloaded in mp4 format and the desired format is mp4, ffmpeg fails with the error "ERROR: FFmpeg cannot edit existing files in-place." I propose that this error be handled in the youtube-dl source code for the following reasons.

1. If this error occurs then the file is already in the desired format and does not need any work from ffmpeg.
2. If there were other post-processors that were needed they will not be run.
3. The information extracted from the webpage is not returned because the program exits with an exception.

I am happy to handle the error and send a pull request. I wanted to open a dialogue first to be sure that this was something that would get merged if I proposed it.

@dstftw dstftw closed this Aug 6, 2019
@dstftw dstftw added the incomplete label Aug 6, 2019
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Aug 6, 2019

Post complete source code of your script.

@sam-ulrich1
Copy link
Author

@sam-ulrich1 sam-ulrich1 commented Aug 6, 2019

@dstftw Please reopen

class VideoExtraction:
    def __init__(self, high_quality=False, post_processors=None, fragment_retries=5,
                 verbose=False):
        if post_processors is None:
            post_processors = [{"key": "FFmpegVideoConvertor", "preferedformat": "mp4"}]
        if high_quality is True:
            format = "bestvideo+bestaudio/best"
        else:
            format = "worst"
        self.ydl_opts = {
            "format": format,
            "postprocessors": post_processors,
            "keepvideo": True,
            "fragment_retries": fragment_retries,
            "nocheckcertificate": True,
            "verbose": verbose
        }

    def get_video(self, link, download_archive, out_name, download=True, audio=False):
        self.ydl_opts["outtmpl"] = os.path.join(download_archive, out_name)
        opts = self.ydl_opts
        opts["forcejson"] = True
        opts["writeinfojson"] = True
        if audio is True:
            opts['postprocessors'].append({
                'key': 'FFmpegExtractAudio',
                'preferredcodec': 'wav',
            })
        with ydl.YoutubeDL(opts) as y:
            y.extract_info(url=link, download=download)


downloader = VideoExtraction(high_quality=False, verbose=True)
downloader.get_video(
    link="https://www.youtube.com/watch?v=polXDtvYXLU",
    download_archive="/home/user/Desktop/EXAMPLEPROJECT",
    out_name="WAPO-CW-Putin-Interview.mp4",
    download=True,
    audio=True,
)
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Aug 6, 2019

Do not hardcode extension in outtmpl.

@dstftw dstftw added invalid and removed incomplete labels Aug 6, 2019
@sam-ulrich1
Copy link
Author

@sam-ulrich1 sam-ulrich1 commented Aug 6, 2019

@dstftw What would an alternative look like? This is what I found a long time ago on StackOverflow.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Aug 6, 2019

Read FAQ on output template.

@ytdl-org ytdl-org locked and limited conversation to collaborators Aug 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.