
Recherche avancée
Autres articles (97)
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Configuration spécifique pour PHP5
4 février 2011, parPHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
Modules spécifiques
Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...) -
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 (8115)
-
Anyway to get current playtime of a song ?
2 décembre 2019, par Blue LightningSo this is the basic voice that I’m currently using to play music through my bot. I’m streaming the audio (using the stream async function) opposed to downloading it local. Anyway I can get the current playtime of the song that is being played ?
So whenever someone plays a song, they can, whenever they want, see how much of the song they played through already.
import asyncio
import discord
import youtube_dl
from discord.ext import commands
# Suppress noise about console usage from errors
youtube_dl.utils.bug_reports_message = lambda: ''
ytdl_format_options = {
'format': 'bestaudio/best',
'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
'restrictfilenames': True,
'noplaylist': True,
'nocheckcertificate': True,
'ignoreerrors': False,
'logtostderr': False,
'quiet': True,
'no_warnings': True,
'default_search': 'auto',
'source_address': '0.0.0.0'
}
ffmpeg_options = {
'options': '-vn'
}
ytdl = youtube_dl.YoutubeDL(ytdl_format_options)
class YTDLSource(discord.PCMVolumeTransformer):
def __init__(self, source, *, data, volume=0.5):
super().__init__(source, volume)
self.data = data
self.title = data.get('title')
self.url = data.get('url')
@classmethod
async def from_url(cls, url, *, loop=None, stream=False):
loop = loop or asyncio.get_event_loop()
data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))
if 'entries' in data:
# take first item from a playlist
data = data['entries'][0]
filename = data['url'] if stream else ytdl.prepare_filename(data)
return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)
class Music(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def join(self, ctx, *, channel: discord.VoiceChannel):
"""Joins a voice channel"""
if ctx.voice_client is not None:
return await ctx.voice_client.move_to(channel)
await channel.connect()
@commands.command()
async def stream(self, ctx, *, url):
"""Streams from a url (same as yt, but doesn't predownload)"""
async with ctx.typing():
player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True)
ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
await ctx.send('Now playing: {}'.format(player.title))
@commands.command()
async def volume(self, ctx, volume: int):
"""Changes the player's volume"""
if ctx.voice_client is None:
return await ctx.send("Not connected to a voice channel.")
ctx.voice_client.source.volume = volume / 100
await ctx.send("Changed volume to {}%".format(volume))
@commands.command()
async def stop(self, ctx):
"""Stops and disconnects the bot from voice"""
await ctx.voice_client.disconnect()
@play.before_invoke
@yt.before_invoke
@stream.before_invoke
async def ensure_voice(self, ctx):
if ctx.voice_client is None:
if ctx.author.voice:
await ctx.author.voice.channel.connect()
else:
await ctx.send("You are not connected to a voice channel.")
raise commands.CommandError("Author not connected to a voice channel.")
elif ctx.voice_client.is_playing():
ctx.voice_client.stop()
bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"),
description='Relatively simple music bot example')
@bot.event
async def on_ready():
print('Logged in as {0} ({0.id})'.format(bot.user))
print('------')
bot.add_cog(Music(bot))
bot.run('token') -
How do I get duration of an In Memory Video in Python / Django ?
21 novembre 2019, par Lucas TononSo I was successfully using the following code to get the duration of a saved video in Django.
def get_video_length(file_path):
command = [
'ffprobe',
'-v',
'error',
'-show_entries',
'format=duration',
'-of',
'default=noprint_wrappers=1:nokey=1',
file_path
]
try:
output = check_output( command, stderr=STDOUT ).decode()
except CalledProcessError as e:
output = e.output.decode()
return outputBut now I need to get the duration of an uploaded file before saving it.
I have a serializer with a FileField and on validate method I should check the video duration.
For instance :class VideoSerializer(serializers.Serializer):
video = serializers.FileField(required=True, validators=[validate_media_extension, validate_video_duration])Then on validate_video_duration I needed to call some method like get_video_length, but I need an alternative to get the duration from the video in memory. The object that I have is an instance of InMemoryUploadedFile (https://docs.djangoproject.com/en/2.2/_modules/django/core/files/uploadedfile/)
-
Prevent FFmpeg from closing when a named pipe has been read completely
21 octobre 2019, par Werther BerselliI’m doing a C++ application for a university project that takes a video file (e.g. matroska) and using FFmpeg (embedding commands inside
std::system()
instructions) apply these steps :-
Extract chunks of frames (e.g. 10 seconds per chunk) and chunks of .aac audio
-
Apply some filters to frames
-
Encode video chunk and audio chunk with x264 and send it to a listening client using RTSP. This step is achieved using two named pipes, one for video and one for audio.
-
Receive the stream into another process and play it using ffplay (on localhost or lan).
I need to divide my stream in chunks because I need eventually to satisfy real-time constraints, so I can’t apply filters before to my entire input video file and only then start streaming to client.
My primary problem here is that once FFmpeg has emptied the two pipes, it close ; but other chunks of video and audio have still to be piped and streamed. I need FFmpeg to listen to the pipes waiting for new data.In bash I achieved this with the following commands.
Start to listen in a prompt for a RTSP stream :
ffplay -rtsp_flags listen rtsp://127.0.0.1@127.0.0.1:8090
Create a video named pipe and an audio named pipe :
mkfifo video_pipe
mkfifo audio_pipeUse this command to prevent FFmpeg to close when video pipe is emptied :
exec 7<>video_pipe
(it is sufficient to apply it to the pipe video and neither will the audio pipe give problems)
Activate FFmpeg command
ffmpeg -probesize 2147483647 -re -s 1280x720 -pix_fmt rgb24 -i pipe:0 -vsync 0 -i audio_pipe -r 25 -vcodec libx264 -crf 23 -preset ultrafast -f rtsp -rtsp_transport tcp rtsp://127.0.0.1@127.0.0.1:8090 < video_pipe
And then feed the pipes in another prompt :
cat audiochunk.aac > audio_pipe & cat frame*.bmp > video_pipe
These commands work well using 3 prompts, then I tried them in C++ embedding commands in
std::system()
instructions (using different threads) ; everything works, but once ffmpeg command empty the video pipe (finishing first chunk), it closes.
exec
command seems to be uneffective here.
How could I prevent FFmpeg from closing ?Two days struggling on that problem, viewing all possible internet solution. I hope I was clear despite a great headache, thanks for your suggestions in advance.
UPDATE :
My C++ code is something like this ; I putted it in a single function on a single thread, but it doesn’t change it’s behaviour.
I’m on Ubuntu 18.04.2void CameraThread::ffmpegJob()
{
std::string strvideo_length, command, timing;
long video_length, begin_chunk, end_chunk;
int begin_h, begin_m, begin_s, end_h, end_m, end_s;
command = "ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 " + Configurations::file_name;
strvideo_length = execCmd(command.c_str());
strvideo_length.pop_back(); // remove \n character
video_length = strToPositiveDigit(strvideo_length);
if(video_length == -1)
{
std::cout << "Invalid input file";
return;
}
std::system("bash -c \"rm mst-temp/mst_video_pipe\"");
std::system("bash -c \"rm mst-temp/mst_audio_pipe\"");
std::system("bash -c \"mkfifo mst-temp/mst_video_pipe\"");
std::system("bash -c \"mkfifo mst-temp/mst_audio_pipe\"");
// Keep video pipe opened
std::system("bash -c \"exec 7<>mst-temp/mst_video_pipe\"");
std::string rtsp_url = "rtsp://" + Configurations::my_own_used_ip + "@" + Configurations::client_ip +
":" + std::to_string(Configurations::port + 1);
command = "ffmpeg -probesize 2147483647 -re -s 1280x720 -pix_fmt rgb24 -i pipe:0 "
"-i mst-temp/mst_audio_pipe -r 25 -vcodec libx264 -crf 23 -preset ultrafast -f rtsp "
"-rtsp_transport tcp " + rtsp_url + " < mst-temp/mst_video_pipe &"; // Using & to continue without block on command
std::system(command.c_str());
begin_chunk = -1 * VIDEO_CHUNK;
end_chunk = 0;
// Extract the complete audio track
command = "bash -c \"ffmpeg -i " + Configurations::file_name + " -vn mst-temp/audio/complete.aac -y\"";
std::system(command.c_str());
while(true)
{
// Define the actual video chunk (in seconds) to use, if EOF is reached, exit
begin_chunk += (end_chunk - begin_chunk);
if(begin_chunk == video_length)
break;
if(end_chunk + VIDEO_CHUNK <= video_length)
end_chunk += VIDEO_CHUNK;
else
end_chunk += (video_length - end_chunk);
// Set begin and end H, M, S variables
begin_h = static_cast<int>(begin_chunk / 3600);
begin_chunk -= (begin_h * 3600);
begin_m = static_cast<int>(begin_chunk / 60);
begin_chunk -= (begin_m * 60);
begin_s = static_cast<int>(begin_chunk);
end_h = static_cast<int>(end_chunk / 3600);
end_chunk -= (end_h * 3600);
end_m = static_cast<int>(end_chunk / 60);
end_chunk -= (end_m * 60);
end_s = static_cast<int>(end_chunk);
// Extract bmp frames and audio from video chunk
// Extract frames
timing = " -ss " + std::to_string(begin_h) + ":" + std::to_string(begin_m) +
":" + std::to_string(begin_s) + " -to " + std::to_string(end_h) +
":" + std::to_string(end_m) + ":" + std::to_string(end_s);
command = "bash -c \"ffmpeg -i " + Configurations::file_name + timing +
" -compression_algo raw -pix_fmt rgb24 mst-temp/frames/output%03d.bmp\"";
std::system(command.c_str());
// Extract audio
command = "bash -c \"ffmpeg -i mst-temp/audio/complete.aac" + timing +
" -vn mst-temp/audio/audiochunk.aac -y\"";
std::system(command.c_str());
// Apply elaborations on audio and frames.........................
// Write modified audio and frames to streaming pipes
command = "bash -c \"cat mst-temp/audio/audiochunk.aac > mst-temp/mst_audio_pipe & "
"cat mst-temp/frames/output*.bmp > mst-temp/mst_video_pipe\"";
std::system(command.c_str());
}
}
</int></int></int></int></int></int> -