
Recherche avancée
Autres articles (36)
-
Ajouter notes et légendes aux images
7 février 2011, parPour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
Modification lors de l’ajout d’un média
Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...) -
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...) -
Support de tous types de médias
10 avril 2011Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)
Sur d’autres sites (12319)
-
FFmpeg overlay PNG has not necessary black borders
24 mars 2021, par Mikołaj HenklewskiI have a few PNG files that I want to add to the video :


- 

- Two lines text
- Circle
- Red letters
- White letters










but on the final video, some of them have black borders (they do not have it originally !) Actual Result.. The question is why FFmpeg is adding it, and how to avoid adding it ? Command is :


ffmpeg -i 3d9678e2e58c4d08a24363468d0cfd3e.mp4 -i caption-1616544596077.png -i caption-1616544596080.png -i caption-1616544597262.png -i caption-1616544598027.png -filter_complex "[1:v]format=rgba,colorchannelmixer=aa=1[1_alpha];
[1_alpha]setpts=1.0*PTS[1_alpha_speed]; [1_alpha_speed]rotate=6.178465552059927:c=none:ow=rotw(6.178465552059927):oh=roth(6.178465552059927)[1_alpha_speed_rot];
[1_alpha_speed_rot]scale=iw/2:ih/2[1_alpha_speed_rot_scale];
[0:v][1_alpha_speed_rot_scale]overlay=x=288:y=50:enable='between(t,0,3.2)':format=rgb[1_out];
[2:v]format=rgba,colorchannelmixer=aa=1[2_alpha];
[2_alpha]setpts=1.0*PTS[2_alpha_speed];
[2_alpha_speed]rotate=0.0:c=none:ow=rotw(0.0):oh=roth(0.0)[2_alpha_speed_rot];
[2_alpha_speed_rot]scale=iw/2:ih/2[2_alpha_speed_rot_scale];
[1_out][2_alpha_speed_rot_scale]overlay=x=589:y=71:enable='between(t,0,3.2)':format=rgb[2_out];
[3:v]format=rgba,colorchannelmixer=aa=1[3_alpha];
[3_alpha]setpts=1.0*PTS[3_alpha_speed]; [3_alpha_speed]rotate=6.178465552059927:c=none:ow=rotw(6.178465552059927):oh=roth(6.178465552059927)[3_alpha_speed_rot];
[3_alpha_speed_rot]scale=iw/2:ih/2[3_alpha_speed_rot_scale];
[2_out][3_alpha_speed_rot_scale]overlay=x=409:y=104:enable='between(t,0,3.2)':format=rgb[3_out];
[4:v]format=rgba,colorchannelmixer=aa=1[4_alpha];
[4_alpha]setpts=1.0*PTS[4_alpha_speed];
[4_alpha_speed]rotate=0.0:c=none:ow=rotw(0.0):oh=roth(0.0)[4_alpha_speed_rot];
[4_alpha_speed_rot]scale=iw/2:ih/2[4_alpha_speed_rot_scale];
[3_out][4_alpha_speed_rot_scale]overlay=x=593:y=337:enable='between(t,0,3.2)':format=rgb" -preset ultrafast -crf 23 d4d85756d7b54735b95720f9280bf6e2.mp4



Here is also log from ffmpeg :


ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
 built with Apple clang version 12.0.0 (clang-1200.0.32.29)
 configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.2_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
 libavutil 56. 51.100 / 56. 51.100
 libavcodec 58. 91.100 / 58. 91.100
 libavformat 58. 45.100 / 58. 45.100
 libavdevice 58. 10.100 / 58. 10.100
 libavfilter 7. 85.100 / 7. 85.100
 libavresample 4. 0. 0 / 4. 0. 0
 libswscale 5. 7.100 / 5. 7.100
 libswresample 3. 7.100 / 3. 7.100
 libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '3d9678e2e58c4d08a24363468d0cfd3e.mp4':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 encoder : Lavf58.77.100
 Duration: 00:00:03.72, start: 0.000000, bitrate: 2333 kb/s
 Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 2331 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
 Metadata:
 handler_name : VideoHandler
Input #1, png_pipe, from 'caption-1616544596077.png':
 Duration: N/A, bitrate: N/A
 Stream #1:0: Video: png, rgba(pc), 1382x884, 25 tbr, 25 tbn, 25 tbc
Input #2, png_pipe, from 'caption-1616544596080.png':
 Duration: N/A, bitrate: N/A
 Stream #2:0: Video: png, rgba(pc), 612x612, 25 tbr, 25 tbn, 25 tbc
Input #3, png_pipe, from 'caption-1616544597262.png':
 Duration: N/A, bitrate: N/A
 Stream #3:0: Video: png, rgba(pc), 720x266, 25 tbr, 25 tbn, 25 tbc
Input #4, png_pipe, from 'caption-1616544598027.png':
 Duration: N/A, bitrate: N/A
 Stream #4:0: Video: png, rgba(pc), 304x170, 25 tbr, 25 tbn, 25 tbc
File 'd4d85756d7b54735b95720f9280bf6e2.mp4' already exists. Overwrite? [y/N] y
Stream mapping:
 Stream #0:0 (h264) -> overlay:main
 Stream #1:0 (png) -> format
 Stream #2:0 (png) -> format
 Stream #3:0 (png) -> format
 Stream #4:0 (png) -> format
 overlay -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[libx264 @ 0x7fb2c7015a00] using SAR=1/1
[libx264 @ 0x7fb2c7015a00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fb2c7015a00] profile High 4:4:4 Predictive, level 3.1, 4:4:4, 8-bit
[libx264 @ 0x7fb2c7015a00] 264 - core 161 r3048 b86ae3c - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=6 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to 'd4d85756d7b54735b95720f9280bf6e2.mp4':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 encoder : Lavf58.45.100
 Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
 Metadata:
 encoder : Lavc58.91.100 libx264
 Side data:
 cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 17 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= frame= 93 fps=0.0 q=-1.0 Lsize= 972kB time=00:00:03.68 bitrate=2164.1kbits/s speed=4.01x
video:971kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.121794%
[libx264 @ 0x7fb2c7015a00] frame I:1 Avg QP:20.00 size: 90127
[libx264 @ 0x7fb2c7015a00] frame P:92 Avg QP:18.23 size: 9821
[libx264 @ 0x7fb2c7015a00] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x7fb2c7015a00] mb P I16..4: 1.7% 0.0% 0.0% P16..4: 19.9% 0.0% 0.0% 0.0% 0.0% skip:78.4%
[libx264 @ 0x7fb2c7015a00] coded y,u,v intra: 33.9% 3.1% 5.2% inter: 8.6% 0.9% 0.8%
[libx264 @ 0x7fb2c7015a00] i16 v,h,dc,p: 29% 34% 19% 18%
[libx264 @ 0x7fb2c7015a00] kb/s:2136.99



-
ffmpeg adding 6 secs of black frames in the beginning of a file
7 août 2014, par user3842039Trying to convert a .mov file (h264 and pcm) generated in Mpegstreamclip (MacOS) and the result is strangely out of sync with around 6 seconds of black frames at the beginning. I have tried many differente audio and video codec and the result is the same even with a -vcodec copy and -acodec copy. Below the return of ffmpeg (git version compiled today - 06/08/2014) :
ffmpeg -i /media/dados/x/PGM-970.mov -vcodec copy -acodec copy /media/dados/convertidos/PGM-970-converted-ffmpeg-compilado.mov
ffmpeg version 2.3.git-1ace957 Copyright (c) 2000-2014 the FFmpeg developers
built on Jul 26 2014 20:25:06 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-x11grab --enable-libpulse --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr
libavutil 52. 92.101 / 52. 92.101
libavcodec 55. 69.100 / 55. 69.100
libavformat 55. 49.100 / 55. 49.100
libavdevice 55. 13.102 / 55. 13.102
libavfilter 4. 11.102 / 4. 11.102
libavresample 1. 3. 0 / 1. 3. 0
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x2ddac20] multiple edit list entries, a/v desync might occur, patch welcome
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x2ddac20] Concatenated H.264 or H.265 might not play correctly.
Guessed Channel Layout for Input Stream #0.1 : mono
Guessed Channel Layout for Input Stream #0.2 : mono
Guessed Channel Layout for Input Stream #0.3 : mono
Guessed Channel Layout for Input Stream #0.4 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/media/dados/x/PGM-970.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2014-08-01 16:50:24
Duration: 00:24:56.30, start: 0.000000, bitrate: 8350 kb/s
Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte1File '/media/dados/convertidos/PGM-970-converted-ffmpeg-compilado.mov' already exists. Overwrite ? [y/N] y
70m), 720x480, 5258 kb/s, 29.97 fps, 29.97 tbr, 2997 tbn, 5994 tbc (default)
Metadata:
creation_time : 2014-08-01 16:50:24
handler_name : Apple Alias Data Handler
encoder : H.264
timecode : 01:00:00;00
Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 1 channels, s16, 768 kb/s (default)
Metadata:
creation_time : 2014-08-01 16:50:24
File '/media/dados/convertidos/PGM-970-converted-ffmpeg-compilado.mov' already exists. Overwrite ? [y/N] yhandler_name : Apple Alias Data Handler
Stream #0:2(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 1 channels, s16, 768 kb/s (default)
Metadata:
creation_time : 2014-08-01 16:50:24
handler_name : Apple Alias Data Handler
Stream #0:3(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 1 channels, s16, 768 kb/s (default)
Metadata:
creation_time : 2014-08-01 16:50:24
handler_name : Apple Alias Data Handler
Stream #0:4(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 1 channels, s16, 768 kb/s (default)
Metadata:
creation_time : 2014-08-01 16:50:24
handler_name : Apple Alias Data Handler
Stream #0:5(eng): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2014-08-01 16:51:16
handler_name : Apple Alias Data Handler
timecode : 01:00:00;00
Output #0, mov, to '/media/dados/convertidos/PGM-970-converted-ffmpeg-compilado.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
encoder : Lavf55.49.100
Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 720x480, q=2-31, 5258 kb/s, 29.97 fps, 11988 tbn, 2997 tbc (default)
Metadata:
creation_time : 2014-08-01 16:50:24
handler_name : Apple Alias Data Handler
encoder : H.264
timecode : 01:00:00;00
Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, mono, 768 kb/s (default)
Metadata:
creation_time : 2014-08-01 16:50:24
handler_name : Apple Alias Data Handler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for helpEven ignoring the audio stream with "-an" ffmpeg persists to add the frames and alter the output duration.
Any help is very much appreciated ! thanks in advance
-
how to add audio using ffmpeg when recording video from browser and streaming to Youtube/Twitch ?
26 juillet 2021, par Tosh VelagaI have a web application I am working on that allows the user to stream video from their browser and simultaneously livestream to both Youtube and Twitch using ffmpeg. The application works fine when I don't need to send any of the audio. Currently I am getting the error below when I try to record video and audio. I am new to using ffmpeg and so any help would be greatly appreciated. Here is also my repo if needed : https://github.com/toshvelaga/livestream


Here is my node.js server with ffmpeg


const child_process = require('child_process') // To be used later for running FFmpeg
const express = require('express')
const http = require('http')
const WebSocketServer = require('ws').Server
const NodeMediaServer = require('node-media-server')
const app = express()
const cors = require('cors')
const path = require('path')
const logger = require('morgan')
require('dotenv').config()

app.use(logger('dev'))
app.use(cors())

app.use(express.json({ limit: '200mb', extended: true }))
app.use(
 express.urlencoded({ limit: '200mb', extended: true, parameterLimit: 50000 })
)

var authRouter = require('./routes/auth')
var compareCodeRouter = require('./routes/compareCode')

app.use('/', authRouter)
app.use('/', compareCodeRouter)

if (process.env.NODE_ENV === 'production') {
 // serve static content
 // npm run build
 app.use(express.static(path.join(__dirname, 'client/build')))

 app.get('*', (req, res) => {
 res.sendFile(path.join(__dirname, 'client/build', 'index.html'))
 })
}

const PORT = process.env.PORT || 8080

app.listen(PORT, () => {
 console.log(`Server is starting on port ${PORT}`)
})

const server = http.createServer(app).listen(3000, () => {
 console.log('Listening on PORT 3000...')
})


const wss = new WebSocketServer({
 server: server,
})

wss.on('connection', (ws, req) => {
 const ffmpeg = child_process.spawn('ffmpeg', [
 // works fine when I use this but when I need audio problems arise
 // '-f',
 // 'lavfi',
 // '-i',
 // 'anullsrc',

 '-i',
 '-',

 '-f',
 'flv',
 '-c',
 'copy',
 `${process.env.TWITCH_STREAM_ADDRESS}`,
 '-f',
 'flv',
 '-c',
 'copy',
 `${process.env.YOUTUBE_STREAM_ADDRESS}`,
 // '-f',
 // 'flv',
 // '-c',
 // 'copy',
 // `${process.env.FACEBOOK_STREAM_ADDRESS}`,
 ])

 ffmpeg.on('close', (code, signal) => {
 console.log(
 'FFmpeg child process closed, code ' + code + ', signal ' + signal
 )
 ws.terminate()
 })

 ffmpeg.stdin.on('error', (e) => {
 console.log('FFmpeg STDIN Error', e)
 })

 ffmpeg.stderr.on('data', (data) => {
 console.log('FFmpeg STDERR:', data.toString())
 })

 ws.on('message', (msg) => {
 console.log('DATA', msg)
 ffmpeg.stdin.write(msg)
 })

 ws.on('close', (e) => {
 console.log('kill: SIGINT')
 ffmpeg.kill('SIGINT')
 })
})

const config = {
 rtmp: {
 port: 1935,
 chunk_size: 60000,
 gop_cache: true,
 ping: 30,
 ping_timeout: 60,
 },
 http: {
 port: 8000,
 allow_origin: '*',
 },
}

var nms = new NodeMediaServer(config)
nms.run()



Here is my frontend code that records the video/audio and sends to server :


import React, { useState, useEffect, useRef } from 'react'
import Navbar from '../../components/Navbar/Navbar'
import './Dashboard.css'

const CAPTURE_OPTIONS = {
 audio: true,
 video: true,
}

function Dashboard() {
 const [mute, setMute] = useState(false)
 const videoRef = useRef()
 const ws = useRef()
 const mediaStream = useUserMedia(CAPTURE_OPTIONS)

 let liveStream
 let liveStreamRecorder

 if (mediaStream && videoRef.current && !videoRef.current.srcObject) {
 videoRef.current.srcObject = mediaStream
 }

 const handleCanPlay = () => {
 videoRef.current.play()
 }

 useEffect(() => {
 ws.current = new WebSocket(
 window.location.protocol.replace('http', 'ws') +
 '//' + // http: -> ws:, https: -> wss:
 'localhost:3000'
 )

 ws.current.onopen = () => {
 console.log('WebSocket Open')
 }

 return () => {
 ws.current.close()
 }
 }, [])

 const startStream = () => {
 liveStream = videoRef.current.captureStream(30) // 30 FPS
 liveStreamRecorder = new MediaRecorder(liveStream, {
 mimeType: 'video/webm;codecs=h264',
 videoBitsPerSecond: 3 * 1024 * 1024,
 })
 liveStreamRecorder.ondataavailable = (e) => {
 ws.current.send(e.data)
 console.log('send data', e.data)
 }
 // Start recording, and dump data every second
 liveStreamRecorder.start(1000)
 }

 const stopStream = () => {
 liveStreamRecorder.stop()
 ws.current.close()
 }

 const toggleMute = () => {
 setMute(!mute)
 }

 return (
 <>
 <navbar></navbar>
 <div style="{{" classname="'main'">
 <div>
 
 </div>
 <div classname="'button-container'">
 <button>Go Live</button>
 <button>Stop Recording</button>
 <button>Share Screen</button>
 <button>Mute</button>
 </div>
 </div>
 >
 )
}

const useUserMedia = (requestedMedia) => {
 const [mediaStream, setMediaStream] = useState(null)

 useEffect(() => {
 async function enableStream() {
 try {
 const stream = await navigator.mediaDevices.getUserMedia(requestedMedia)
 setMediaStream(stream)
 } catch (err) {
 console.log(err)
 }
 }

 if (!mediaStream) {
 enableStream()
 } else {
 return function cleanup() {
 mediaStream.getVideoTracks().forEach((track) => {
 track.stop()
 })
 }
 }
 }, [mediaStream, requestedMedia])

 return mediaStream
}

export default Dashboard