Okay guys looks like I have another question to ask, which is kind of related to my last question, which can be found on here: How to start ffprobe with Windows PowerShell. There I was asking how to start ffprobe with Windows PowerShell and after trying out a few things I got it, well lets say, started for a second before it closes again.
I tried it with following commands in PowerShell:
$env:Path = ';C:\Users\Administrator\bin\'
$title = "A_Day_for_Cake_and_Accidents"
Start-Process ff-prompt.bat -ArgumentList "ffprobe -show_streams -select_streams v -print_format xml -count_frames C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\$title.mov > C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\totalframes.xml"
The result, and that is the strange thing, is the xml file with only the standard text from the ff-prompt.bat, which looks like this:
C:\Users\Administrator>ECHO OFF
ffmpeg version N-60959-g669043d
built on Feb 27 2014 22:01:58 with gcc 4.8.2 (GCC)
configuration: --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-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
For help run: ffmpeg -h
For formats run: ffmpeg -formats | more
For codecs run: ffmpeg -codecs | more
Current directory is now: "C:\Users\Administrator\bin"
The bin directory has been added to PATH
My first thought was, that it did not work at all, but then I was wondering why I get an XML file when it is not working at all. PowerShell executes the ff-prompt.bat for maybe a second, before PowerShell shuts down the ff-prompt.bat again without doing half of my commands. Does anybody know why ff-prompt gets closed before executing all of my commands?
EDIT: So what I tried is something that should execute it directly, but in fact I get a shitload of errors:
$title = "A_Day_for_Cake_and_Accidents"
$Cmd = ‘C:\Users\Administrator\ffmpeg\bin\ffprobe.exe’
$Arg1 = ’ffprobe '
$Arg2 = ‘-show_streams ’
$Arg3 = ‘-select_streams v '
$Arg4 = ‘-print_format xml '
$Arg5 = ‘-count_frames '
$Arg6 = "C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\$title.mov >"
$Arg7 = " C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\totalframes.xml"
& $Cmd $Arg1 $Arg2 $Arg3 $Arg4 $Arg5 $Arg6 $Arg7
Error message(s) I get:
"ffprobe.exe
Failed to set value '-select_streams v ' for option 'show_streams ': Option not found"
The problem I am facing now is that -show_streams does not get a value, so maybe that is the reason why he uses the next parameter as a value, is there anything I can do?
The following worked for me:
$title = "A_Day_for_Cake_and_Accidents"
$inputFile = "C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\$title.mov"
$outputFile = "C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\totalframes.xml"
&.\bin\ffprobe.exe -show_streams -select_streams v -print_format xml -count_frames -loglevel quiet $inputFile | out-file $outputFile
I should have realised that '-select_streams v' counts a 2 command line parameters, so wrapping them up in a single argument will not work.
I removed the '>' redirection and added the | out-file .... clause.
The main issue with FFPROBE is that it writes it's logging information to the STDERR channel. PowerShell spots this and throws a NativeCommandError exception.
I tried trapping NativeCommandError, using $ErrorActionPreference = 'stop' and a try...catch construction, but the exception fires before the XML output is generated. In the end, I RTFM for FFPROBE and added the -loglevel quiet parameter which stops FFPROBE writing any log info.
NB - this code assumes it is executed from the directory above 'bin'.
Assuming ffmpeg is in C:\users\Administrator\ffmpeg:
$title = "A_Day_for_Cake_and_Accidents"
& C:\users\Administrator\ffmpeg\bin\ffprobe -show_streams -select_streams v -print_format xml -count_frames C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\$title.mov > C:\Users\Administrator\Desktop\dcp_bearbeitet\$title\totalframes.xml
Related
I want to convert a bunch of photos into a video with crossfade between them. The number of photos I am converting is variable
I am using the code from HERE to apply the crossfade:
Since the number of photos are variable I looped over all the photos in the directory and generated the -loop and also the second part ([0:v]fade=t=out:st=4:d=1[v0];):
for i in range(os.listdir('photos')):
if i == 0:
text += f'\n-loop 1 -t 60 -i photos/Image{i+1}.jpg \\\n'
text2 = '\n[0:v]fade=t=out:st=4:d=1[v0]; \\\n'
else:
text += f'-loop 1 -t 60 -i photos/Image{i+1}.jpg \\\n'
text2 += f' [{i}:v]fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v{i}]; \\\n'
#And the Subprocess part
command = f'ffmpeg \
{text} \
-filter-complex \
{text2} -map "[v]" video/out.mp4'
p = subprocess.call(command, shell=True)
But this thing didn't create any video but said this:
Use -h to get full help or, even better, run 'man ffmpeg'
The full output:
ffmpeg version git-2019-11-11-20c5f4d Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20191010
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 35.101 / 56. 35.101
libavcodec 58. 61.100 / 58. 61.100
libavformat 58. 34.101 / 58. 34.101
libavdevice 58. 9.100 / 58. 9.100
libavfilter 7. 66.100 / 7. 66.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
I am trying to concat video from many files.
But sometimes I receive an error: "Invalid data found when processing input".
So, I am trying to iterate over files with ffprobe and find invalid files.
Here is the error.
ffprobe started on 2020-06-28 at 16:06:39
Report written to "ffreport.log"
Log level: 32
Command line:
"f:\\prog\\ffmpeg\\bin\\ffprobe.exe" -i Rec496_20200423123337_A_1.avi
ffprobe version git-2020-03-23-ba698a2 Copyright (c) 2007-2020 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20200122
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --e
nable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrn
b --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-lib
soxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --e
nable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-l
ibvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-
libaom --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable
-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 42.101 / 56. 42.101
libavcodec 58. 76.100 / 58. 76.100
libavformat 58. 42.100 / 58. 42.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 77.100 / 7. 77.100
libswscale 5. 6.101 / 5. 6.101
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
[avi # 000002510398e1c0] non-interleaved AVI
[h264 # 00000251039a0480] missing picture in access unit with size 256
[extract_extradata # 0000025103996740] No start code is found.
Rec496_20200423123337_A_1.avi: Invalid data found when processing input
Questions:
How can this be fixed, so I don't need to iterate with ffprobe and just use concat (command line: f:\prog\ffmpeg\bin\ffmpeg.exe -f concat -safe 0 -i mylist.txt -c copy output-xx.avi)?
If not, how can I receive an error in my .bat file and move "invalid" file to "Error" folder?
Ok, here is the solution for .bat file.
It moves file to "Err" folder, if found word "Invalid" in log.
set FFREPORT=file=ffreport.log:level=32
IF NOT EXIST "err" md err
for %%i in (*.avi) do (
f:\prog\ffmpeg\bin\ffprobe.exe -i %%i
echo 'errlevel:' + %ERRORLEVEL% >> err.txt
find /c "Invalid" ffreport.log && ( move %%i err )
type ffreport.log >> err.txt
)
I am attempting to combine youtube-dl and ffmpeg to clip audio from YouTube videos. Everything was fine on my laptop, but when I moved to my server (Debian 9) I started coming across this error. Why is this? Am I missing a dependency ... if so which one?
Input
ffmpeg -f m4a $(youtube-dl -f bestaudio[ext=m4a] -g \'https://www.youtube.com/watch?v=qnjYyfkcaNI\' | sed "s/.*/-ss 0 -i &/") -to 60 -c copy -y /public/audio/test.m4a
Error
[NULL # 0x55cf161f1e60] Requested output format 'm4a' is not a
suitable output format /public/audio/test.m4a: Invalid argument
ffmpeg info
ffmpeg version 3.2.12-1~deb9u1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --prefix=/usr --extra-version='1~deb9u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --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-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
The error was not with ffmpeg. The youtube-dl command was failing and resulting in the error.
Updated command
ffmpeg -f m4a $(youtube-dl -f bestaudio[ext=m4a] -g https://www.youtube.com/watch?v=qnjYyfkcaNI | sed "s/.*/-ss 0 -i &/") -to 60 -c copy -y /public/audio/test.m4a
Basically just had to remove the \'.
I also had to go one step further and give permission to the www-data apache group for the output folder since the command was being executed from a PHP script.
I'm writing a python GUI for ffmpeg. When calling ffmpeg via subprocess it runs fine as long as the command is like
subprocess.Popen([ffmpeg_converter,
'-i',file,
target_file
])
But when I do the same call with ffmpeg arguments it fails with
"At least one output file must be specified":
option_string = '-q:a 4'
subprocess.Popen([ffmpeg_converter,
'-i',file,
option_string,
target_file
])
It even recognizes the options but does not see the target file. I even replaced the actual target file with someting simple like "test.mp3" but still the same error. Any ideas? (I'm on windows with python 3.3.)
The complete console output is:
ffmpeg version N-57781-g0610d6e Copyright (c) 2000-2013 the FFmpeg developers
built on Nov 1 2013 18:01:35 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 49.100 / 52. 49.100
libavcodec 55. 40.101 / 55. 40.101
libavformat 55. 20.105 / 55. 20.105
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Trailing options were found on the commandline.
Input #0, flac, from 'c:\script\python\testdata\source\01. Es geht los.flac':
Metadata:
ARTIST : Olivia Trummer Trio
TITLE : Es geht los
ALBUM : Westwind
DATE : 2008
track : 01
GENRE : Jazz
COMMENT : EAC FLAC -8
Duration: 00:06:27.25, bitrate: 834 kb/s
Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
At least one output file must be specified
I think you need to pass -q:a 4 as separate values -q:a, 4.
Try this:
subprocess.Popen([ffmpeg_converter,
'-i',file,
'-q:a', '4'
target_file
])
You are passing your option string as one argument instead of two.
Assume current directory contains files in .bmp format, named IMG_0000.bmp, IMG_0001.bmp, and so on. I need to make avi file from them, threating them as a frames. FFmpeg gives me an error, and i could not understand what is wrong. I've got following error message:
D:\WORK\MyFrames>"C:\Users\Den\Downloads\ffmpeg-latest-win32-static\ffmpeg-201 30928-git-c461265-win32-static\bin\ffmpeg.exe" -i d:\WORK\MyFrames\IMG_%4d.bmp
-r 4 -vcodec h264 -y out.avi
ffmpeg version N-56715-gc461265 Copyright (c) 2000-2013 the FFmpeg developers built on Sep 28 2013 18:02:00 with gcc 4.8.1 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 46.100 / 52. 46.100
libavcodec 55. 33.101 / 55. 33.101
libavformat 55. 18.104 / 55. 18.104
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 88.100 / 3. 88.100
libswscale 2. 5.100 / 2. 5.100
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
[image2 # 022cfa60] Could find no file with path 'd:\WORK\MyFrames\IMG_%4d.bmp
' and index in the range 0-4
d:\WORK\Serega28-3\IMG_%4d.bmp: No such file or directory
the error message say that ffmpeg cannot find your input file sequence.
how are they numbered ? if they are named 'IMG_0001.bmp' etc... you have to use:
fmpeg.exe" -r 4 -i d:\WORK\MyFrames\IMG_%04d.bmp -vcodec h264 -y out.avi