
Recherche avancée
Médias (1)
-
Video d’abeille en portrait
14 mai 2011, par
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (103)
-
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 -
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...) -
Les formats acceptés
28 janvier 2010, parLes commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
ffmpeg -codecs ffmpeg -formats
Les format videos acceptés en entrée
Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
Les formats vidéos de sortie possibles
Dans un premier temps on (...)
Sur d’autres sites (8464)
-
PHP execute batch files to start recording ffmpeg and to kill ffmpeg
28 février 2018, par Mitchell DayHi was just wondering if anyone knows a way that i can run a batch file that contains multiple "start ffmpeg" commands, that allows me to kill it using a batch file at some random point in time.
I have one batch that starts 4 videos recording from a rtsp feed to file. And another one that taskkills that ffmpeg process. The problem is that i can run these successfully by running in cmd prompt, but when i try to use exec(record.bat) or popen() etc, it runs the ffmpeg process in the background, and the stoprecord.bat can’t kill it error is :
The Process with PID x <child process="process" of="of" pid="pid" y="y"> could not be terminated.
Reason: This Process can only be termintated forcefully (with /f option)
</child>I don’t want to force it, because the mp4 file corrupts when you force close it. When i run the bat files directly i dont need that force option. I have tried giving the folders full permissions for the IIS_IUSRS user, i have made the bat and folder creater as IIS_IUSRS (thought the mkdir in the batch gives not permission to IIS usr which it is recording the video to).
Any one have any clue why this wouldnt work. I have put the bat files below and the php script which calls them.
Record.bat
cd C:\inetpub\wwwroot\ESTF\batch
tasklist /FI "IMAGENAME eq ffmpeg_sr.exe" | find ":" > NUL
if errorlevel 1 exit
set MEDIA_DIR=C:\inetpub\wwwroot\ESTF\media\recordings
set WEB_DIR=C:\inetpub\wwwroot\estf\
set VLC_DIR=C:\Program Files\VideoLAN\VLC
set ROOM=simroom
set M=1
set N=1
set CURRENT_DAY=day1
set FFMPEG_DIR=C:\inetpub\wwwroot\ESTF\ffmpeg\bin
call "date.bat"
if not exist %MEDIA_DIR%\curDate.txt (
mkdir %MEDIA_DIR%
icacls %MEDIA_DIR% /grant Everyone:(f)
echo %DATESTR%>%MEDIA_DIR%\curDate.txt
echo %CURRENT_DAY%>%MEDIA_DIR%\curDay.txt
goto :LOOP2
)
if exist %MEDIA_DIR%\curDate.txt (
set /p STORED_DATE=I %STORED_DATE%==%DATESTR% (
set /p CURRENT_DAY=I NOT %STORED_DATE%==%DATESTR% (
echo %DATESTR%>%MEDIA_DIR%\curDate.txt
goto :LOOP1
)
:LOOP1
set DAY_LOOP=%MEDIA_DIR%\day%M%
if exist %DAY_LOOP% (
set /a M = %M%+1
goto :LOOP1
)
if not exist %DAY_LOOP% (
mkdir %DAY_LOOP%
icacls %DAY_LOOP% /grant Everyone:(f)
)
set CURRENT_DAY=day%M%
@echo %CURRENT_DAY%>%MEDIA_DIR%\curDay.txt
:LOOP2
set CURRENT_ROOM=%MEDIA_DIR%\%CURRENT_DAY%\%ROOM%\Team%N%
if exist %CURRENT_ROOM% (
set /a N = %N%+1
goto :LOOP2
)
if not exist %CURRENT_ROOM% (
mkdir %CURRENT_ROOM%
icacls %CURRENT_ROOM% /grant Everyone:(f)
)
cd %FFMPEG_DIR%
echo %CURRENT_ROOM%>%MEDIA_DIR%\%CURRENT_DAY%\%ROOM%\teamNo.txt
echo recording>%WEB_DIR%\srRecording.txt
start ffmpeg_sr -i rtsp://192.168.0.50:554/Streaming/Channels/1 -c:v copy -c:a libmp3lame -strict experimental "%CURRENT_ROOM%\1.mp4"
start ffmpeg_sr -i rtsp://192.168.0.51:554/Streaming/Channels/1 -c:v copy "%CURRENT_ROOM%\2.mp4"
start ffmpeg_sr -i rtsp://192.168.0.52:554/Streaming/Channels/1 -c:v copy "%CURRENT_ROOM%\3.mp4"
start ffmpeg_sr -i rtsp://192.168.0.21:554/Streaming/Channels/1 -c:v copy "%CURRENT_ROOM%\4.mp4"
start ffmpeg_sr -f dshow -i audio="Microphone (High Definition Audio Device)" -c:a libmp3lame -strict experimental "%CURRENT_ROOM%\0.mp3"
exitStoprecord.bat
taskkill /im ffmpeg_sr.exe /t
set WEB_DIR=c:\inetpub\wwwroot\estf\
set FFMPEG_DIR=C:\inetpub\wwwroot\ESTF\ffmpeg\bin\
echo stopped>%WEB_DIR%\srRecording.txt
set /p CURRENT_DAY=p CURRENT_ROOM= -i %CURRENT_ROOM%/0.mp3 -c:v copy -c:a copy -strict experimental -map 0:v:0 -map 1:a:0 %CURRENT_ROOM%/1.mp4
ffmpeg -i %CURRENT_ROOM%/1_temp.mp4 -c:v copy -c:a copy -strict experimental -map 0:v:0 -map 1:a:0 %CURRENT_ROOM%/1.mp4
REM del %CURRENT_ROOM%\1_temp.mp4
del %CURRENT_ROOM%\0.mp3
exitrecord.php
<?php
echo exec('whoami');
//$recordPath = 'c:\inetpub\wwwroot\estf\batch\srRecord.bat';
//exec('c:\inetpub\wwwroot\estf\batch\srRecord.bat');
$handle = popen('start c:\inetpub\wwwroot\estf\batch\srRecord.bat exit','r');
pclose($handle);
echo $handle;
?>stoprecord.php
<?php
//exec('c:\inetpub\wwwroot\estf\batch\srRecordStop.exe /dev/null');
$handle = popen('start c:\inetpub\wwwroot\estf\batch\srRecordStop.bat','r');
pclose($handle);
//die();
echo $handle;
?>I have tried exec(), pclose(popen()), shell_exec(), tried adding /dev/nul & to both the php file and ffmpeg in the batch file.
Regards,
Mitchell
-
Compression Artifacts using sws_Scale() AVFrame YUV420p-> openCV Mat BGR24 and back
8 septembre 2023, par MorphI transcode, using C++ and FFmpeg, an H264 video in an .mp4 container to H265 video in an .mp4 container. That works perfectly with crisp and clear images and encoding conversion confirmed by checking with FFprobe.


Then, I call one extra function in between the end of the H264 decoding and before the start of the H265 encoding. At that point I have an allocated AVFrame* that I pass to that function as an argument.


The function converts the AVFrame into an openCV cv::Mat and backwards. Technically that is the easy part, yet i encountered a compression artifact problem in the process of which i don't understand why it happens.


The function code (including a workaround for the question that follows) is as follows :


void modifyVideoFrame(AVFrame * frame)
{
 // STEP 1: WORKAROUND, overwriting AV_PIX_FMT_YUV420P BEFORE both sws_scale() functions below, solves "compression artifacts" problem;
 frame->format = AV_PIX_FMT_RGB24; 
 
 // STEP 2: Convert the FFmpeg AVFrame to an openCV cv::Mat (matrix) object.
 cv::Mat image(frame->height, frame->width, CV_8UC3);
 int clz = image.step1();

 SwsContext* context = sws_getContext(frame->width, frame->height, (AVPixelFormat)frame->format, frame->width, frame->height, AVPixelFormat::AV_PIX_FMT_BGR24, SWS_FAST_BILINEAR, NULL, NULL, NULL);
 sws_scale(context, frame->data, frame->linesize, 0, frame->height, &image.data, &clz);
 sws_freeContext(context);

 // STEP 3 : Change the pixels.
 if (false)
 {
 // TODO when "compression artifacts" problem with baseline YUV420p to BGR24 and back BGR24 to YUV420P is solved or explained and understood.
 }
 
 // UPDATE: Added VISUAL CHECK
 cv::imshow("Visual Check of Conversion AVFrame to cv:Map", image);
 cv::waitKey(20);

 // STEP 4: Convert the openCV Mat object back to the FFmpeg AVframe.
 clz = image.step1();
 context = sws_getContext(frame->width, frame->height, AVPixelFormat::AV_PIX_FMT_BGR24, frame->width, frame->height, (AVPixelFormat)frame->format, SWS_FAST_BILINEAR, NULL, NULL, NULL);
 sws_scale(context, &image.data, &clz, 0, frame->height, frame->data, frame->linesize);
 sws_freeContext(context);
}



The code as shown, including the workaround, works perfectly but is NOT understood.


Using FFprobe i established that the input pixel format is YUV420p which is indeed AV_PIX_FMT_YUV420p that is found in the frame format. If I convert it to BGR24 and back to YUV420p without the workaround in step 1, then i have slight compression artifacts but which are clearly visible when viewing with VLC. So there is a loss somewhere which is what I try to understand.


However, when I use the workaround in step 1 then I obtain the exact same output as if this extra function wasn't called (that is crisp and clear H265 without compression artifacts). To be sure that the conversion took place i modified the red value (inside the part of the code that now says if(false) ), and i can indeed see the changes when playing the H265 output file with VLC.


From that test it is clear that after the conversion of the input, data present in AVFrame, from YUV420P to cv::Map BGR24, all information and data needed to convert it back into the original YUV420P input data was available. Yet that is not what happens without the workaround, proven by the compression artifacts.


I used the first 17 seconds of the movie clip "Charge" encoded in H264 and available on the 'Blender' website.


Is there anyone that has some explanation or that can help me understand why the code WITHOUT the workaround does not nicely converts the input data forwards and then backwards back into the original input data.




compared to what i see with work-around OR (update) Visual Check section (cv::imshow) IF part 4 of code is remarked :



These are the FFmpeg StreamingParams that i used on input :


copy_audio => 1
copy_video => 0
vid_codec => "libx265"
vid_video_codec_priv_key => "x265-params"
vid_codec_priv_value => "keyint=60:min-keyint=60:scenecut=0"

// Encoder output
x265 [info]: HEVC encoder version 3.5+98-753305aff
x265 [info]: build info [Windows][GCC 12.2.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-3.1 (Main tier)
x265 [info]: Thread pool 0 using 64 threads on numa nodes 0
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 1 / wpp(12 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge : hex / 57 / 2 / 2
x265 [info]: Lookahead / bframes / badapt : 15 / 4 / 0
x265 [info]: b-pyramid / weightp / weightb : 1 / 1 / 0
x265 [info]: References / ref-limit cu / depth : 3 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress : ABR-2000 kbps / 0.60
x265 [info]: VBV/HRD buffer / max-rate / init : 4000 / 2000 / 0.750
x265 [info]: tools: rd=2 psy-rd=2.00 rskip mode=1 signhide tmvp fast-intra
x265 [info]: tools: strong-intra-smoothing lslices=4 deblock sao



-
Optimize ffmpeg 2 pass command to speed up compression
21 août 2022, par Khawar RazaIn my android app, I am using ffmpeg wrapper library ffmpeg-kit. User is offered different file sizes and video file is compressed to the selected file size. I am using ffmpeg 2 pass command technique to compress video file to desired size. Here are the commands :


-y -i "input.mp4" -c:v h264 -b:v 8064k -s 1920x1440 -pass 1 -an -f mp4 -passlogfile "logfile.passlogfile" /dev/null

 -i "input.mp4" -c:v h264 -b:v 8064k -s 1920x1440 -pass 2 -c:a aac -b:a 128k -passlogfile "logfile.passlogfile" "outfile.mp4"



Here file size 8064k and resolution 1920x1440 are dynamically set. It works for small video files but takes considerably high amount of time for large videos to finish the job. Can we optimize this process to complete it in less time ?


Note : The whole purpose of this process is to compress video to a desired file size where video quality will surely be compromised.