
Recherche avancée
Médias (1)
-
La conservation du net art au musée. Les stratégies à l’œuvre
26 mai 2011
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (52)
-
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
-
List of compatible distributions
26 avril 2011, parThe table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...) -
Contribute to translation
13 avril 2011You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
MediaSPIP is currently available in French and English (...)
Sur d’autres sites (6917)
-
Handling correctly the ffmpeg & ffprobe with php
29 septembre 2014, par coccoHandling correctly the ffmpeg & ffprobe with php
maybe not relevant final goals :
- upload clip with ajax
- get ajax info from
ffprobe
using php as json executingffprobe
once only (noffmpeg
) - handle all calculations with javascript
- maybe an extra php script tool that can create gifs, extract frames(thumbs), or a video grid preview
- when rdy ajax the conversion info to the final php conversion script executing ffmpeg once only (just the final ffmpeg string.).
I’m trying to write my own ffmpeg local web video editor that converts all formats to mp4 automatically. As mp4 is the most compatible container now and the h264+aac/+ac3 is also one of the best compressions. I also want to be able to cut, crop, resize, remove streams, add streams and more. I’m stuck on some simple problems :
1. HOW TO GET THE INFO ?
I’m using ffprobe to get the file information as json with the following command :
ffprobe -v quiet -print_format json -show_format -show_streams -show_packets '.$video
this gives you a lot of information, but some relevant stuff is not always present. I need the duration (in milliseconds),the fps (as a float) and the total frames (as an integer).
i know that these values can sometimes be found inside this array :
format.duration //Total duration
streams[0].duration //Video duration
streams[1].duration //Audio duration
streams[0].avg_frame_rate //Average framerate
streams[0].r_frame_rate //Video framerate
streams[0].nb_frames //Total framesbut most of the time
nb_frames
is missing, alsoavg_frame_rate
differs fromr_frame_rate
, which is also not always available.I know that i could use multiple commands to increase the chance to get the correct values.. but srsly ???
//fps
ffmpeg -i INPUT 2>&1 | sed -n "s/.*, \(.*\) fp.*/\1/p"
//duration
ffmpeg -i INPUT 2>&1 | awk '/Duration/ {split($2,a,":");print a[1]*3600+a[2]*60+a[3]}'
//frames
ffmpeg -i INPUT -vcodec copy -f rawvideo -y /dev/null 2>&1 | tr ^M '\n' | awk '/^frame=/ {print $2}'|tail -n 1I don’t want to execute ffmpeg 3 times to get this information ; I’d prefer to just use ffprobe.
So... is there an elegant way to get the extra info that is not always present inside the ffprobe output (fps, frames, duration) ???
In the preview i want to be able to jump correctly to a specific frame (NOT TIME). if the above parameters are aviable i can do that using this command.
ffmpeg -i INPUT -vf 'select=gte(n\,FRAMENUMBER)' -vframes 1 -f image2 OUTPUT
using the above command by setting the framenumber to the last frame always returns a black frame.
if there are 50 frames (for example) the range is 1-50 — correct ? Frame 50 is black, frame 1 is ok, frame 0 returns an error...
2. WHILE READING THE LOG HOW TO SKIP ERRORS AND DETERMINE IF THE CONVERSION IS FINISHED ?
I’m able to upload one single video per time (per page) and i can read the current progress from the ffmpeg generated output log until i don’t close the page. more control/multiple conversions would be nice.
i’m reading the last line of the log with a custom tail function but as this is a log that also includes errors i don’t always get a nice line containing the desidered values. btw to check if the progress is complete i check if the last line CONTAINS the WORD
frame
....How can i find out when the conversion progress is finished ?
maybe a way to delete the log with ffmpeg command ??And skip/log the errors ??
i’m using server sent events to read the log...
here is the php code<?php
setlocale(LC_CTYPE, "en_US.UTF-8");
function tailCustom($filepath,$lines=1,$adaptive=true){
// a custom function to get the last line of a textfile.
}
function send($data){
echo "id: ".time().PHP_EOL;
echo "data: ".$data.PHP_EOL;
echo PHP_EOL;
ob_flush();
flush();
}
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
while(true){
send(tailCustom($_GET['log'].".log"));
sleep(1);
}
?>And here the SSE js
function startSSE(fn){
sse=new EventSource("ffmpegProgress.php?log="+encodeURIComponent(fn));
sse.addEventListener('message',conversionProgress,false);
}
function conversionProgress(e){
if(e.data.substr(0,6)=='frame='){
inProgress=true;
var x=e.data.match(/frame=\s*(.*?)\s*fps=\s*(.*?)\s*q=\s*(.*?)\s*size=\s*(.*?)\s*time=\s*(.*?)\s*bitrate=\s*(.*?)\s*$/);
x.shift();x={frame:x[0]*1,fps:x[1]*1,q:x[2],size:x[3],time:x[4],bitrate:x[5]};
var elapsedTime = ((new Date().getTime()) - startTime);
var chunksPerTime = timeString2ms(x.time) / elapsedTime;
var estimatedTotalTime = duration / chunksPerTime;
var timeLeftInSeconds = Math.abs(elapsedTime-(estimatedTotalTime*1000));
var withOneDecimalPlace = Math.round(timeLeftInSeconds * 10) / 10;
conversion.innerHTML='Time Left: '+ms2TimeString(timeLeftInSeconds).split('.')[0]+'<br />'+
'Time Left2: '+(ms2TimeString(((frames-x.frame)/x.fps)*1000)+(timeString2ms(x.time)/(duration*1000)*100|0)).split('.')[0]+'<br />'+
'Estimated Total: '+ms2TimeString(estimatedTotalTime*1000).split('.')[0]+'<br />'+
'Elapsed Time: '+ms2TimeString(elapsedTime).split('.')[0];
}else{
if(inProgress){
sse.removeEventListener('message',conversionProgress,false);
sse.close();
sse=null;
conversion.textContent='Finished in '+ms2TimeString((new Date().getTime()) - startTime).split('.')[0];
//delete log/old file??
inProgress=false;
}
}
}EDIT
HERE IS A SAMPLE OUTPUT after detecting h264 codec in a m2ts with ac3 audio
As most devices can already read h264 i just need to convert the audio in aac and copy the same audio AC3 as second track. and put everything inside a mp4 container. So that i have a Android/chrome/ios & more browsers compatible file.
$opt="-map 0:0 -map 0:1 -map 0:1 -c:v copy -c:a:0 libfdk_aac -metadata:s:a:0 language=ita -b:a 128k -ar 48000 -ac 2 -c:a:1 copy -metadata:s:a:1 language=ita -movflags +faststart";
$i="in.m2ts";
$o="out.mp4";
$t="title";
$y="2014";
$progress="nameoftheLOG.log";
$cmd="ffmpeg -y -i ".escapeshellarg($i)." -metadata title=".$t." -metadata date=".$y." ".$opt." ".$o." null >/dev/null 2>".$progress." &";if you have any questions about the code or want to see more code just ask...
-
ffmpeg runs in terminal but returns error in subprocess.run
29 septembre 2022, par ExllatedI want to run this command in python :


ffmpeg -ss 00:00:30 -i "/home/exl/—1—ARCHIVE—1—/video/music videos/author --- a2 - name (text).webm" -vf scale=150:-2 -vframes 1 -c:v libwebp -compression_level 6 -quality 100 /home/exl/—1—ARCHIVE—1—/—3—previews—3—/734a8a0bac3a83e0f6c69416a26ec5cd211a6d742f3df63bb72bdbe6431b57c30677bc11551ba4aaaecac15ed2c48de51340a09020b7e9d9479e1e81ff766191.webp



In terminal it works fine, but in subprocess returns error. Python code :


finished_process = subprocess.run(
 [
 '/usr/bin/ffmpeg',
 '-ss', f'00:00:{seconds_shift}',
 '-i', original_path,
 '-vf', 'scale=150:-2',
 '-vframes', '1',
 '-c:v', 'libwebp',
 '-compression_level', '6',
 '-quality', '100',
 preview_path
 ],
 #stdout=subprocess.DEVNULL,
 #stderr=subprocess.DEVNULL,
 check=False,
 capture_output=True
 )



finished_process.stderr.decode()
:

ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
 built with gcc 12.1.0 (GCC)
 configuration: --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --disable-debug --disable-doc --disable-static --enable-optimizations --enable-shared --disable-everything --enable-ffplay --enable-ffprobe --enable-gnutls --enable-libaom --enable-libdav1d --enable-libfdk-aac --enable-libmp3lame --enable-libfontconfig --enable-libfreetype --enable-libopus --enable-libpulse --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-openal --enable-opengl --enable-sdl2 --enable-vulkan --enable-zlib --enable-libv4l2 --enable-libxcb --enable-vdpau --enable-vaapi --enable-encoder='ac3,alac,flac,libfdk_aac,g723_1,mp2,libmp3lame,libopus,libspeex,pcm_alaw,pcm_mulaw,pcm_f32le,pcm_s16be,pcm_s24be,pcm_s16le,pcm_s24le,pcm_s32le,pcm_u8,tta,libvorbis,wavpack,' --enable-encoder='ass,ffv1,libaom_av1,libvpx_vp8,libvpx_vp9,mjpeg_vaapi,rawvideo,theora,vp8_vaapi,libopenh264' --enable-decoder='adpcm_g722,alac,flac,g723_1,g729,libfdk_aac,libopus,libspeex,mp2,mp3,m4a,pcm_alaw,pcm_mulaw,pcm_f16le,pcm_f24le,pcm_f32be,pcm_f32le,pcm_f64be,pcm_f64le,pcm_s16be,pcm_s16be_planar,pcm_s24be,pcm_s16le,pcm_s16le_planar,pcm_s24le,pcm_s24le_planar,pcm_s32le,pcm_s32le_planar,pcm_s64be,pcm_s64le,pcm_s8,pcm_s8_planar,pcm_u8,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,tta,vorbis,wavpack,' --enable-decoder='ass,ffv1,mjpeg,mjpegb,libaom_av1,libdav1d,libvpx_vp8,libvpx_vp9,rawvideo,theora,vp8,vp9,libopenh264' --enable-encoder='bmp,gif,jpegls,png,tiff,webp,' --enable-decoder='bmp,gif,jpegls,png,tiff,webp,' --enable-hwaccel='vp8_vaapi,mjpeg_vaapi,' --enable-parser='aac,ac3,flac,mjpeg,mpegaudio,mpeg4video,opus,vp3,vp8,vp9,vorbis,' --enable-muxer='ac3,ass,flac,g722,gif,matroska,mp3,mpegvideo,rtp,ogg,opus,pcm_s16be,pcm_s16le,wav,webm,' --enable-demuxer='aac,ac3,ass,flac,g722,gif,image_jpeg_pipe,image_png_pipe,image_webp_pipe,matroska,mjpeg,mov,mp3,mpegvideo,ogg,pcm_mulaw,pcm_alaw,pcm_s16be,pcm_s16le,rtp,wav,' --enable-filter='crop,scale,overlay,amix,amerge,aresample,format,aformat,fps,transpose,pad,' --enable-indev='v4l2,xcbgrab,' --enable-protocol='crypto,file,pipe,rtp,srtp,rtsp,tcp,udp,unix,' --arch=x86_64 --enable-libopenh264
 libavutil 57. 17.100 / 57. 17.100
 libavcodec 59. 18.100 / 59. 18.100
 libavformat 59. 16.100 / 59. 16.100
 libavdevice 59. 4.100 / 59. 4.100
 libavfilter 8. 24.100 / 8. 24.100
 libswscale 6. 4.100 / 6. 4.100
 libswresample 4. 3.100 / 4. 3.100
Input #0, matroska,webm, from '/home/exl/—1—ARCHIVE—1—/video/music videos/author --- a2 - name (text).webm':
 Metadata:
 ENCODER : Lavf59.16.100
 Duration: 00:03:24.98, start: -0.007000, bitrate: 915 kb/s
 Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709), 1920x1036, SAR 1:1 DAR 480:259, 25 fps, 25 tbr, 1k tbn (default)
 Metadata:
 DURATION : 00:03:24.960000000
 Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, s16 (default)
 Metadata:
 DURATION : 00:03:24.981000000
[NULL @ 0x55dd82de7d00] Unable to find a suitable output format for '/home/exl/—1—ARCHIVE—1—/—3—previews—3—/734a8a0bac3a83e0f6c69416a26ec5cd211a6d742f3df63bb72bdbe6431b57c30677bc11551ba4aaaecac15ed2c48de51340a09020b7e9d9479e1e81ff766191.webp'
/home/exl/—1—ARCHIVE—1—/—3—previews—3—/734a8a0bac3a83e0f6c69416a26ec5cd211a6d742f3df63bb72bdbe6431b57c30677bc11551ba4aaaecac15ed2c48de51340a09020b7e9d9479e1e81ff766191.webp: Invalid argument




As suggested here (FFMPEG command runs in terminal but not by subprocess) i tried using
which
determine path to correct version, but this command returns/usr/bin/ffmpeg
both in python and in terminal.

which ffmpeg
(bothsubprocess.run(['which', 'ffmpeg'], capture_output=True).stdout
and terminal) :/usr/bin/ffmpeg


ffmpeg -version
: 5.1.1-1ubuntu1

ffmpeg version 5.1.1-1ubuntu1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12 (Ubuntu 12.2.0-1ubuntu1)
configuration: --prefix=/usr --extra-version=1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-shared



subprocess.run(['ffmpeg', '-version'], capture_output=True).stdout.decode()
: 5.0.1

ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12.1.0 (GCC)
configuration: --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --disable-debug --disable-doc --disable-static --enable-optimizations --enable-shared --disable-everything --enable-ffplay --enable-ffprobe --enable-gnutls --enable-libaom --enable-libdav1d --enable-libfdk-aac --enable-libmp3lame --enable-libfontconfig --enable-libfreetype --enable-libopus --enable-libpulse --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-openal --enable-opengl --enable-sdl2 --enable-vulkan --enable-zlib --enable-libv4l2 --enable-libxcb --enable-vdpau --enable-vaapi --enable-encoder='ac3,alac,flac,libfdk_aac,g723_1,mp2,libmp3lame,libopus,libspeex,pcm_alaw,pcm_mulaw,pcm_f32le,pcm_s16be,pcm_s24be,pcm_s16le,pcm_s24le,pcm_s32le,pcm_u8,tta,libvorbis,wavpack,' --enable-encoder='ass,ffv1,libaom_av1,libvpx_vp8,libvpx_vp9,mjpeg_vaapi,rawvideo,theora,vp8_vaapi,libopenh264' --enable-decoder='adpcm_g722,alac,flac,g723_1,g729,libfdk_aac,libopus,libspeex,mp2,mp3,m4a,pcm_alaw,pcm_mulaw,pcm_f16le,pcm_f24le,pcm_f32be,pcm_f32le,pcm_f64be,pcm_f64le,pcm_s16be,pcm_s16be_planar,pcm_s24be,pcm_s16le,pcm_s16le_planar,pcm_s24le,pcm_s24le_planar,pcm_s32le,pcm_s32le_planar,pcm_s64be,pcm_s64le,pcm_s8,pcm_s8_planar,pcm_u8,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,tta,vorbis,wavpack,' --enable-decoder='ass,ffv1,mjpeg,mjpegb,libaom_av1,libdav1d,libvpx_vp8,libvpx_vp9,rawvideo,theora,vp8,vp9,libopenh264' --enable-encoder='bmp,gif,jpegls,png,tiff,webp,' --enable-decoder='bmp,gif,jpegls,png,tiff,webp,' --enable-hwaccel='vp8_vaapi,mjpeg_vaapi,' --enable-parser='aac,ac3,flac,mjpeg,mpegaudio,mpeg4video,opus,vp3,vp8,vp9,vorbis,' --enable-muxer='ac3,ass,flac,g722,gif,matroska,mp3,mpegvideo,rtp,ogg,opus,pcm_s16be,pcm_s16le,wav,webm,' --enable-demuxer='aac,ac3,ass,flac,g722,gif,image_jpeg_pipe,image_png_pipe,image_webp_pipe,matroska,mjpeg,mov,mp3,mpegvideo,ogg,pcm_mulaw,pcm_alaw,pcm_s16be,pcm_s16le,rtp,wav,' --enable-filter='crop,scale,overlay,amix,amerge,aresample,format,aformat,fps,transpose,pad,' --enable-indev='v4l2,xcbgrab,' --enable-protocol='crypto,file,pipe,rtp,srtp,rtsp,tcp,udp,unix,' --arch=x86_64 --enable-libopenh264



Thank you in advance.


-
FFMPEG Concurrent Video Decoding
26 septembre 2022, par Patrick McKeeverSo, right now my program is decoding an input video sequentially and doing math on each frame to determine black frames. I feel like decoding the video frames concurrently could greatly improve the speed of my program, but I'm not really sure if FFMPEG supports that. Currently I generate 2 threads that call avcodec_receive_frame and avcodec_send_packet, but It doesn't seem to be working like the sequential implementation. Does anyone know the proper way to decode in parallel ?