Error log:
2021-03-10 07:44:11,114: /home/vishnuji/blog/youtube/views.py:48: DeprecationWarning: Call to deprecated function all (This object can be treated as a list, all() is useless).
2021-03-10 07:44:11,115: stream_all= yt.streams.all()
2021-03-10 07:44:52,483: /home/vishnuji/blog/youtube/views.py:48: DeprecationWarning: Call to deprecated function all (This object can be treated as a list, all() is useless).
2021-03-10 07:44:52,483: stream_all= yt.streams.all()
2021-03-10 07:45:00,251: None
2021-03-10 07:45:00,252: b»ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developersn built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609n configuration: —prefix=/usr —extra-version=0ubuntu0.16.04.1 —build-suffix=-ffmpeg —toolchain=hardened —libdir=/usr/lib/x86_64-linux-gnu —incdir=/usr/include/x86_64-linux-gnu —cc=cc —cxx=g++ —enable-gpl —enable-shared —disable-stripping —disable-decoder=libopenjpeg —disable-decoder=libschroedinger —enable-avresample —enable-avisynth —enable-gnutls —enable-ladspa —enable-libass —enable-libbluray —enable-libbs2b —enable-libcaca —enable-libcdio —enable-libflite —enable-libfontconfig —enable-libfreetype —enable-libfribidi —enable-libgme —enable-libgsm —enable-libmodplug —enable-libmp3lame —enable-libopenjpeg —enable-libopus —enable-libpulse —enable-librtmp —enable-libschroedinger —enable-libshine —enable-libsnappy —enable-libsoxr —enable-libspeex —enable-libssh —enable-libtheora —enable-libtwolame —enable-libvorbis —enable-libvpx —enable-libwavpack —enable-libwebp —enable-libx265 —enable-libxvid —enable-libzvbi —enable-openal —enable-opengl —enable-x11grab —enable-libdc1394 —enable-libiec61883 —enable-libzmq —enable-frei0r —enable-libx264 —enable-libopencvn libavutil 54. 31.100 / 54. 31.100n libavcodec 56. 60.100 / 56. 60.100n libavformat 56. 40.101 / 56. 40.101n libavdevice 56. 4.100 / 56. 4.100n libavfilter 5. 40.101 / 5. 40.101n libavresample 2. 1. 0 / 2. 1. 0n libswscale 3. 1.101 / 3. 1.101n libswresample 1. 2.101 / 1. 2.101n libpostproc 53. 3.100 / 53. 3.100nInput #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘/home/vishnuji/Downloads/audio.mp4’:n Metadata:n major_brand : dashn minor_version : 0n compatible_brands: iso6mp41n creation_time : 2020-01-28 19:11:09n Duration: 00:04:39.71, start: 0.000000, bitrate: 129 kb/sn Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 4 kb/s (default)n Metadata:n creation_time : 2020-01-28 19:11:09n handler_name : ISO Media file produced by Google Inc.nInput #1, mov,mp4,m4a,3gp,3g2,mj2, from ‘/home/vishnuji/Downloads/video.mp4’:n Metadata:n major_brand : mp42n minor_version : 0n compatible_brands: isommp42n creation_time : 2020-01-28 19:00:25n Duration: 00:04:39.71, start: 0.000000, bitrate: 655 kb/sn Stream #1:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 640×360 [SAR 1:1 DAR 16:9], 556 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)n Metadata:n creation_time : 2020-01-28 19:00:25n handler_name : ISO Media file produced by Google Inc. Created on: 01/28/2020.n Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 95 kb/s (default)n Metadata:n creation_time : 2020-01-28 19:00:25n handler_name : ISO Media file produced by Google Inc. Created on: 01/28/2020.n[aac @ 0x281d840] The encoder ‘aac’ is experimental but experimental codecs are not enabled, add ‘-strict -2’ if you want to use it.n»
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
Dec-04-2022, 05:39 PM
(This post was last modified: Dec-04-2022, 10:31 PM by Larz60+.
Edit Reason: fixed error tags
)
Hello, I have a problem so I hope some programmers can help me solve it.
Basically I run this:
import whisper model = whisper.load_model("base") result = model.transcribe('test.mp3', fp16=False)
And I get this:
Error:
Output exceeds the size limit. Open the full output data in a text editor.
Error Traceback (most recent call last)
File
38 try:
39 # This launches a subprocess to decode audio while down-mixing and resampling as necessary.
40 # Requires the ffmpeg CLI and `ffmpeg-python` package to be installed.
41 out, _ = (
---> 42 ffmpeg.input(file, threads=0)
43 .output("-", format="s16le", acodec="pcm_s16le", ac=1, ar=sr)
44 .run(cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True)
45 )
46 except ffmpeg.Error as e:
File
324 if retcode:
--> 325 raise Error('ffmpeg', out, err)
326 return out, err
Error:
Error: ffmpeg error (see stderr output for detail)
The above exception was the direct cause of the following exception:
Error:
RuntimeError Traceback (most recent call last)
Cell In[25], line 4
1 import whisper
...
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
test.mp3: No such file or directory
For those who are wondering, my goal is just to transcribe an mp3 audio file «test.mp3» into text, via the AI Whisper of OpenAI.
And honestly, I’ve been at it for two days now and I’m not getting anywhere, I’ve opened the files in question, located lines 42 and 325 but I don’t know what to do next.
Thank you in advance for your help and your explanations.
Posts: 6,575
Threads: 116
Joined: Sep 2016
Reputation:
487
Dec-04-2022, 06:44 PM
(This post was last modified: Dec-04-2022, 06:44 PM by snippsat.)
Look at this blog post.
So you most be in folder where test.mp3
is,do this from command line.
The first do whisper test.mp3
then try to run python script in all in same folder.
Posts: 2
Threads: 1
Joined: Dec 2022
Reputation:
0
Hi, first of all, thank you for your help
I followed the instructions in your link to the letter, unfortunately the same error message appeared.
Now I renamed my audio file test.mp3 to «audio.wav» to follow the tutorial.
But I got the same error message whether it was on WindowsPowerShell or VScode.
I think indeed that the heart of the problem is the fact that it can’t find the audio file.
How can I make it find it ?
Posts: 6,575
Threads: 116
Joined: Sep 2016
Reputation:
487
Dec-04-2022, 10:13 PM
(This post was last modified: Dec-04-2022, 10:13 PM by snippsat.)
(Dec-04-2022, 08:21 PM)needhelp Wrote: But I got the same error message whether it was on WindowsPowerShell or VScode.
I think indeed that the heart of the problem is the fact that it can’t find the audio file.
How can I make it find it ?
I have tested this this and it work as expected with a test.mp3 file.
You should be using virtual environment as it install a lot to avoid conflicts.
Example:
# Make G:div_code λ python -m venv whisper_env # Cd in G:div_code λ cd whisper_env # Activate G:div_codewhisper_env λ G:div_codewhisper_envScriptsactivate.bat # Install (whisper_env) G:div_codewhisper_env λ pip install git+https://github.com/openai/whisper.git Collecting ..... Successfully installed certifi-2022.9.24 charset-normalizer-2.1.1 colorama-0.4.6 ffmpeg-python-0.2.0 filelock-3.8.0 future-0.18.2 huggingface-hub-0.11.1 idna-3.4 more-itertools-9.0.0 numpy-1.23.5 packaging-21.3 pyparsing-3.0.9 pyyaml-6.0 regex-2022.10.31 requests-2.28.1 tokenizers-0.13.2 torch-1.13.0 tqdm-4.64.1 transformers-4.25.1 typing-extensions-4.4.0 urllib3-1.26.13 whisper-1.0
Also install update, whisper setup .
(whisper_env) G:div_codewhisper_env λ pip install --upgrade --no-deps --force-reinstall git+https://github.com/openai/whisper.git Collecting ..... Successfully installed whisper-1.0
Now if look in folder,use dir
if ls
not work.
(whisper_env) G:div_codewhisper_env λ ls Connection Lib/ audio.wav audio.wav.txt pyvenv.cfg test.mp3.srt test.mp3.vtt Include/ Scripts/ audio.wav.srt audio.wav.vtt test.mp3 test.mp3.txt ws.py
See that i have ws.py
and test.mp3
is in same folder.
Run first:
(whisper_env) G:div_codewhisper_env λ whisper test.mp3 .....
The run code:
# ws.py import whisper model = whisper.load_model("base") result = model.transcribe("test.mp3") print(result["text"])
Output:
(whisper_env) G:div_codewhisper_env
λ python ws.py
Okay, we are trying this for a second time to test the ability to upload an MP3 file. Hopefully this will work.
Hi guys I have a head ache running this as a service I am really stuck here and have wasted quite the hours here, i am on ubuntu 20 LTS.
I have a celery worker which is waiting for an audio to transform using ffmpeg python library.
If I run it like this:
source venv/bin/activate && Celery -A tasks worker -l info It works without a problem and complete the tasks.
but when I run it as a service in systemd I get this error:
[Errno 20] Not a directory: 'ffmpeg'
Traceback (most recent call last):
File "/home/ubuntu/p1-react-flask-app/app/tasks.py", line 58, in transform_audio_format
output.run()
File "/home/ubuntu/p1-react-flask-app/app/venv/lib/python3.8/site-packages/ffmpeg/_run.py", line 313, in run
process = run_async(
File "/home/ubuntu/p1-react-flask-app/app/venv/lib/python3.8/site-packages/ffmpeg/_run.py", line 284, in run_async
return subprocess.Popen(
File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: 'ffmpeg'
I really do not know why and have tried different ways. python os can access the audio folder and files without problem but the problem here, I think, is that my systemd service does not find ffmpeg.exe, but how do I specify it to my service?
My celery config file:
# The names of the workers. This example create one worker
CELERYD_NODES="worker1"
# The name of the Celery App, should be the same as the python file
# where the Celery tasks are defined
CELERY_APP="tasks"
# Log and PID directories
CELERYD_LOG_FILE="/var/log/celery/%n%I.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"
# Log level
CELERYD_LOG_LEVEL=INFO
# Path to celery binary, that is in your virtual environment
CELERY_BIN=/home/ubuntu/venv/bin/celery
# Options for Celery Beat
CELERYBEAT_PID_FILE="/var/run/celery/beat.pid"
CELERYBEAT_LOG_FILE="/var/log/celery/beat.log"
my celeryd.service:
[Unit]
Description=Celery Service
After=network.target
[Service]
Type=forking
User=ubuntu
Group=ubuntu
EnvironmentFile=/etc/default/celeryd
WorkingDirectory=/home/ubuntu/p1/app
ExecStart=/bin/sh -c '${CELERY_BIN} multi start ${CELERYD_NODES}
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE}
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait ${CELERYD_NODES}
--pidfile=${CELERYD_PID_FILE}'
ExecReload=/bin/sh -c '${CELERY_BIN} multi restart ${CELERYD_NODES}
-A ${CELERY_APP} --pidfile=${CELERYD_PID_FILE}
--logfile=${CELERYD_LOG_FILE} --loglevel=${CELERYD_LOG_LEVEL} ${CELERYD_OPTS}'
[Install]
WantedBy=multi-user.target
My python code:
@app.task
def transform_audio_format(url_original,url_destiny):
input = ffmpeg.input(url_original)
output = ffmpeg.output(input,url_destiny,shell=True)
output.run()
any help would be appreciated.
UPDATE:
I added to my .service file:
Environment=»PATH=/home/ubuntu/p1-react-flask-app/app:/usr/local/bin»
but nothing changed.
then I tried with:
Environment=»PATH=/home/ubuntu/p1-react-flask-app/app:/usr/bin»
and got:
ffmpeg error (see stderr output for detail)
Traceback (most recent call last):
File "/home/ubuntu/p1-react-flask-app/app/tasks.py", line 58, in transform_audio_format
output.run()
File "/home/ubuntu/p1-react-flask-app/app/venv/lib/python3.8/site-packages/ffmpeg/_run.py", line 325, in run
raise Error('ffmpeg', out, err)
ffmpeg._run.Error: ffmpeg error (see stderr output for detail)
I do not know what to do.
out, err = (
ffmpeg.input(in_file)
.filter(‘select’, ‘gte(n,{})’.format(frame_num))
.output(‘pipe:’, vframes=1, format=’image2′, vcodec=’mjpeg’)
.run(capture_stdout=True)
)
can I convert video to multiple images with the method above?
and what is the parameter «vframes=1» mean?
thank u !
When I get this back from ffmpeg ffprobe error (see stderr output for detail)
I do not know how to check the stderr output for the details.
import sys
import ffmpeg
from ffmpeg import Error as FFmpegError
try:
duration = ffmpeg.probe('https://www.youtube.com/watch?v=cv4123_39ddfa324LB23MsYg')['format']['duration']
except FFmpegError as e:
print(e)
# doesn't work
# for line in sys.stderr:
# print(line)
# doesn't work
# data = sys.stderr.readlines()
# print(data)
Couldn’t find an example of this in the documentation and couldn’t figure it out myself.
Dear all,
ffmpeg allows to add chapter metadata as described here. The FFmpeg call requires a specific map option: ‘-map_metadata’:
ffmpeg -i INPUT -i FFMETADATAFILE -map_metadata 1 -codec copy OUTPUT
How can ffmpeg_python be instructed to issue a ‘-map_metadata’?
—Bid
Hi
I’ve installed ffmpeg
+ ffmpeg-python
correctly and the path is ok but I just can’t get any info.
getting this error:
File "/home1/myproj/virtualenv/mainproj/3.9/lib/python3.9/site-packages/ffmpeg/_probe.py", line 23, in probe
raise Error('ffprobe', out, err)
ffmpeg._run.Error: ffprobe error (see stderr output for detail)
done this:
file = "./Vids/tstvid.mp4" var= ffmpeg.probe(file) # + # var = ffmpeg.probe(file)['streams'] print(var)
just to mention, I’m accessing a Linux server using SSH from VScode, I don’t have superuser rights to see version details of ffmpeg
or update it.
📝 P.S: There was another error: [FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe': 'ffprobe'
.
✔ Fixed it.
Howdy!
I am writing some code that using info pulled from a database cuts new clips from sections of longer files, e.g:
from file 1, take the segment between 50 seconds and 150 seconds, plus between 200 seconds and 250 seconds. Make that into a new file.
I managed to get that with ffmpeg via commandline, but I’d like to avoid spawning processes and so I came here However, I do not really understand how to replicate the same using your code.
This is my working ffmpeg command:
ffmpeg -i inputfile.mp4 -vf "select='between(t,575.0,632.0)+between(t,4145.0,4193.0)', setpts=N/FRAME_RATE/TB" -af "aselect='between(t,575.0,632.0)+between(t,4145.0,4193.0)', asetpts=N/SR/TB" outputfile.mp4
Could you please help me obtaining the same?
Thanks!
overlay=x=’if(lt(mod(t,120),60),W-w-W10/100,W10/100)’:y=’if(lt(mod(t+30,120),60),H-h-H5/100,H5/100)’
I found this but how to implement it using ffmpeg-python?
I keep get this error when I want to merge my audio to my video, here is my code:
import ffmpeg
video = ffmpeg.input('D:/Downloads/Wadada.mp4')
audio = ffmpeg.input('d:/Downloads/audio.mp4')
ffmpeg.concat(video, audio, v=1, a=1).output('D:/Downloads/out.mp4').run()
Or
import ffmpeg
video = ffmpeg.input('D:/Downloads/Wadada.mp4')
audio = ffmpeg.input('D:/Downloads/audio.mp4')
out = ffmpeg.output(video, audio, 'D:/Downloads', vcodec='copy', acodec='aac', strict='experimental')
out.run()
Then I got the same error:
---------------------------------------------------------------------------
Error Traceback (most recent call last)
~AppDataLocalTemp/ipykernel_3736/1465659961.py in <module>
5
6 out = ffmpeg.output(video, audio, 'D:/Downloads', vcodec='copy', acodec='aac', strict='experimental')
----> 7 out.run()
D:xxxxxxxanaconda3libsite-packagesffmpeg_run.py in run(stream_spec, cmd, capture_stdout, capture_stderr, input, quiet, overwrite_output)
323 retcode = process.poll()
324 if retcode:
--> 325 raise Error('ffmpeg', out, err)
326 return out, err
327
Error: ffmpeg error (see stderr output for detail)
Where did I go wrong??
hi,dear
I just wonder how to get the key frame with the best project,
any suggestion or advice will be good.
thx,
I want to create multiple stacked streams, from a continuously updated list of image streams.
I have implemented this successfully for a single image stream where one python process reads the image and passes it to ffmpeg through the process StdIn.
My question is there a way to stream more than one to ffmpeg the approaches that come to mind are (but not sure how some of them will be implemented)
- Some how using multiples process input pipes ?
- Passing an image from each stream consecutively in the pipe and ffmpeg puts each one in the correct position
- Stacking the images before hand and passing the stacked image to ffmpeg (This feels inefficient to me)
Ideas are welcome
Hello,
i try to use the function «nullsrc».
No matter which approach I have tried so far, this gives me an error message which has no meaningful value for me.
As an example of the following lines of code: (always tried one by one)
base = ffmpeg.filter(‘nullsrc’, size=’100:200′)
base = ffmpeg.filter(‘nullsrc’, size=’100×200′)
base = ffmpeg.filter(‘nullsrc’, size=100:200)
base = ffmpeg.filter(‘nullsrc’, size=100×200)
Always returns the error message:
filter() missing 1 required positional argument: ‘filter_name’.
But the filter option I wanted was specified.
I am asking for your help.
Many Greetings
Reading from disk (works)
stream = ffmpeg.filter(stream, filter_name='palettegen') stream = ffmpeg.output(stream, self.output_palette) ffmpeg.run(stream)
stream = ffmpeg.filter([ ffmpeg.input(self.input_path, pattern_type='glob', framerate=self.sequence_fps), ffmpeg.input(self.output_palette)], filter_name='paletteuse', dither='none' )
Reading from pipe (doesn’t work)
stream = ffmpeg.filter(stream, filter_name='palettegen') stream = ffmpeg.output(stream, ':pipe', format='image2pipe') ffmpeg.run(stream, capture_stdout=True)
stream = ffmpeg.filter([ ffmpeg.input(self.input_path, pattern_type='glob', framerate=self.sequence_fps), ffmpeg.input(':pipe', format='image2pipe')], filter_name='paletteuse', dither='none' )
I don’t get an error. It just gets stuck here indefinitely until I terminate the process.
Input #0, image2, from 'image/*.png':
Duration: 00:00:03.13, start: 0.000000, bitrate: N/A
Stream #0:0: Video: png, rgba(pc), 1967x1276 [SAR 11811:11811 DAR 1967:1276], 8 fps, 8 tbr, 8 tbn, 8 tbc
Hi! I want to extract the I frames in an video. How to write this command ‘ffmpeg -i 666051400.mp4 -vf «select=eq(pict_type,I)» -vsync vfr -qscale:v 2 -f image2 ./%08d.jpg’ using ffmpeg-python?
I wanted to read the data in the buffer, but I couldn’t find a way to return them. How can I get them
I failed to exprt pcm file when use the following code:
ffmpeg.input('song.mp3', allowed_media_types='audio').output('song.pcm', format='s16le', acodec='pcm_s16le', ac=1, ar='16k').run()
I am a newer in learning ffmpeg-python and can’t solve this problem for a long time.I can use these two codes to reliseze my goal like:
import os os.system('ffmpeg -i song.mp3 -acodec pcm_s16le -f s16le -ac 1 -ar 16000 -y song.pcm> log 2>&1')
however,I just wanna to use methods in the first style because I felt very frustrated for spending too much time on it …
Hi, I was making a small python 3.8 script to sort photos and videos according to their metadata on my Synology NAS (working on DSM 7.0), overall it works well on ubuntu but it fails on the NAS with this error :
FileNotFoundError: [Errno 2] No such file or directory: ‘ffprobe’
I’ve been searching everywhere for help on this issue, I saw this post and tried the solutions but I still got the error on any video I try to read metadata from.
ffmpeg is installed and so are ffmpeg-python and ffprobe-python
Here’s my test code:
from datetime import datetime
import ffmpeg
name = "VID_20200130_185053.mp4"
path = "/volume1/photo/phone/DCIM/Camera/"
data_keys = ["DateTimeOriginal", "DateTime", "creation_time"]
file = f"{path}{name}"
print(file)
vid = ffmpeg.probe(file)['streams']
# vid = ffprobe.FFProbe(file).streams
for key in data_keys:
if key in vid[0]['tags']:
print(datetime.strptime(vid[0]['tags'].get(key).split('T')[0], "%Y-%m-%d"))
I’m trying to concatenate a list of external .ts files:
urls = [ <ts urls> ] inputs = [ ffmpeg.input(url) for url in urls ] concat = ffmpeg.concat(*inputs) ffmpeg.output(concat, "out.wav").run()
The inputs are working fine, but as soon as I concat and output the files I get the ffmpeg error:
Stream specifier '' in filtergraph description [0][1][2][3][4][5][6][7][8][9][10][11][12][13]concat=n=14[s0] matches no streams.
Traceback (most recent call last):
File "pathtofileindex.py", line 35, in <module>
ffmpeg.output(concat, "a.wav").run()
File "pathtofileAppDataRoamingPythonPython39site-packagesffmpeg_run.py", line 325, in run
raise Error('ffmpeg', out, err)
ffmpeg._run.Error: ffmpeg error (see stderr output for detail)
There are 14 inputs
What do I do to concat these .ts files into a single .wav?
Hi!
I have a bunch of source jpegs that haven’t been modified in any way. I want to create a time lapse with all of these images, but at the same time draw a dynamic text on each image with its timestamp. Can this be done directly with ffmpeg (through Python) or do I have to modify each image beforehand?
It would be great if there would be a special method to create a tee
output, because, I would say, its one of those that are «not so pretty» to configure.
The following are 6
code examples of ffmpeg.Error().
You can vote up the ones you like or vote down the ones you don’t like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ffmpeg
, or try the search function
.
Example #1
def test__run__error(mocker, capture_stdout, capture_stderr): mocker.patch.object(ffmpeg._run, 'compile', return_value=['ffmpeg']) stream = _get_complex_filter_example() with pytest.raises(ffmpeg.Error) as excinfo: out, err = ffmpeg.run( stream, capture_stdout=capture_stdout, capture_stderr=capture_stderr ) assert str(excinfo.value) == 'ffmpeg error (see stderr output for detail)' out = excinfo.value.stdout err = excinfo.value.stderr if capture_stdout: assert out == ''.encode() else: assert out is None if capture_stderr: assert err.decode().startswith('ffmpeg version') else: assert err is None
Example #2
def decode_audio(in_filename, **input_kwargs): try: out, err = (ffmpeg .input(in_filename, **input_kwargs) .output('-', format='s16le', acodec='pcm_s16le', ac=1, ar='16k') .overwrite_output() .run(capture_stdout=True, capture_stderr=True) ) except ffmpeg.Error as e: print(e.stderr, file=sys.stderr) sys.exit(1) return out
Example #3
def generate_thumbnail(in_filename, out_filename, time, width): try: ( ffmpeg .input(in_filename, ss=time) .filter('scale', width, -1) .output(out_filename, vframes=1) .overwrite_output() .run(capture_stdout=True, capture_stderr=True) ) except ffmpeg.Error as e: print(e.stderr.decode(), file=sys.stderr) sys.exit(1)
Example #4
def test__probe__exception(): with pytest.raises(ffmpeg.Error) as excinfo: ffmpeg.probe(BOGUS_INPUT_FILE) assert str(excinfo.value) == 'ffprobe error (see stderr output for detail)' assert 'No such file or directory'.encode() in excinfo.value.stderr
Example #5
def normalize_movie(movie_path, fps="24.00", width=None, height=1080): """ Turn movie in a 1080p movie file (or use resolution given in parameter). """ folder_path = os.path.dirname(movie_path) file_source_name = os.path.basename(movie_path) file_target_name = "%s.mp4" % file_source_name[:-8] file_target_path = os.path.join(folder_path, file_target_name) (w, h) = get_movie_size(movie_path) resize_factor = w / h if width is None: width = math.floor(resize_factor * height) if width % 2 == 1: width = width + 1 if height % 2 == 1: height = height + 1 try: stream = ffmpeg.input(movie_path) stream = stream.output( file_target_path, pix_fmt="yuv420p", format="mp4", r=fps, crf="15", preset="medium", vcodec="libx264", s="%sx%s" % (width, height), ) stream.run(quiet=False, capture_stderr=True) if not has_soundtrack(file_target_path): add_empty_soundtrack(file_target_path) except ffmpeg.Error as exc: from flask import current_app current_app.logger.error(exc.stderr) raise return file_target_path
Example #6
def check_file(filename, error_detect='default', strict_level=0, zero_detect=0, ffmpeg_threads=0): if sys.version_info[0] < 3: filename = filename.decode('utf8') file_lowercase = filename.lower() file_ext = os.path.splitext(file_lowercase)[1][1:] file_size = 'NA' try: file_size = check_size(filename) if zero_detect > 0: check_zeros(filename, CONFIG.zero_detect) if file_ext in PIL_EXTENSIONS: if strict_level in [1, 2]: pil_check(filename) if strict_level in [0, 2]: magick_identify_check(filename) if file_ext in PDF_EXTENSIONS: if strict_level in [1, 2]: pypdf_check(filename) if strict_level in [0, 2]: magick_identify_check(filename) if file_ext in MAGICK_EXTENSIONS: if strict_level in [1, 2]: magick_check(filename) if strict_level in [0, 2]: magick_identify_check(filename) if file_ext in VIDEO_EXTENSIONS: ffmpeg_check(filename, error_detect=error_detect, threads=ffmpeg_threads) # except ffmpeg.Error as e: # # print e.stderr # return False, (filename, str(e), file_size) except Exception as e: # IMHO "Exception" is NOT too broad, io/decode/any problem should be (with details) an image problem return False, (filename, str(e), file_size) return True, (filename, None, file_size)
Я использую ffmpeg-python для объединения видео и аудио в своей программе, но для одного видеофайла я постоянно получаю эту ошибку:
ffmpeg version N-55702-g920046a Copyright (c) 2000-2013 the FFmpeg developers
built on Aug 21 2013 18:10:00 with gcc 4.7.3 (GCC)
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 42.100 / 52. 42.100
libavcodec 55. 29.100 / 55. 29.100
libavformat 55. 14.101 / 55. 14.101
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 82.100 / 3. 82.100
libswscale 2. 5.100 / 2. 5.100
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000073cb40] Could not find codec parameters for stream 0 (Video: none (av01 / 0x31307661), 2560x1440, 5427 kb/s): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
temp/Above NYC - Filmed in 12K.mp4: could not find codec parameters
Traceback (most recent call last):
File "C:/Users/Family/PycharmProjects/8-bit Downloader/class_8_bit.py", line 4, in <module>
ffmpeg.output(v, "temp/hello.mp4").run()
File "C:UsersFamilyPycharmProjects8-bit Downloadervenvlibsite-packagesffmpeg_run.py", line 325, in run
raise Error('ffmpeg', out, err)
ffmpeg._run.Error: ffmpeg error (see stderr output for detail)
Он просто этого не узнает. Я знаю, что используется кодек av01 . Я попытался передать его как ключевое слово vcodec , но ничего не помогло. Я попытался перейти к cmd напрямую и добавить к «проанализированному» и «пробному», но, похоже, ничего не работает. Как я могу это исправить? Мой код:
import ffmpeg
# I have tried passing absolute paths instead of relative ones too, still not working
input_video = ffmpeg.input("temp/Above NYC - Filmed in 12K.mp4")
input_audio = ffmpeg.input("temp/audio_temp 1.webm")
full_path = "temp/New.mp4"
out = ffmpeg.output(input_video, input_audio, full_path, vcodec='copy', acodec='aac', strict='experimental')
out.run(overwrite_output=True)
1 ответ
Лучший ответ
Похоже, ваш ffmpeg
не был построен с поддержкой AV1. Ни --enable-libdav1d
, ни --enable-libaom
не отображаются в конфигурации. Он также очень старый (сборка 2.0 от 2013 года).
Вы можете подтвердить с помощью команды ffmpeg -codecs
и найти такую строку
DEV.L. av1 Alliance for Open Media AV1 (декодеры: libdav1d libaom-av1)
Если он отсутствует или отсутствует D
, он не будет работать.
Обратите внимание, что у вас есть общая сборка (--disable-static --enable-shared
), поэтому вам также необходимо установить библиотеки отдельно, даже если они были включены.
Рассмотрите возможность увеличения значения параметров «проанализированная длительность» и «размер проверки».
В этом случае это не сработает. Он уже нашел параметры — (av01 / 0x31307661), 2560x1440, 5427 kb/s
— но не знает, что с ними делать.
4
OrangeDog
26 Янв 2021 в 15:18