
Recherche avancée
Autres articles (100)
-
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 (...) -
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 (...) -
Organiser par catégorie
17 mai 2013, parDans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)
Sur d’autres sites (6096)
-
A ffmpeg comman canwork in cmd but not in Python using subprocess.call() or os.system()
6 juin 2018, par StarryskyI wanna transfer a .mp3 to .wav. This is my command :
ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav
It worked well in cmd
C:\Users\starrysky\Documents\GitHub\bing_pic\html>ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav
ffmpeg version N-86482-gbc40674 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.1.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
libavutil 55. 66.100 / 55. 66.100
libavcodec 57. 99.100 / 57. 99.100
libavformat 57. 73.100 / 57. 73.100
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 92.100 / 6. 92.100
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Input #0, mp3, from 'a.mp3':
Metadata:
encoder : Lavf54.6.100
Duration: 00:00:01.87, start: 0.000000, bitrate: 8 kb/s
Stream #0:0: Audio: mp3, 8000 Hz, mono, s16p, 8 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to 'a.wav':
Metadata:
ISFT : Lavf57.73.100
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s
Metadata:
encoder : Lavc57.99.100 pcm_s16le
size= 59kB time=00:00:01.87 bitrate= 256.3kbits/s speed= 187x
video:0kB audio:58kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.130208%but when I moved it into my python program, something strange happened.
>>> C:\Users\starrysky\Documents\GitHub\bing_pic\html\
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
�����������
1 Command 'ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav' returned non-zero exit status 1.
文件错误啊,亲
[WinError 2] 系统找不到指定的文件。: 'a.wav'This is part of my python code :
@bot.register(wife, RECORDING)
def translate_sound(msg):
msg.get_file(save_path='a.mp3')
path = os.path.abspath('.')+'\\'
print(path)
try:
subprocess.check_call('ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav', shell=True)
# ''
except Exception as e:
print(1, e)
wav_to_text('a.wav')
try:
os.remove('a.wav')
except Exception as e:
print(e)# 调用百度语音识别API
def get_token():
URL = 'http://openapi.baidu.com/oauth/2.0/token'
_params = urllib.parse.urlencode({'grant_type': b'client_credentials',
'client_id': b''
'client_secret': b''})
_res = urllib.request.Request(URL, _params.encode())
_response = urllib.request.urlopen(_res)
_data = _response.read()
_data = json.loads(_data)
return _data['access_token']
def wav_to_text(wav_file):
try:
wav_file = open(wav_file, 'rb')
except IOError:
print('文件错误啊,亲')
return
wav_file = wave.open(wav_file)
n_frames = wav_file.getnframes()
print('n_frames ', n_frames)
frame_rate = wav_file.getframerate()
print("frame_rate ", frame_rate)
if n_frames == 1 or frame_rate not in (8000, 16000):
print('不符合格式')
return
audio = wav_file.readframes(n_frames)
seconds = n_frames/frame_rate+1
minute = int(seconds/60 + 1)
for i in range(0, minute):
sub_audio = audio[i*60*frame_rate:(i+1)*60*frame_rate]
base_data = base64.b64encode(sub_audio)
data = {"format": "wav",
"token": get_token(),
"len": len(sub_audio),
"rate": frame_rate,
"speech": base_data.decode(),
"cuid": "B8-AC-6F-2D-7A-94",
"channel": 1}
data = json.dumps(data)
res = urllib.request.Request('http://vop.baidu.com/server_api',
data.encode(),
{'content-type': 'application/json'})
response = urllib.request.urlopen(res)
res_data = json.loads(response.read())
try:
print(res_data['result'][0])
except Exception as e:
print(e)What happened ?
-
ffmpeg failed to call avcodec_send_packet
23 juin 2017, par GizakWindows 10 x64,
ffmpeg : 3.1, prebuilt dllsAbsolute beginner here.
I was trying out a very basic case to decode frames from a video file but desperately failed at every attempts. The final code snippet looks like this :
#define __STDC_CONSTANT_MACROS
extern "C" {
#include<libavutil></libavutil>avutil.h>
#include<libavutil></libavutil>imgutils.h>
#include <libavformat></libavformat>avformat.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <libswscale></libswscale>swscale.h>
}
#include <iostream>
int main(int argc, char **argv) {
AVFormatContext* ctx_format = nullptr;
AVCodecContext* ctx_codec = nullptr;
AVCodec* codec = nullptr;
AVFrame* frame = av_frame_alloc();
int stream_idx;
SwsContext* ctx_sws = nullptr;
const char* fin = argv[1];
AVStream *vid_stream = nullptr;
AVPacket* pkt = av_packet_alloc();
av_register_all();
if (int ret = avformat_open_input(&ctx_format, fin, nullptr, nullptr) != 0) {
std::cout << 1 << std::endl;
return ret;
}
if (avformat_find_stream_info(ctx_format, nullptr) < 0) {
std::cout << 2 << std::endl;
return -1; // Couldn't find stream information
}
av_dump_format(ctx_format, 0, fin, false);
for (int i = 0; i < ctx_format->nb_streams; i++)
if (ctx_format->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
stream_idx = i;
vid_stream = ctx_format->streams[i];
break;
}
if (vid_stream == nullptr) {
std::cout << 4 << std::endl;
return -1;
}
codec = avcodec_find_decoder(vid_stream->codecpar->codec_id);
if (!codec) {
fprintf(stderr, "codec not found\n");
exit(1);
}
ctx_codec = avcodec_alloc_context3(codec);
if(avcodec_parameters_to_context(ctx_codec, vid_stream->codecpar)<0)
std::cout << 512;
if (avcodec_open2(ctx_codec, codec, nullptr)<0) {
std::cout << 5;
return -1;
}
//av_new_packet(pkt, pic_size);
while(av_read_frame(ctx_format, pkt) >= 0){
int ret = avcodec_send_packet(ctx_codec, pkt);
if (ret < 0 || ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
std::cout << "avcodec_send_packet: " << ret << std::endl;
break;
}
if (pkt->stream_index == stream_idx) {
while (ret >= 0) {
ret = avcodec_receive_frame(ctx_codec, frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
//std::cout << "avcodec_receive_frame: " << ret << std::endl;
break;
}
std::cout << "frame: " << ctx_codec->frame_number << std::endl;
}
}
av_packet_unref(pkt);
}
avformat_close_input(&ctx_format);
av_packet_unref(pkt);
avcodec_free_context(&ctx_codec);
avformat_free_context(ctx_format);
return 0;
}
</iostream>It basically leaves everything by its defaults and try to read packets and decode frames from them. The
avcodec_send_packet
always returned a negative value at the first or second round of calling in the while loop.Output for flv :
> .\streamer_test.exe .\SampleVideo_360x240_5mb.flv
Input #0, flv, from '.\SampleVideo_360x240_5mb.flv':
Metadata:
encoder : Lavf53.24.2
Duration: 00:00:53.32, start: 0.000000, bitrate: 787 kb/s
Stream #0:0: Audio: aac (LC), 48000 Hz, 5.1, fltp, 384 kb/s
Stream #0:1: Video: flv1, yuv420p, 320x240, 500 kb/s, 1k fps, 25 tbr, 1k tbn
frame: 1
[flv @ 000001545edb66c0] Bad picture start code
[flv @ 000001545edb66c0] header damaged
avcodec_send_packet: -1094995529Output for mp4 :
> .\streamer_test.exe .\SampleVideo_360x240_10mb.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '.\SampleVideo_360x240_10mb.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01T00:00:00.000000Z
encoder : Lavf53.24.2
Duration: 00:02:05.95, start: 0.000000, bitrate: 669 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 282 kb/s, 15 fps, 15 t
br, 15360 tbn, 30 tbc (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : SoundHandler
[h264 @ 000002e2446a6cc0] Invalid NAL unit size (17191968 > 1007).
[h264 @ 000002e2446a6cc0] Error splitting the input into NAL units.
avcodec_send_packet: -1094995529Output for mkv :
> .\streamer_test.exe .\SampleVideo_1280x720_2mb.mkv
Input #0, matroska,webm, from '.\SampleVideo_1280x720_2mb.mkv':
Metadata:
ENCODER : Lavf53.24.2
Duration: 00:00:10.65, bitrate: 1575 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 25 tbc (de
fault)
Stream #0:1: Audio: aac (LC), 48000 Hz, 5.1, fltp (default)
frame: 1
[mpeg4 @ 000001166798ede0] header damaged
avcodec_send_packet: -1So I guess there must be something wrong around
avcodec_send_packet
call but could not figured out what is missing. Any ideas about the causes ? Much appreciate your help ! -
FFmpeg (Thumbnail from video) works in command line, but not in PHP script
25 juin 2017, par Jun KimI looked at the similar questions, and the solutions there do not work in my case. Anyone has any idea ? I am trying to capture a thumbnail from a given video file.
Later, my goal is to capture a thumbnail from live streaming video file.
Below is my current set up.
Linux Ubuntu 16.04
PHP version 7.0
Nginx Version 1.10.3
FFmpeg Version FFmpeg 2.8.11
I installed FFmpeg through below commands in my Ubuntu server.
apt-get update
apt-get install ffmpegWhen I type the below command line in the terminal, it does the conversion fine.
ffmpeg -i /etc/nginx/html/test.mp4 -ss 00:00:01 -vframes 1 -vf scale=240:120 /etc/nginx/html/Share/ffmpeg/thumbnails/test.png;
In order to use it in php file, I confirmed the location of ffmpeg binaries by I typing in the terminal,
which ffmpeg
, and it returns/usr/bin/ffmpeg
I also gave permission to the directory by using
chmod 755
command line.Here is what I have in my ffmpeg.php file.
I included the full path to my ffmpeg as you can see.<?php
header("Content-Type: text/html;charset=UTF-8");
$ffmpeg = "/usr/bin/ffmpeg";
$videoFile="/etc/nginx/html/test.mp4";
$thumbnail= "/etc/nginx/html/Share/ffmpeg/thumbnails/thumbnail1.jpg";
$cmd = "$ffmpeg -i $videoFile -ss 00:00:01 -vframes 1 -vf scale=240:120 $thumbnail 2>&1 &";
$output = shell_exec($cmd);
echo "<pre>".$output."</pre>";
?>This returns the message like below.
ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --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-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/etc/nginx/html/Share/test.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf53.24.2
Duration: 00:00:06.40, start: 0.000000, bitrate: 1321 kb/s
Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 640x368 [SAR 1:1 DAR 40:23], 932 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : SoundHandler
[swscaler @ 0x1621be0] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '/etc/nginx/html/Share/ffmpeg/thumbnails/thumbnail1.jpg':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf56.40.101
Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 240x120 [SAR 20:23 DAR 40:23], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : VideoHandler
encoder : Lavc56.60.100 mjpeg
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[image2 @ 0x16165a0] Could not open file : /etc/nginx/html/Share/ffmpeg/thumbnails/thumbnail1.jpg
av_interleaved_write_frame(): Input/output error
frame= 1 fps=0.0 q=3.9 Lsize=N/A time=00:00:00.04 bitrate=N/A
video:8kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!UPDATED : I also gave permission to ffmpeg by chmod +x $(which ffmpeg)
I tried
php /etc/nginx/html/Share/ffmpeg/ffmpeg.php
in the terminal, and it also does conversion fine.libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/etc/nginx/html/Share/test.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
creation_time : 1970-01-01 00:00:00
encoder : Lavf53.24.2
Duration: 00:00:06.40, start: 0.000000, bitrate: 1321 kb/s
Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 640x368 [SAR 1:1 DAR 40:23], 932 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : SoundHandler
[swscaler @ 0x72dbe0] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '/etc/nginx/html/Share/ffmpeg/thumbnails/thumbnail.jpg':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf56.40.101
Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 240x120 [SAR 20:23 DAR 40:23], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name : VideoHandler
encoder : Lavc56.60.100 mjpeg
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame= 1 fps=0.0 q=3.9 Lsize=N/A time=00:00:00.04 bitrate=N/A
video:8kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown