Output file not found
I am trying to get an individual frame at a specified interval from a live youtube video. Using ffmpeg in a shell following this example saves a png every 5 seconds as intended.
Trying to implement the same using ffmpeg-python (using spyder) yields the following error:
Traceback (most recent call last):
File "C:\Users\User1\Downloads\untitled0.py", line 38, in <module>
get_video_frame(hidden_url,int(time.time()))
File "C:\Users\User1\Downloads\untitled0.py", line 32, in get_video_frame
.output('output%d.png')
File "C:\Users\User1\AppData\Local\Programs\Python\Python310\Lib\site-packages\ffmpeg\_run.py", line 320, in run
overwrite_output=overwrite_output,
File "C:\Users\User1\AppData\Local\Programs\Python\Python310\Lib\site-packages\ffmpeg\_run.py", line 285, in run_async
args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream
File "C:\Users\User1\AppData\Local\Programs\Spyder\pkgs\spyder_kernels\customize\spydercustomize.py", line 108, in __init__
super(SubprocessPopen, self).__init__(*args, **kwargs)
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\subprocess.py", line 800, in __init__
File "D:\obj\windows-release\37amd64_Release\msi_python\zip_amd64\subprocess.py", line 1207, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
To me, it looks like this is pointing to the output file not being found. I tried specifically pointing to a full output file path and also creating a blank png to overwrite to no effect. Is there anything else I can do to get this to work? My alternative is to just call a batch script from python, however I would prefer to use this wrapper and have the inputs be more easily mutable.
My code:
def get_video_frame(hidden_url):
(
ffmpeg
.input(hidden_url)
.filter('fps', 1/5)
.output('output%d.png')
.run()
)
return
hidden_url example: 'https://manifest.googlevideo.com/api/manifest/hls_playlist/expire/1640648731/ei/u_vJYf-VMIKHir4PwL2mkAM/ip/199.247.32.18/id/AdUw5RdyZxI.1/itag/96/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/sgoap/gir%3Dyes%3Bitag%3D140/sgovp/gir%3Dyes%3Bitag%3D137/hls_chunk_host/rr2---sn-vgqskn7l.googlevideo.com/playlist_duration/30/manifest_duration/30/vprv/1/playlist_type/DVR/initcwndbps/14750/mh/6l/mip/71.90.98.158/mm/44/mn/sn-vgqskn7l/ms/lva/mv/m/mvi/2/pl/20/dover/11/keepalive/yes/fexp/24001373,24007246/mt/1640626844/sparams/expire,ei,ip,id,itag,source,requiressl,ratebypass,live,sgoap,sgovp,playlist_duration,manifest_duration,vprv,playlist_type/sig/AOq0QJ8wRgIhAJibW73gflzGQqACTYJLT1iueRvPrZoSxewsg8GwhrIbAiEAsiEOovcoojoSz_FWdZonyPJ3alpVU_AQFI1NRyLJe_Q%3D/lsparams/hls_chunk_host,initcwndbps,mh,mip,mm,mn,ms,mv,mvi,pl/lsig/AG3C_xAwRQIgJvElvs-qXkW7VAgVVO2lD2XxTwK-ouMZmQY12cunfX0CIQCdpTgCfDIEppxDt05OA_TsovAH_9281owe4JilbPAPEw%3D%3D/playlist/index.m3u8'
Solved, moved the ffmpeg.exe directory into the script directory, and that seemingly fixed the issue.