
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (21)
-
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
ANNEXE : Les plugins utilisés spécifiquement pour la ferme
5 mars 2010, parLe site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)
-
MediaSPIP v0.2
21 juin 2013, parMediaSPIP 0.2 is the first MediaSPIP stable release.
Its official release date is June 21, 2013 and is announced here.
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)
Sur d’autres sites (7695)
-
FFMPEG - Why can't i record a video for more than 10 seconds ?
12 février 2020, par gabrielI’m developing a screen recorder for windows with python but for some reason i can’t record the video for more than 10 seconds.However i can record the audio for more than 10 seconds.
Also i’m using :FFMPEG - to record the video with mp4 extension
PYAUDIO - to record the sound
TKINTER - to design the GUI
Since the problem is with the video recording i will leave the code that i used with ffmpeg :
"""
cmdGen.py generates ffmpeg commands to record your screen
"""
import os
class cmdGen:
def __init__(self):
self.fps = 60
self.source = "desktop"
self.encoder = 'mpeg4'
self.hwaccel = None
self.drawMouse = 1
self.enableWebcam = False
self.audList = 0
def config(self,
fps=None,source=None,encoder=None,
hwaccel='unchanged',drawMouse=None,
webcam=None,audList=None):
if fps: self.fps = fps
if source: self.source = source
if encoder: self.encoder = encoder
if hwaccel != 'unchanged': self.hwaccel = hwaccel
if drawMouse: self.drawMouse = 0 if not self.drawMouse else 1
if webcam: self.enableWebcam = bool(webcam)
if audList: self.audList = audList
def setSource(self,isWindow,windowName=""):
if not isWindow:
self.source = "desktop"
else:
self.source = "title="+windowName
def setFps(self,fps):
self.fps = fps
def setEncode(self,encoder):
self.encoder = encoder
def getCmd(self,filename):
print("ACK")
finalCmd = ["ffmpeg.exe","-f","gdigrab"]
finalCmd.extend(['-i',self.source])
finalCmd.extend(['-framerate',str(self.fps)])
finalCmd.extend(['-c:v',self.encoder])
if self.encoder == 'mpeg4':
finalCmd.extend(['-q:v','7'])
if self.hwaccel:
finalCmd.extend(['-hwaccel',self.hwaccel])
finalCmd.extend(['-draw_mouse',str(self.drawMouse)])
finalCmd.extend(["-y", filename])
print(finalCmd)
return finalCmd
def getCvtCmd(self,filename):
# if self.rcchecked.get():
# self.mergeProcess = subprocess.Popen(args= ["ffmpeg","-i",'tmp/tmp.mkv','-i','tmp/tmp.wav','-i','tmp/webcamtmp.mkv','-filter_complex','[2:v] scale=640:-1 [inner]; [0:0][inner] overlay=0:0 [out]',"-shortest",'-map','[out]','-y',"ScreenCaptures/"+self.filename])
# else:
# self.mergeProcess = subprocess.Popen(args= ["ffmpeg","-i",'tmp/tmp.mkv','-i','tmp/tmp.wav',"-shortest",'-y',"ScreenCaptures/"+self.filename], startupinfo=startupinfo)
print("ACK")
finalCmd = ["ffmpeg.exe"]
finalCmd.extend(['-i','tmp/tmp.mkv'])
for i in range(len(self.audList)):
finalCmd.extend(['-i','tmp/tmp_'+str(i)+'.wav'])
if len(self.audList) > 0:
finalCmd.extend(['-filter_complex','amerge=inputs='+str(len(self.audList)),'-ac',str(len(self.audList))])
# finalCmd.extend(['-c:v',self.encoder])
if self.enableWebcam:
finalCmd.extend(['-i','tmp/webcamtmp.mkv','-filter_complex','[2:v] scale=640:-1 [inner]; [0:0][inner] '
'overlay=0:0 [out]','-map','[out]'])
#finalCmd.extend(['-shortest'])
finalCmd.extend(["-y", filename])
print(finalCmd)
return finalCmd
if __name__ == "__main__":
cg = cmdGen()
cg.setEncode("h264_nvenc")
cg.setFps(60)
cg.setSource(False)
print(cg.getCmd("tmp"))Thanks guys
Full log trying to record 1 minute :
C:\Users\FabianoFreitas\AppData\Local\Programs\Python\Python37\python.exe C:/Users/FabianoFreitas/Desktop/PowerShare-v2.0/screenRecorder.py
ACK
['ffmpeg.exe', '-f', 'gdigrab', '-i', 'desktop', '-framerate', '60', '-c:v', 'mpeg4', '-q:v', '7', '-draw_mouse', '1', '-y', 'tmp/tmp.mkv']
* recording
ACK
['ffmpeg.exe', '-i', 'tmp/tmp.mkv', '-i', 'tmp/tmp_0.wav', '-filter_complex', 'amerge=inputs=1', '-ac', '1', '-y', 'Videos/ScreenCapture24.mp4']
* done recording
ffmpeg version git-2020-02-05-e6891d1 Copyright (c) 2000-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 --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. 39.100 / 56. 39.100
libavcodec 58. 67.101 / 58. 67.101
libavformat 58. 37.100 / 58. 37.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 74.100 / 7. 74.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, matroska,webm, from 'tmp/tmp.mkv':
Metadata:
ENCODER : Lavf58.37.100
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mpeg4 (Simple Profile), yuv420p, 2560x1080 [SAR 1:1 DAR 64:27], 29.97 fps, 29.97 tbr, 1k tbn, 30k tbc (default)
Metadata:
ENCODER : Lavc58.67.101 mpeg4
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from 'tmp/tmp_0.wav':
Duration: 00:01:09.08, bitrate: 1411 kb/s
Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
Stream #1:0 (pcm_s16le) -> amerge (graph 0)
amerge (graph 0) -> Stream #0:0 (aac)
Stream #0:0 -> #0:1 (mpeg4 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[Parsed_amerge_0 @ 00000218cb4c1640] No channel layout for input 1
[libx264 @ 00000218cb4acdc0] using SAR=1/1
[libx264 @ 00000218cb4acdc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 00000218cb4acdc0] profile High, level 5.0, 4:2:0, 8-bit
[libx264 @ 00000218cb4acdc0] 264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'Videos/ScreenCapture24.mp4':
Metadata:
encoder : Lavf58.37.100
Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s
Metadata:
encoder : Lavc58.67.101 aac
Stream #0:1: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 2560x1080 [SAR 1:1 DAR 64:27], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)
Metadata:
encoder : Lavc58.67.101 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
[matroska,webm @ 00000218cb44af00] File ended prematurely
frame= 297 fps=113 q=-1.0 Lsize= 2325kB time=00:01:09.07 bitrate= 275.8kbits/s dup=22 drop=0 speed=26.2x
video:1713kB audio:591kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.900237%
[aac @ 00000218cb4ab780] Qavg: 24995.135
[libx264 @ 00000218cb4acdc0] frame I:4 Avg QP:15.13 size:199596
[libx264 @ 00000218cb4acdc0] frame P:85 Avg QP:21.15 size: 9466
[libx264 @ 00000218cb4acdc0] frame B:208 Avg QP:24.93 size: 725
[libx264 @ 00000218cb4acdc0] consecutive B-frames: 5.1% 2.7% 6.1% 86.2%
[libx264 @ 00000218cb4acdc0] mb I I16..4: 48.0% 45.3% 6.7%
[libx264 @ 00000218cb4acdc0] mb P I16..4: 1.6% 1.9% 0.8% P16..4: 1.4% 0.4% 0.3% 0.0% 0.0% skip:93.7%
[libx264 @ 00000218cb4acdc0] mb B I16..4: 0.1% 0.1% 0.0% B16..8: 3.0% 0.1% 0.0% direct: 0.0% skip:96.6% L0:51.2% L1:48.3% BI: 0.6%
[libx264 @ 00000218cb4acdc0] 8x8 transform intra:44.4% inter:69.1%
[libx264 @ 00000218cb4acdc0] coded y,uvDC,uvAC intra: 23.8% 27.4% 19.5% inter: 0.2% 0.3% 0.1%
[libx264 @ 00000218cb4acdc0] i16 v,h,dc,p: 54% 45% 1% 0%
[libx264 @ 00000218cb4acdc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 20% 41% 2% 2% 1% 2% 1% 5%
[libx264 @ 00000218cb4acdc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 35% 17% 2% 3% 3% 4% 2% 4%
[libx264 @ 00000218cb4acdc0] i8c dc,h,v,p: 61% 25% 11% 2%
[libx264 @ 00000218cb4acdc0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 00000218cb4acdc0] ref P L0: 68.0% 6.3% 16.6% 9.1%
[libx264 @ 00000218cb4acdc0] ref B L0: 70.2% 23.7% 6.1%
[libx264 @ 00000218cb4acdc0] ref B L1: 91.1% 8.9%
[libx264 @ 00000218cb4acdc0] kb/s:1415.80 -
ffmpeg conversion : Twitter rejects video with "Not valid video"
12 février 2020, par DeadlyBaconI have an app that uploads via twitter api chunked upload, and it finally works with photos.
However, I am trying to get it to work with videos.
Uploading didnt work out-of-the-box even though the video format is mp4. The twitter guidelines for uploads are these
With that in mind, I have this ffmpeg command so far :
ffmpeg -i in.mp4 -vf \"scale=1280:720\" -b:v 5000K -minrate 5000K -maxrate 5000K -b:a 128K -r 30 -f mp4 -vcodec libx264 -profile:v high -pix_fmt yuv420p -strict -2 -ac 2 -acodec aac out.mp4
I still get "Not valid video", and I don’t know why.
Here’s my mediainfo output for out.mp4 :
General
Count : 328
Count of stream of this kind : 1
Kind of stream : General
Kind of stream : General
Stream identifier : 0
Count of video streams : 1
Count of audio streams : 1
Video_Format_List : AVC
Video_Format_WithHint_List : AVC
Codecs Video : AVC
Video_Language_List : English
Audio_Format_List : AAC
Audio_Format_WithHint_List : AAC
Audio codecs : AAC LC
Audio_Language_List : English
Complete name : video-5e4405cd4348a5e4405cd434d2.mp4
File name : video-5e4405cd4348a5e4405cd434d2
File extension : mp4
Format : MPEG-4
Format : MPEG-4
Format/Extensions usually used : mov mp4 m4v m4a m4b m4p 3ga 3gpa 3gpp 3gp 3gpp2 3g2 k3g jpm jpx mqv ismv isma ismt f4a f4b f4v
Commercial name : MPEG-4
Format profile : Base Media
Internet media type : video/mp4
Codec ID : isom
Codec ID : isom (isom/iso2/avc1/mp41)
Codec ID/Url : http://www.apple.com/quicktime/download/standalone.html
CodecID_Compatible : isom/iso2/avc1/mp41
Codec : MPEG-4
Codec : MPEG-4
Codec/Extensions usually used : mov mp4 m4v m4a m4b m4p 3ga 3gpa 3gpp 3gp 3gpp2 3g2 k3g jpm jpx mqv ismv isma ismt f4a f4b f4v
File size : 52664272
File size : 50.2 MiB
File size : 50 MiB
File size : 50 MiB
File size : 50.2 MiB
File size : 50.22 MiB
Duration : 79744
Duration : 1 min 19 s
Duration : 1 min 19 s 744 ms
Duration : 1 min 19 s
Duration : 00:01:19.744
Duration : 00:01:19:20
Duration : 00:01:19.744 (00:01:19:20)
Overall bit rate : 5283334
Overall bit rate : 5 283 kb/s
Frame rate : 30.000
Frame rate : 30.000 FPS
Frame count : 2390
Stream size : 88780
Stream size : 86.7 KiB (0%)
Stream size : 87 KiB
Stream size : 87 KiB
Stream size : 86.7 KiB
Stream size : 86.70 KiB
Stream size : 86.7 KiB (0%)
Proportion of this stream : 0.00169
HeaderSize : 40
DataSize : 52575500
FooterSize : 88732
IsStreamable : No
File last modification date : UTC 2020-02-12 14:05:37
File last modification date (local) : 2020-02-12 15:05:37
Writing application : Lavf57.83.100
Writing application : Lavf57.83.100
Video
Count : 342
Count of stream of this kind : 1
Kind of stream : Video
Kind of stream : Video
Stream identifier : 0
StreamOrder : 0
ID : 1
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format/Url : http://developers.videolan.org/x264.html
Commercial name : AVC
Format profile : High@L3.1
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, CABAC : Yes
Format settings, ReFrames : 4
Format settings, ReFrames : 4 frames
Internet media type : video/H264
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Codec : AVC
Codec : AVC
Codec/Family : AVC
Codec/Info : Advanced Video Codec
Codec/Url : http://developers.videolan.org/x264.html
Codec/CC : avc1
Codec profile : High@L3.1
Codec settings : CABAC / 4 Ref Frames
Codec settings, CABAC : Yes
Codec_Settings_RefFrames : 4
Duration : 79667
Duration : 1 min 19 s
Duration : 1 min 19 s 667 ms
Duration : 1 min 19 s
Duration : 00:01:19.667
Duration : 00:01:19:20
Duration : 00:01:19.667 (00:01:19:20)
Bit rate : 5000000
Bit rate : 5 000 kb/s
Width : 1280
Width : 1 280 pixels
Height : 720
Height : 720 pixels
Sampled_Width : 1280
Sampled_Height : 720
Pixel aspect ratio : 1.000
Display aspect ratio : 1.778
Display aspect ratio : 16:9
Rotation : 0.000
Frame rate mode : CFR
Frame rate mode : Constant
FrameRate_Mode_Original : VFR
Frame rate : 30.000
Frame rate : 30.000 FPS
Frame count : 2390
Resolution : 8
Resolution : 8 bits
Colorimetry : 4:2:0
Color space : YUV
Chroma subsampling : 4:2:0
Chroma subsampling : 4:2:0
Bit depth : 8
Bit depth : 8 bits
Scan type : Progressive
Scan type : Progressive
Interlacement : PPF
Interlacement : Progressive
Bits/(Pixel*Frame) : 0.181
Stream size : 51297022
Stream size : 48.9 MiB (97%)
Stream size : 49 MiB
Stream size : 49 MiB
Stream size : 48.9 MiB
Stream size : 48.92 MiB
Stream size : 48.9 MiB (97%)
Proportion of this stream : 0.97404
Writing library : x264 - core 152 r2854 e9a5903
Writing library : x264 core 152 r2854 e9a5903
Encoded_Library_Name : x264
Encoded_Library_Version : core 152 r2854 e9a5903
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=5000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language : en
Language : English
Language : English
Language : en
Language : eng
Language : en
Audio
Count : 275
Count of stream of this kind : 1
Kind of stream : Audio
Kind of stream : Audio
Stream identifier : 0
StreamOrder : 1
ID : 2
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Commercial name : AAC
Format profile : LC
Format settings, SBR : No (Explicit)
Format settings, SBR : No (Explicit)
Codec ID : mp4a-40-2
Codec : AAC LC
Codec : AAC LC
Codec/Family : AAC
Codec/CC : 40
Duration : 79744
Duration : 1 min 19 s
Duration : 1 min 19 s 744 ms
Duration : 1 min 19 s
Duration : 00:01:19.744
Duration : 00:01:19:25
Duration : 00:01:19.744 (00:01:19:25)
Bit rate mode : CBR
Bit rate mode : Constant
Bit rate : 128257
Bit rate : 128 kb/s
Channel(s) : 2
Channel(s) : 2 channels
Channel positions : Front: L R
Channel positions : 2/0/0
ChannelLayout : L R
Samples per frame : 1024
Sampling rate : 48000
Sampling rate : 48.0 kHz
Samples count : 3827712
Frame rate : 46.875
Frame rate : 46.875 FPS (1024 SPF)
Frame count : 3738
Compression mode : Lossy
Compression mode : Lossy
Stream size : 1278470
Stream size : 1.22 MiB (2%)
Stream size : 1 MiB
Stream size : 1.2 MiB
Stream size : 1.22 MiB
Stream size : 1.219 MiB
Stream size : 1.22 MiB (2%)
Proportion of this stream : 0.02428
Language : en
Language : English
Language : English
Language : en
Language : eng
Language : en
Default : Yes
Default : Yes
Alternate group : 1
Alternate group : 1Edit : Guess Ill add my PHP code too (This is chopped in a sensible manner because the actual file is very large) :
// Set up Codebird
\Codebird\Codebird::setConsumerKey($consumer_key, $consumer_secret); // static, see README
$cb = \Codebird\Codebird::getInstance();
$cb->setToken($token, $token_secret);
$cb->setTimeout(60 * 1000); // 60 second request timeout
$video = new Video($path);
// Convert to the parameter required by twitter.
$converted = $video->convert();
$path = realpath('videos/' . $converted);
$file = fopen($path, 'rb');
$size = fstat($file)['size'];
$mime_type = mime_content_type($path);
$media = $cb->media_upload([
'command' => 'INIT',
'media_type' => $mime_type,
'media_category' => 'tweet_video',
'total_bytes' => $size,
]);
$success = $media->httpstatus >= 200 && $media->httpstatus < 300; # 2xx
if (!$success) {
throw new TwitterException("Failed to INIT upload for $path...");
}
// APPEND chunks to upload.
$mediaId = $media->media_id_string;
$segmentId = 0;
while (!feof($file)) {
echo "chunk #$segmentId....";
$chunk = fread($file, 512 * 1024); // caps out at 512 MB
echo "chunk size: ". strlen($chunk);
$media = $cb->media_upload([
'command' => 'APPEND',
'media_id' => $mediaId,
'segment_index' => $segmentId,
'media' => $chunk,
]);
$success = $media->httpstatus >= 200 && $media->httpstatus < 300; # 2xx
if (!$success) {
throw new TwitterException("Failed to APPEND to upload for $path, chunk $segmentId...");
}
$segmentId++;
}
// Close file and FINALIZE upload.
fclose($file);
echo "FINALIZING id $mediaId...";
$media = $cb->media_upload([
'command' => 'FINALIZE',
'media_id' => $mediaId,
]);
$success = $media->httpstatus >= 200 && $media->httpstatus < 300; # 2xx
if (!$success) {
var_dump($media);
throw new TwitterException("Failed to FINALIZE upload for $path...");
}
return $mediaId;Video is my ffmpeg class, which I’ll paste below, and $path is a URL leading to a perfectly valid mp4 video.
Video.php :
<?php
class VideoConversionException extends \Exception {}
class Video {
public $name;
public $converted;
public function __construct($name) {
self::clear();
$this->name = $name;
}
public function convert() {
$tmpVideo = 'video-' . uniqid() . uniqid() . '.mp4';
$videoPath = 'videos/' . $tmpVideo;
//$ffmpeg = "ffmpeg -i https://tvcanarias.acfipress.com/BC_190907_gc_teror.mp4 -vf "scale=1280:720" -b:v 5000K -b:a 128K -r 30 -f mp4 -vcodec libx264 -acodec aac output_video.mp4";
$ffmpeg = "ffmpeg -i {$this->name} -vf \"scale=1280:720\" -b:v 5000K -minrate 5000K -maxrate 5000K -b:a 128K -r 30 -f mp4 -vcodec libx264 -profile:v high -pix_fmt yuv420p -strict -2 -ac 2 -acodec aac $videoPath";
//$ffmpeg = "ffmpeg -i {$this->name} -pix_fmt yuv420p -vcodec libx264 -vf scale=640:-1 -acodec aac -vb 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -ar 44100 -ac 2 -strict experimental -r 30 $videoPath";
$output = [];
exec($ffmpeg, $output, $status);
if ($status != 0) {
//die("Couldnt run ffmpeg. (Error code: #$status)");
throw new VideoConversionException("Couldn't run ffmpeg. (Error code: #$status)");
}
$this->converted = $tmpVideo;
return $tmpVideo;
}
public function shredConverted() {
// delete video.
@unlink("videos/{$this->$converted}");
}
public static function clear() {
// We can't really shred videos right away as they might be still uploading.
// Therefore, every time this library is used, we will just delete videos older
// than, say, an hour.
$files = scandir('videos');
$curtime = time();
foreach ($files as $file) {
if ($file == '.gitignore' || $file == '.' || $file == '..') {
continue;
}
$mtime = filemtime("videos/$file");
$diff = $curtime - $mtime;
$overAnHour = $diff > (60 * 60);
if ($overAnHour) {
@unlink("videos/$file");
}
}
}
} -
Discord.js Music bot TypeError [ERR_INVALID_ARG_TYPE] : The "file" argument must be of type string. Received type object
21 février 2020, par Cole PerryI’m new to Discord.js and I’m trying to have the bot join a voice channel and play an audio file on my computer. I have been following this guide : https://discord.js.org/#/docs/main/stable/topics/voice . Here is the Index.js page :
const Discord = require('discord.js');
const Colesbot = new Discord.Client();
const token = '***********************************************';
Colesbot.on('ready', () =>{
console.log('Slamsbot is online.');
})
Colesbot.on('message', msg=>{
if(msg.content == "What up bot?"){
msg.reply("Whats good pimp?")
}
});
Colesbot.on('message', message=>{
if (message.content === '/join') {
// Only try to join the sender's voice channel if they are in one themselves
if (message.member.voiceChannel) {
message.member.voiceChannel.join().then(connection => {
message.reply('I have successfully connected to the channel!');
// To play a file, we need to give an absolute path to it
const dispatcher = connection.playFile('C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\Assets\Glory.mp3');
dispatcher.on('end', () => {
// The song has finished
console.log('Finished playing!');
});
dispatcher.on('error', e => {
// Catch any errors that may arise
console.log(e);
});
dispatcher.setVolume(0.5); // Set the volume to 50%
}).catch(console.log);
} else {
message.reply('You need to join a voice channel first!');
}
}
});
//Event listener for new guild members
Colesbot.on('guildMemberAdd', member =>{
// Send the message to a designated channel on a server:
const channel = member.guild.channels.find(ch => ch.name === 'general');
// Do nothing if the channel wasn't found on this server
if (!channel) return;
// Send the message, mentioning the member
channel.send(`Welcome to the server, ${member}. Please use the bot-commands channel to assign yourself a role.`);
})
Colesbot.login(token);
exports.run = (client, message, args) => {
let user = message.mentions.users.first || message.author;
}FFMPEG is installed and I have set the environment path for it. When I type FFMPEG in the command line I get the proper response.
Some have said I need to install the ffmpeg binaries but when I run npm install ffmpeg-binaries I get this error message :
npm WARN deprecated ffmpeg-binaries@4.0.0: ffmpeg-binaries is no longer being maintained. use ffmpeg-static, or just install ffmpeg
> lzma-native@3.0.8 install C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\lzma-native
> node-pre-gyp install --fallback-to-build && node node_modules/rimraf/bin.js build
node-pre-gyp ERR! Tried to download(404): https://node-pre-gyp.addaleax.net/lzma-native/lzma_native-v3.0.8-node-v72-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for lzma-native@3.0.8 and node@12.14.1 (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://node-pre-gyp.addaleax.net/lzma-native/lzma_native-v3.0.8-node-v72-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for lzma-native@3.0.8 and node@12.14.1 (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python checking if the py launcher can be used to find Python 2
gyp ERR! find Python - "py.exe" is not in PATH or produced an error
gyp ERR! find Python checking if Python is C:\Python27\python.exe
gyp ERR! find Python - "C:\Python27\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Python37\python.exe
gyp ERR! find Python - "C:\Python37\python.exe" could not be run
gypgyp ERR! find PythonERR!
find Pythongyp
gyp ERR!ERR! find Pythonfind Python Python is not set from command line or npm configuration
**********************************************************
gypgyp ERR!ERR! find Pythonfind Python Python is not set from environment variable PYTHON
You need to install the latest version of Python.
gypgyp ERR!ERR! find Pythonfind Python checking if "python" can be used
Node-gyp should be able to find and use Python. If not,
gypgyp ERR!ERR! find Pythonfind Python - "python" is not in PATH or produced an error
you can try one of the following options:
gypgyp ERR!ERR! find Pythonfind Python checking if "python2" can be used
- Use the switch --python="C:\Path\To\python.exe"
gypgyp ERR! ERR!find Python - "python2" is not in PATH or produced an error
find Pythongyp (accepted by both node-gyp and npm)
gypERR! ERR!find Python checking if "python3" can be used
find Pythongyp - Set the environment variable PYTHON
gypERR! ERR!find Python - "python3" is not in PATH or produced an error
find Pythongyp - Set the npm configuration variable python:
gypERR! ERR!find Python checking if the py launcher can be used to find Python 2
find Pythongyp npm config set python "C:\Path\To\python.exe"
gypERR! ERR!find Python - "py.exe" is not in PATH or produced an error
find Pythongyp For more information consult the documentation at:
gypERR! ERR!find Python checking if Python is C:\Python27\python.exe
gypfind Python https://github.com/nodejs/node-gyp#installation
ERR!gyp find PythonERR! - "C:\Python27\python.exe" could not be run
gypfind Python **********************************************************
ERR!gyp find PythonERR! checking if Python is C:\Python37\python.exe
gypfind Python
ERR! find Python - "C:\Python37\python.exe" could not be run
gypgyp ERR!ERR! configure errorfind Python
gypgyp ERR!ERR! stackfind Python Error: Could not find any Python installation to use
**********************************************************
gyp gypERR! ERR!stack at PythonFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:307:47)
find Pythongyp You need to install the latest version of Python.
ERR!gyp stack at PythonFinder.runChecks (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:136:21)
ERR!gyp ERR!find Python Node-gyp should be able to find and use Python. If not,
stack at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:225:16)
gypgyp ERR!ERR! find Pythonstack you can try one of the following options:
at PythonFinder.execFileCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:271:16)
gypgyp ERR!ERR! stackfind Python at exithandler (child_process.js:302:5)
gyp - Use the switch --python="C:\Path\To\python.exe"
gypERR! stackERR! at ChildProcess.errorhandler (child_process.js:314:5)
gyp find PythonERR! (accepted by both node-gyp and npm)
stack at ChildProcess.emit (events.js:223:5)
gypgyp ERR!ERR! stackfind Python at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
- Set the environment variable PYTHON
gypgyp ERR!ERR! stack at onErrorNT (internal/child_process.js:456:16)
find Pythongyp - Set the npm configuration variable python:
gypERR! ERR!stack at processTicksAndRejections (internal/process/task_queues.js:81:21)
find Python npm config set python "C:\Path\To\python.exe"
gypgyp ERR!ERR! find PythonSystem For more information consult the documentation at:
Windows_NT 10.0.17763
gypgyp ERR!ERR! find Pythoncommand https://github.com/nodejs/node-gyp#installation
"C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\Users\\bobal\\Documents\\GitHub\\Spotify-Playlist-Discord-bot\\node_modules\\lzma-native\\binding-v3.0.8-node-v72-win32-x64\\lzma_native.node" "--module_name=lzma_native" "--module_path=C:\\Users\\bobal\\Documents\\GitHub\\Spotify-Playlist-Discord-bot\\node_modules\\lzma-native\\binding-v3.0.8-node-v72-win32-x64"
gypgyp ERR!ERR! find Pythoncwd **********************************************************
C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\lzma-native
gypgyp ERR!ERR! find Pythonnode -v
v12.14.1
gyp ERR! node-gyp -vgyp v5.0.5
gyp ERR!ERR! configure errornot ok
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack at PythonFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:307:47)
gyp ERR! stack at PythonFinder.runChecks (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:136:21)
gyp ERR! stack at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:225:16)
gyp ERR! stack at PythonFinder.execFileCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:271:16)
gyp ERR! stack at exithandler (child_process.js:302:5)
gyp ERR! stacknode-pre-gyp at ChildProcess.errorhandler (child_process.js:314:5)
gypERR! ERR!build error
stack at ChildProcess.emit (events.js:223:5)
node-pre-gypgyp ERR!ERR! stackstack at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\lzma-native\binding-v3.0.8-node-v72-win32-x64\lzma_native.node --module_name=lzma_native --module_path=C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\lzma-native\binding-v3.0.8-node-v72-win32-x64' (1)
node-pre-gypgyp ERR! ERR!stack at ChildProcess.<anonymous> (C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\lzma-native\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
stacknode-pre-gyp at onErrorNT (internal/child_process.js:456:16)
gypERR! ERR!stack at ChildProcess.emit (events.js:223:5)
stacknode-pre-gyp at processTicksAndRejections (internal/process/task_queues.js:81:21)
ERR! stackgyp at maybeClose (internal/child_process.js:1021:16)
node-pre-gypERR! ERR!System stack Windows_NT 10.0.17763
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
gyp ERR! node-pre-gypcommand "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\Users\\bobal\\Documents\\GitHub\\Spotify-Playlist-Discord-bot\\node_modules\\lzma-native\\binding-v3.0.8-node-v72-win32-x64\\lzma_native.node" "--module_name=lzma_native" "--module_path=C:\\Users\\bobal\\Documents\\GitHub\\Spotify-Playlist-Discord-bot\\node_modules\\lzma-native\\binding-v3.0.8-node-v72-win32-x64"
ERR!gyp SystemERR! Windows_NT 10.0.17763
node-pre-gypcwd C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\lzma-native
ERR!gyp commandERR! "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\bobal\\Documents\\GitHub\\Spotify-Playlist-Discord-bot\\node_modules\\lzma-native\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gypnode -v v12.14.1
ERR!gyp cwdERR! C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\lzma-native
node-pre-gypnode-gyp -v v5.0.5
ERR!gyp ERR!node -v v12.14.1
not ok
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\lzma-native\binding-v3.0.8-node-v72-win32-x64\lzma_native.node --module_name=lzma_native --module_path=C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\lzma-native\binding-v3.0.8-node-v72-win32-x64' (1)
npm WARN discord.js@11.5.1 requires a peer of @discordjs/uws@^10.149.0 but none is installed. You must install peer dependencies yourself.
npm WARN spotifybot@1.0.0 No description
npm WARN spotifybot@1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! lzma-native@3.0.8 install: `node-pre-gyp install --fallback-to-build && node node_modules/rimraf/bin.js build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the lzma-native@3.0.8 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\bobal\AppData\Roaming\npm-cache\_logs\2020-02-21T19_25_47_323Z-debug.log
</anonymous></anonymous></anonymous>So then I tried installing an older version and I’m now using ffmpeg-binaries@3.2.2-3 but when I type /join I get this : [ERR_INVALID_ARG_TYPE] : The "file" argument must be of type string. Received type object