
Recherche avancée
Autres articles (39)
-
Other interesting software
13 avril 2011, parWe don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
We don’t know them, we didn’t try them, but you can take a peek.
Videopress
Website : http://videopress.com/
License : GNU/GPL v2
Source code : (...) -
HTML5 audio and video support
13 avril 2011, parMediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
For older browsers the Flowplayer flash fallback is used.
MediaSPIP allows for media playback on major mobile platforms with the above (...) -
De l’upload à la vidéo finale [version standalone]
31 janvier 2010, parLe chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
Upload et récupération d’informations de la vidéo source
Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)
Sur d’autres sites (4853)
-
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...
-
Android recorded video getting rotated after using ffmpeg
6 novembre 2014, par VaeianorI’m developing an android app, in which users can record a video, trim it, and then upload it to my server. I’m using the MediaRecorder class to handle the recording and using ffmpeg to trim the recorded video. The problem I’m having with ffmpeg is that the video is always getting rotated either 90 or 180 degrees after being trimmed. I know I can add a video filter (transpose=1) within the ffmpeg command to rotate the video. But that will require re-encoding the video. In my case, I don’t want to re-encode the video,as it takes too long. Instead, I’m having "-vcodec:copy" within ffmpeg command to use the same video codec.
Because I’m setting an orientation hint to the media recorder, the media recorder always adds "rotate=90" or "rotate=180" to the video metadata. I think that’s why the video is always getting rotated by ffmpeg.
So I was wondering if there is a way to rotate the video without re-encoding it. Or if there is a way to modify the metadata(rotate) of a recorded video before trimming it with ffmpeg.Please help ! The problem has been driving me crazy...
Thanks in advance !
Here is the ffmpeg command :
/data/data/com.xxx.xxx/app_bin/ffmpeg -y -ss 00:00:00 -t 4.000000 -i file:/storage/sdcard0/Movies/xxx/vid.mp4 -vcodec copy -acodec copy -metadata:s:v:0 rotate=0 - strict -2 file:/storage/sdcard0/Movies/xxx/vid_new.mp4
Below is the console output :
I/ShellCallback : shellOut()(9781): ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
I/ShellCallback : shellOut()(9781): built on Nov 15 2013 00:50:10 with gcc 4.6 20120106 (prerelease)
I/ShellCallback : shellOut()(9781): configuration: --arch=arm --cpu=cortex-a8 --target-os=linux --enable-runtime-cpudetect --enable-small --prefix=/data/data/info.guardianproject.ffmpeg/app_opt --enable-pic --disable-shared --enable-static --cross-prefix=/home/n8fr8/dev/android/ndk//toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi- --sysroot=/home/n8fr8/dev/android/ndk//platforms/android-3/arch-arm --extra-cflags='-I../x264 -mfloat-abi=softfp -mfpu=neon' --extra-ldflags=-L../x264 --enable-version3 --enable-gpl --disable-doc --enable-yasm --enable-decoders --enable-encoders --enable-muxers --enable-demuxers --enable-parsers --enable-protocols --enable-filters --enable-avresample --enable-libfreetype --disable-indevs --enable-indev=lavfi --disable-outdevs --enable-hwaccels --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-network --enable-libx264 --enable-zlib --enable-muxer=md5
I/ShellCallback : shellOut()(9781): libavutil 51. 54.100 / 51. 54.100
I/ShellCallback : shellOut()(9781): libavcodec 54. 23.100 / 54. 23.100
I/ShellCallback : shellOut()(9781): libavformat 54. 6.100 / 54. 6.100
I/ShellCallback : shellOut()(9781): libavdevice 54. 0.100 / 54. 0.100
I/ShellCallback : shellOut()(9781): libavfilter 2. 77.100 / 2. 77.100
I/ShellCallback : shellOut()(9781): libswscale 2. 1.100 / 2. 1.100
I/ShellCallback : shellOut()(9781): libswresample 0. 15.100 / 0. 15.100
I/ShellCallback : shellOut()(9781): libpostproc 52. 0.100 / 52. 0.100
I/ShellCallback : shellOut()(9781): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file:/storage/sdcard0/Movies/xxx/vid.mp4':
I/ShellCallback : shellOut()(9781): Metadata:
I/ShellCallback : shellOut()(9781): major_brand : isom
I/ShellCallback : shellOut()(9781): minor_version : 0
I/ShellCallback : shellOut()(9781): compatible_brands: isom3gp4
I/ShellCallback : shellOut()(9781): creation_time : 2014-09-17 17:25:50
I/ShellCallback : shellOut()(9781): Duration: 00:00:04.69, start: 0.000000, bitrate: 2969 kb/s
I/ShellCallback : shellOut()(9781): Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 720x480, 2989 kb/s, 29.89 fps, 30 tbr, 90k tbn, 180k tbc
I/ShellCallback : shellOut()(9781): Metadata:
I/ShellCallback : shellOut()(9781): rotate : 90
I/ShellCallback : shellOut()(9781): creation_time : 2014-09-17 17:25:50
I/ShellCallback : shellOut()(9781): handler_name : VideoHandle
I/ShellCallback : shellOut()(9781): Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, s16, 128 kb/s
I/ShellCallback : shellOut()(9781): Metadata:
I/ShellCallback : shellOut()(9781): creation_time : 2014-09-17 17:25:50
I/ShellCallback : shellOut()(9781): handler_name : SoundHandle
I/ShellCallback : shellOut()(9781): Output #0, mp4, to 'file:/storage/sdcard0/Movies/xxx/vid_new.mp4':
I/ShellCallback : shellOut()(9781): Metadata:
I/ShellCallback : shellOut()(9781): major_brand : isom
I/ShellCallback : shellOut()(9781): minor_version : 0
I/ShellCallback : shellOut()(9781): compatible_brands: isom3gp4
I/ShellCallback : shellOut()(9781): creation_time : 2014-09-17 17:25:50
I/ShellCallback : shellOut()(9781): encoder : Lavf54.6.100
I/ShellCallback : shellOut()(9781): Stream #0:0(eng): Video: h264 (![0][0][0] / 0x0021), yuv420p, 720x480, q=2-31, 2989 kb/s, 29.89 fps, 90k tbn, 90k tbc
I/ShellCallback : shellOut()(9781): Metadata:
I/ShellCallback : shellOut()(9781): handler_name : VideoHandle
I/ShellCallback : shellOut()(9781): creation_time : 2014-09-17 17:25:50
I/ShellCallback : shellOut()(9781): rotate : 0
I/ShellCallback : shellOut()(9781): Stream #0:1(eng): Audio: aac (@[0][0][0] / 0x0040), 44100 Hz, mono, 128 kb/s
I/ShellCallback : shellOut()(9781): Metadata:
I/ShellCallback : shellOut()(9781): creation_time : 2014-09-17 17:25:50
I/ShellCallback : shellOut()(9781): handler_name : SoundHandle
I/ShellCallback : shellOut()(9781): Stream mapping:
I/ShellCallback : shellOut()(9781): Stream #0:0 -> #0:0 (copy)
I/ShellCallback : shellOut()(9781): Stream #0:1 -> #0:1 (copy)
I/ShellCallback : shellOut()(9781): Press [q] to stop, [?] for help
I/ShellCallback : shellOut()(9781): frame= 120 fps=0.0 q=-1.0 Lsize= 1530kB time=00:00:03.98 bitrate=3147.1kbits/s
I/ShellCallback : shellOut()(9781): video:1462kB audio:62kB global headers:0kB muxing overhead 0.329934%
I/ShellCallback : shellOut()(9781): ret 0, stream_spec v:0 -
how is the 'response' parameter calculated for rtsp authentication ?
11 septembre 2015, par zcaudateSo I’ve captured a couple of packets from ffmpeg to a ip camera with rtsp, which I’ve attached at the end of the question :
In the second request/response pair, the protocol sees that it needs authentication and returns a
nonce="be129bc71fa3ddfbff9989ed6f748268"
to the userIn the third request/response pair, there is a
response="da0882d360a56deef2994d8ba0de8e89"
being sent to the server and I’m not sure how that is generated. The user/password pair isadmin
with a blank password.Any ideas of where to look in the RFCs would be great
OPTIONS rtsp://192.168.1.245:88/videoMain RTSP/1.0
CSeq: 1
User-Agent: Lavf56.4.101
RTSP/1.0 200 OK
CSeq: 1
Date: Sun, Sep 21 2014 01:33:07 GMT
Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER
----------
DESCRIBE rtsp://192.168.1.245:88/videoMain RTSP/1.0
Accept: application/sdp
CSeq: 2
User-Agent: Lavf56.4.101
RTSP/1.0 401 Unauthorized
CSeq: 2
Date: Sun, Sep 21 2014 01:33:07 GMT
WWW-Authenticate: Digest realm="LIVE555 Streaming Media", nonce="be129bc71fa3ddfbff9989ed6f748268"
----------
DESCRIBE rtsp://192.168.1.245:88/videoMain RTSP/1.0
Accept: application/sdp
CSeq: 3
User-Agent: Lavf56.4.101
Authorization: Digest username="admin",realm="LIVE555 Streaming Media",nonce="be129bc71fa3ddfbff9989ed6f748268",uri="rtsp://192.168.1.245:88/videoMain",response="da0882d360a56deef2994d8ba0de8e89"
RTSP/1.0 200 OK
CSeq: 3
Date: Sun, Sep 21 2014 01:33:07 GMT
Content-Base: rtsp://192.168.1.245:65534/videoMain/
Content-Type: application/sdp
Content-Length: 500
v=0
o=- 1411259869717503 1 IN IP4 192.168.1.245
s=IP Camera Video
i=videoMain
t=0 0
a=tool:LIVE555 Streaming Media v2013.01.25
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:IP Camera Video
a=x-qt-text-inf:videoMain
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=42001F;sprop-parameter-sets=Z0IAH5WoFAFuQA==,aM48gA==
a=control:track1
m=audio 0 RTP/AVP 0
c=IN IP4 0.0.0.0
b=AS:64
a=control:track2