
Recherche avancée
Médias (3)
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
-
GetID3 - Boutons supplémentaires
9 avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
-
Collections - Formulaire de création rapide
19 février 2013, par
Mis à jour : Février 2013
Langue : français
Type : Image
Autres articles (61)
-
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...) -
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs
Sur d’autres sites (11878)
-
PHP exec command running and waiting to finish on dev machine, but exiting without completing on production
2 juin 2017, par HirveshI’m trying to run a command within PHP to resize a video using ffmpeg. My command is as follows :
$videoFilename = storage_path()."/app/gifrecipes/sample.mp4";
$videoFilename2 = storage_path()."/app/gifrecipes/sample2.mp4";
exec("ffmpeg -y -i " . $videoFilename . " -s 640x640 -aspect 1:1 -r 24000/1001 -b 1550k -bt 1792k -vcodec libx264 -pass 1 -preset ultrafast -an " . $videoFilename2 . " && ffmpeg -y -i " . $videoFilename . " -s 640x640 -aspect 1:1 -r 24000/1001 -b 1550k -bt 1792k -vcodec libx264 -pass 2 -preset ultrafast -acodec libfaac -ac 2 -ab 128k " . $videoFilename2);On my development server (with same PHP and FFMPEG version as production) the command converts the video and finishes, whereas, on production, it just creates and empty (0 bytes) video file and exits. When I run the command from command line on the production server, video converts fine, it’s just when ran from php which causes the issue.
Anybody can guide me as to why this is happening ?
Edit :
Similar threads :
ffmpeg video conversion creates empty file when using php’s exec()
-
WriteToUDP only works on same machine
26 mai 2017, par Anderson Scouto da SilvaThis script is intended to capture the output of ffmpeg and write to a UDP address.
It works correctly as I open the VLC 233.10.10.13:1234 and runs normally, but out of this computer the stream is not played, it’s as if the stream does not exit from the machine to the multicast network, but on the same PC it works normally, I run the script go and open the VLC to run, it works perfectly.
To take the doubts that might be some problem in the interfaces, I made a VLC stream by capturing 233.1.1.13:1234 and exiting to 233.10.10.13:1234 and I can run anywhere outside the machine where VLC is, for example, in another VLC on another machine. It just does not work in the script I wrote on go.
Can anyone help ?
package main
import (
"os/exec"
"io"
"strings"
"net"
"net/url"
"os"
"github.com/juju/loggo"
)
const (
BUFFER = 40 * 1024
DEBUG = true
)
func verificaErro(e error) {
if e != nil {
logger.Errorf(e.Error())
}
}
var logger loggo.Logger
func main() {
initLogger()
dir, _ := os.Getwd()
// conexão UDP
conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4zero, Port: 0})
verificaErro(err)
err = conn.SetWriteBuffer(BUFFER)
verificaErro(err)
inputSource := dir + "/in/teste-4k.mp4"
inputSource = normalizeInputSource(inputSource)
inputCodec := probeInputCodec(inputSource)
outputCodec := probeOutputCodec(inputCodec)
cmdName := "ffmpeg"
argsPipe1 := []string{
"-hide_banner",
"-loglevel", "panic",
"-re",
"-i",
inputSource,
"-preset",
"superfast",
"-c:v",
inputCodec,
"-crf",
"0",
"-c",
"copy",
"-f", outputCodec, "pipe:1",
}
cmdPipe1 := exec.Command(cmdName, argsPipe1...)
logger.Debugf(strings.Join(argsPipe1, " "))
stdoutPipe1, err := cmdPipe1.StdoutPipe()
verificaErro(err)
err2 := cmdPipe1.Start()
verificaErro(err2)
chunk := make([]byte, BUFFER)
for {
nr, err5 := stdoutPipe1.Read(chunk)
logger.Debugf("Lido %d bytes\n", nr)
if nr > 0 {
validData := chunk[:nr]
nw, err6 := conn.WriteToUDP(validData, &net.UDPAddr{IP: net.IP{233, 10, 10, 13}, Port: 1234})
logger.Debugf("Escrito %d bytes\n", nw)
verificaErro(err6)
}
if err5 != nil {
// fim do arquivo
if err5 == io.EOF {
break
}
logger.Errorf("Erro = %v\n", err5)
continue
}
}
}
func probeInputCodec(input string) string {
cmdName := "ffprobe"
args := []string{
"-v", "error",
"-select_streams", "v:0", "-show_entries",
"stream=codec_name", "-of", "default=noprint_wrappers=1:nokey=1",
input,
}
out, err := exec.Command(cmdName, args...).Output()
verificaErro(err)
return strings.TrimSpace(string(out))
}
func probeOutputCodec(inputCode string) string {
switch inputCode {
case "h264":
return "mpegts"
case "mpeg4":
return "mpeg4"
}
return "mpegts"
}
func normalizeInputSource(inputSource string) (string) {
isFile := false
if _, err := os.Stat(inputSource); err == nil {
isFile = true
}
if isFile {
return inputSource
}
u, err := url.Parse(inputSource)
verificaErro(err)
if u.Scheme != "udp" && u.Scheme != "tcp" {
errorMessage := "A entrada deve ser uma URL UDP/TCP ou um arquivo existente"
logger.Errorf(errorMessage)
os.Exit(1)
}
q := u.Query()
if u.Scheme == "udp" {
q.Set("overrun_nonfatal", "1")
q.Set("fifo_size", "1000000")
q.Set("buffer_size", "26214400")
}
u.RawQuery = q.Encode()
return u.String()
}
func initLogger() {
logger = loggo.GetLogger(loggo.DefaultWriterName)
if DEBUG {
logger.SetLogLevel(loggo.DEBUG)
} else {
logger.SetLogLevel(loggo.ERROR)
}
} -
ffmpeg get machine readable output
15 mai 2017, par J.SI am trying to find a way to get FFmpeg to return a machine readable output. basically, I just want to know if video conversion was successfull.
I am calling FFmpeg from go code.
output, err := exec.Command("ffmpeg", "-i", source, "-vcodec", "h264", "-acodec", "aac", "-strict", "-2", destination).CombinedOutput()
The above code executes this command :
ffmpeg -i /tmp/pitchVideo-1494844705-102.mp4 -vcodec h264 -acodec aac -strict -2 /tmp/1494844705.mp4
I get the following output :
ffmpeg version 2.4.3-1ubuntu1~trusty6 Copyright (c) 2000-2014 the FFmpeg developers
built on Nov 22 2014 17:07:19 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --prefix=/usr --extra-version='1ubuntu1~trusty6' --build-suffix=-ffmpeg --toolchain=hardened --extra-cflags= --extra-cxxflags= --libdir=/usr/lib/x86_64-linux-gnu --shlibdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-fontconfig --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --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-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-opengl --enable-x11grab --enable-libxvid --enable-libx265 --enable-libdc1394 --enable-libiec61883 --enable-libzvbi --enable-libzmq --enable-frei0r --enable-libx264 --enable-libsoxr --enable-openal --enable-libopencv
libavutil 54. 7.100 / 54. 7.100
libavcodec 56. 1.100 / 56. 1.100
libavformat 56. 4.101 / 56. 4.101
libavdevice 56. 0.100 / 56. 0.100
libavfilter 5. 1.100 / 5. 1.100
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 0.100 / 3. 0.100
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 0.100 / 53. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/pitchVideo-1494844705-102.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:39.28, start: 0.000000, bitrate: 2300 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480, 2231 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 64 kb/s (default)
Metadata:
handler_name : SoundHandler
[libx264 @ 0x1e12640] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX LZCNT
[libx264 @ 0x1e12640] profile High, level 3.0
[libx264 @ 0x1e12640] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - 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=1 lookahead_threads=1 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 '/tmp/new.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.4.101
Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480, q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc56.1.100 libx264
Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, mono, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc56.1.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
frame= 983 fps= 27 q=28.0 Lsize= 4134kB time=00:00:39.24 bitrate= 863.0kbits/s dup=1 drop=0
video:3542kB audio:565kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.646525%
[libx264 @ 0x1e12640] frame I:9 Avg QP:19.44 size: 9936
[libx264 @ 0x1e12640] frame P:664 Avg QP:23.58 size: 4839
[libx264 @ 0x1e12640] frame B:310 Avg QP:25.50 size: 1045
[libx264 @ 0x1e12640] consecutive B-frames: 56.0% 4.3% 5.2% 34.6%
[libx264 @ 0x1e12640] mb I I16..4: 33.9% 53.6% 12.5%
[libx264 @ 0x1e12640] mb P I16..4: 6.7% 10.2% 0.9% P16..4: 50.7% 8.3% 3.0% 0.0% 0.0% skip:20.2%
[libx264 @ 0x1e12640] mb B I16..4: 0.4% 0.4% 0.0% B16..8: 41.7% 1.4% 0.1% direct: 1.3% skip:54.7% L0:46.9% L1:50.4% BI: 2.8%
[libx264 @ 0x1e12640] 8x8 transform intra:56.8% inter:76.1%
[libx264 @ 0x1e12640] coded y,uvDC,uvAC intra: 37.0% 60.5% 13.9% inter: 17.8% 26.0% 0.3%
[libx264 @ 0x1e12640] i16 v,h,dc,p: 23% 35% 15% 27%
[libx264 @ 0x1e12640] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 27% 21% 4% 4% 4% 4% 5% 5%
[libx264 @ 0x1e12640] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 26% 14% 4% 5% 5% 5% 5% 4%
[libx264 @ 0x1e12640] i8c dc,h,v,p: 53% 22% 19% 6%
[libx264 @ 0x1e12640] Weighted P-Frames: Y:8.7% UV:3.5%
[libx264 @ 0x1e12640] ref P L0: 73.8% 15.7% 8.4% 2.0% 0.1%
[libx264 @ 0x1e12640] ref B L0: 92.9% 6.2% 0.9%
[libx264 @ 0x1e12640] ref B L1: 96.1% 3.9%
[libx264 @ 0x1e12640] kb/s:737.84Edit 1 : Maybe I can just check if new video file was generated. But I don’t know if that is a dependable way to do it.