
Recherche avancée
Autres articles (70)
-
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 -
Contribute to a better visual interface
13 avril 2011MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community. -
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 (...)
Sur d’autres sites (11605)
-
Revision 3202 : Et on update la conf d’emballe_medias tant qu’à faire
6 avril 2010, par kent1 — LogEt on update la conf d’emballe_medias tant qu’à faire
-
FFmpeg - add watermark, concat files and output mp4, optimize ?
17 août 2021, par user892134I use the following code, which works to :


- 

- add watermark
- convert (preroll,video,postroll) to .ts
- create concat txt file from new .ts files
- create mp4 ouput










variables


$filePath = '/home/mywebsite/public_html/assets/videos/';
$convertfile = $filePath.'convert-videos-2.txt';
$watermark = $filePath.'watermark.png';
$preroll = $filePath.'preroll.mp4';
$video = $filePath.'Video.mp4';
$video_watermark = str_replace(".mp4","-watermark.mp4",$video);
$newVideo = $filePath.'Video-New.mp4';
$postroll = $filePath.'postroll.mp4';
$input1 = $filePath.'input1.ts';
$input2 = $filePath.'input2.ts';
$input3 = $filePath.'input3.ts';



Add watermark to original mp4


$mark = "ffmpeg -y -i '".$video."' -i '".$watermark."' -filter_complex \"overlay=10:10\" '".$video_watermark."'";
exec($mark);



convert to ts (video transport stream)


exec("ffmpeg -i '".$preroll."' -c copy -bsf:v h264_mp4toannexb -f mpegts '".$input1."'");
exec("ffmpeg -i '".$video_watermark."' -c copy -bsf:v h264_mp4toannexb -f mpegts '".$input2."'");
exec("ffmpeg -i '".$postroll."' -c copy -bsf:v h264_mp4toannexb -f mpegts '".$input3."'");



create concatenate txt file, with new .ts files


$cmd = "echo \"file '".$input1."'\n";
$cmd.="file '".$input2."'\n";
$cmd.="file '".$input3."'\" > ".$convertfile;
exec($cmd);



create output mp4


exec("ffmpeg -f concat -safe 0 -y -i '".$convertfile."' -c copy -bsf:a aac_adtstoasc '".$newVideo."'");



This works but takes way to long. For an mp4 that is 1GB or more, can take upto 3 hours ? The watermark alone takes 1hour plus. How can i optimize this code ? combine commands ? How do i solve ?


I've tried adding the watermark when generate the second .ts file below, but not working, returns this error Streamcopy requested for output stream 0:0, which is fed from a complex filtergraph. Filtering and streamcopy cannot be used together. :


exec("ffmpeg -y -i '".$video."' -i '".$watermark."' -filter_complex \"overlay=10:10\" -c copy -bsf:v h264_mp4toannexb -f mpegts '".$input2."'");



-
Is there an efficient way to retrieve frames from a video in Android ?
28 mars 2015, par NaveedI have an app which requires me to retrieve frames from a video and do some processing with them. However it seems like that the frame retrieval is very slow to the point where it is unacceptable. Sometimes it is taking upto 2.5 second to retrieve a single frame. I am using the MediaMetadataRetriever as most stackoverflow questions suggested. However the performance is very bad. Here is what I have :
private List<bitmap> retrieveFrames() {
MediaMetadataRetriever fmmr = new MediaMetadataRetriever();
fmmr.setDataSource("/path/to/some/video.mp4");
String strLength = fmmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
long milliSecs = Long.parseLong(strLength);
long microSecLength = milliSecs * 1000;
Log.d("TAG", "length: " + microSecLength);
long one_sec = 1000000; // one sec in micro seconds
ArrayList<bitmap> frames = new ArrayList<>();
int j = 0;
for (int i = 0; i < microSecLength; i += (one_sec / 5)) {
long time = System.currentTimeMillis();
Bitmap frame = fmmr.getFrameAtTime(i, MediaMetadataRetriever.OPTION_CLOSEST);
j++;
Log.d("TAG", "Frame number: " + j + " Time taken: " + (System.currentTimeMillis() - time));
// commented out because each frame would be written to disk instead of holding them in memory
// frames.add(frame);
}
fmmr.release();
return frames;
}
</bitmap></bitmap>The above will logs :
03-26 21:49:29.781 13213-13239/com.example.naveed.myapplication D/TAG﹕ length: 4949000
03-26 21:49:30.187 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 1 Time taken: 406
03-26 21:49:30.779 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 2 Time taken: 592
03-26 21:49:31.578 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 3 Time taken: 799
03-26 21:49:32.632 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 4 Time taken: 1054
03-26 21:49:33.895 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 5 Time taken: 1262
03-26 21:49:35.382 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 6 Time taken: 1486
03-26 21:49:37.128 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 7 Time taken: 1746
03-26 21:49:39.077 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 8 Time taken: 1948
03-26 21:49:41.287 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 9 Time taken: 2210
03-26 21:49:43.717 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 10 Time taken: 2429
03-26 21:49:44.093 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 11 Time taken: 376
03-26 21:49:44.707 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 12 Time taken: 614
03-26 21:49:45.539 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 13 Time taken: 831
03-26 21:49:46.597 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 14 Time taken: 1057
03-26 21:49:47.875 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 15 Time taken: 1278
03-26 21:49:49.384 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 16 Time taken: 1508
03-26 21:49:51.112 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 17 Time taken: 1728
03-26 21:49:53.096 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 18 Time taken: 1983
03-26 21:49:55.315 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 19 Time taken: 2218
03-26 21:49:57.711 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 20 Time taken: 2396
03-26 21:49:58.065 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 21 Time taken: 354
03-26 21:49:58.640 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 22 Time taken: 574
03-26 21:49:59.369 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 23 Time taken: 728
03-26 21:50:00.112 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 24 Time taken: 742
03-26 21:50:00.834 13213-13239/com.example.naveed.myapplication D/TAG﹕ Frame number: 25 Time taken: 721As you can see from above, it is taking about 18 - 25 sec to retrieve 25 frames from a 4 sec long video.
I have also tried this which uses FFmpeg underneath to do the same. I am not sure how well this library is implemented but it only improves the over all performance by a couple of seconds meaning it takes about 15-20 sec to do the same.
So my question is : is there a way to do it quicker ? My friend has an iOS app where he does something similar but it only takes couple of seconds and he is grabbing even more frames however he is not sure how to do it on android.
Is there anything on android that would speed up the process. Am I approaching this wrong ?
The end goal is to stitch those frames together into a gif.