
Recherche avancée
Autres articles (22)
-
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...) -
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...) -
Automated installation script of MediaSPIP
25 avril 2011, parTo overcome the difficulties mainly due to the installation of server side software dependencies, an "all-in-one" installation script written in bash was created to facilitate this step on a server with a compatible Linux distribution.
You must have access to your server via SSH and a root account to use it, which will install the dependencies. Contact your provider if you do not have that.
The documentation of the use of this installation script is available here.
The code of this (...)
Sur d’autres sites (2484)
-
MP4 to DASH (bash script)
13 mars 2017, par francesco.galganiI have a web site in which users can upload video files. I want to stream all of them using DASH to obtain an adaptive bitrate streaming. So I wrote a bash script (to run by cron) that converts all mp4 files to DASH, but it doesn’t work properly : what is wrong ?
For example, using the following script, I obtained :
https://www.informatica-libera.net/dash_faq/stream.mpdIt validates, but it doesn’t play. I tested it on :
http://dash-mse-test.appspot.com/dash-player.html?url=https%3A%2F%2Fwww.informatica-libera.net%2Fdash_faq%2Fstream.mpd&autoplay=on&adapt=auto&flavor=Thank you for any help.
The code :#!/bin/bash
# THIS SCRIPT CONVERTS EVERY MP4 (IN THE CURRENT FOLDER AND SUBFOLDER)
# TO A MULTI-BITRATE VIDEO IN MP4-DASH
# For each file "videoname.mp4" it creates a folder "dash_videoname"
# containing a dash manifest file "stream.mpd" and subfolders containing
# video segments.
# mp4dash documentation and download: https://www.bento4.com/developers/dash/
MYDIR=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
SAVEDIR=$(pwd)
# Check programs
if [ -z "$(which ffmpeg)" ]; then
echo "Error: ffmpeg is not installed"
exit 1
fi
if [ -z "$(which mp4dash)" ]; then
echo "Error: mp4dash is not installed"
exit 1
fi
cd "$MYDIR"
TARGET_FILES=$(find ./ -type f -name "*.mp4")
for f in $TARGET_FILES
do
f=$(basename "$f") # fullname of the file
f="${f%.*}" # name without extension
if [ ! -d "dash_${f}" ]; then
echo "Converting \"$f\" to multi-bitrate video in MPEG-DASH"
ffmpeg -y -i "${f}.mp4" -c:a libfdk_aac -ac 2 -ab 128k -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 1500k -vf "scale=-2:720" -f mp4 -pass 1 -y /dev/null
ffmpeg -y -i "${f}.mp4" -c:a libfdk_aac -ac 2 -ab 128k -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 1500k -vf "scale=-2:720" -f mp4 -pass 2 "${f}_1500.mp4"
ffmpeg -y -i "${f}.mp4" -c:a libfdk_aac -ac 2 -ab 128k -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 800k -vf "scale=-2:540" -f mp4 -pass 1 -y /dev/null
ffmpeg -y -i "${f}.mp4" -c:a libfdk_aac -ac 2 -ab 128k -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 800k -vf "scale=-2:540" -f mp4 -pass 2 "${f}_800.mp4"
ffmpeg -y -i "${f}.mp4" -c:a libfdk_aac -ac 2 -ab 128k -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 400k -vf "scale=-2:360" -f mp4 -pass 1 -y /dev/null
ffmpeg -y -i "${f}.mp4" -c:a libfdk_aac -ac 2 -ab 128k -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 400k -vf "scale=-2:360" -f mp4 -pass 2 "${f}_400.mp4"
ffmpeg -y -i "${f}.mp4" -c:a libfdk_aac -ac 2 -ab 128k -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 200k -vf "scale=-2:180" -f mp4 -pass 1 -y /dev/null
ffmpeg -y -i "${f}.mp4" -c:a libfdk_aac -ac 2 -ab 128k -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 200k -vf "scale=-2:180" -f mp4 -pass 2 "${f}_200.mp4"
rm -f ffmpeg*log*
mp4fragment "${f}_1500.mp4" "${f}_1500_fragmented.mp4"
mp4fragment "${f}_800.mp4" "${f}_800_fragmented.mp4"
mp4fragment "${f}_400.mp4" "${f}_400_fragmented.mp4"
mp4fragment "${f}_200.mp4" "${f}_200_fragmented.mp4"
rm -f "${f}_1500.mp4" "${f}_800.mp4" "${f}_400.mp4" "${f}_200.mp4"
mp4dash -v -o "dash_${f}" "${f}_1500_fragmented.mp4" "${f}_800_fragmented.mp4" "${f}_400_fragmented.mp4" "${f}_200_fragmented.mp4"
rm -f "${f}_1500_fragmented.mp4" "${f}_800_fragmented.mp4" "${f}_400_fragmented.mp4" "${f}_200_fragmented.mp4"
fi
done
cd "$SAVEDIR" -
ffmpeg with "-pattern_type glob" and variable in bash script
20 juin 2019, par KlausPeterI’m trying to let ffmpeg make a video of all pictures in a directory using the -pattern_type glob switch and "/foo/bar/*.jpg". This works well, if I execute the command manually für just one directory. For example :
ffmpeg -framerate 35 -pattern_type glob -i '/root/webcam_test/2018-07-21/*.jpg' -vf scale=1280:-1 -c -c:v libx264 -pix_fmt yuv420p /root/clips/out01_cut.mp4
However, if I do it in a bash script and set the path via a variable, according to ffmpegs output, the variable gets substituted correctly, but ffmpeg states that
’/root/webcam_test/2018-07-21/*.jpg’ : No such file or directory
The part of the script looks like this :
for D in `find /root/webcam_test/ -type d`
do
[...]
cmd="ffmpeg -framerate 35 -pattern_type glob -i '$D/*.jpg' -vf scale=1280:-1 -c -c:v libx264 -pix_fm t yuv420p /root/clips/$d_cut.mp4"
echo $cmd
[...]
doneDoes anyone know how to make ffmpeg do its wildcard interpretation even if the path is constructed by a script and not just try to plainly use the given path ?
Best regards and thanks in advance -
Running a py script in the Cloud
12 janvier 2018, par Anay BoseI’m new to Google’s cloud & Virtual Machine(VM) instances, and I need some clarifications on a couple of points. I have a python script ; it imports a long range of functions. I need to run those functions in parallel. I’m using multiprocessing and Process, not threads. These functions are basically image and media processors, and they use many other tools like FFMPEG, imagemagick and Avisynth in addition to a wide range of python modules, including moviepy. Now, I would like to run some 50 functions in parallel assigning a CPU for each process. Images, media and avi files are stored in seperate folders. I’m on Windows7 Core-i7 machine. So, need cloud computing power.
Now, my question can I run such a python script/app in the cloud that requires a very complicated file system and non-python tools i.e. ffmpeg, avisynth and avi files ?
Can Google VMs emulate my local machine and empower me with more cores and memory to run such a program ? if not, then what are my options ? Is their any tutorials that I can follow ? I need your suggestions. I have given below an example script and some codes to help facilitate your understanding about my situation.
from __future__ import unicode_literals
import youtube_dl
import os
import time
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from multiprocessing import Process
from utils import *
from clip31 import VIDEO31
from clip32 import VIDEO32
from clip189 import VIDEO189
from clip16 import VIDEO16
from clip39 import VIDEO39
if __name__== '__main__':
# 1. CALLING A FUNCTION
folder = "bodyforce3\\16"
serial = "16"
images = get_filepaths("../16")
videos = get_filepaths("12__media")
pngs = get_filepaths("../pngs")
Process(target=VIDEO192, args=(folder, serial, color1, color2, color3, images, videos)).start()
# 2. CALLING A FUNCTION
folder = "bodyforce3\\20"
serial = "20"
images = get_filepaths("../20")
videos = get_filepaths("18__media")
Process(target=VIDEO32, args=(folder, serial, color1, color2, color3, images, videos)).start()
# 3. CALLING A FUNCTION
folder = "bodyforce3\\14"
serial = "14"
images = get_filepaths("../14")
videos = get_filepaths("16__media")
Process(target=VIDEO91, args=(folder, serial, color1, color2, color3, images, videos)).start()I copy avi files in functions like this :
src = "clip50_files"
src_files = os.listdir(src)
for file_name in src_files:
full_file_name = os.path.join(src, file_name)
if (os.path.isfile(full_file_name)):
shutil.copy(full_file_name, folder)I call ffmpeg commands like this, and they are included within py functions.
###########################
#### FFMPEG OPERATIONS ####
###########################
print "Starting FFMPEG operations ..."
if os.path.isfile(os.path.join(folder, "bounce-(3).avi")):
os.remove(os.path.join(folder, "bounce-(3).avi"))
infile = folder + "/bounce-(3).avs"
outfile = folder + "/bounce-(3).avi"
codec = "rawvideo"
pix_fmt = "bgra"
try:
subprocess.call(["ffmpeg",
"-i" ,infile,
"-c:v" ,codec,
"-pix_fmt", pix_fmt,
outfile],
stdout=open(os.devnull, 'w'),
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
#except subprocess.CalledProcessError as e:
sys.exit(e.output)
except OSError as e:
sys.exit(e.strerror)
print "FFMPEG operations ended"