
Recherche avancée
Médias (91)
-
Géodiversité
9 septembre 2011, par ,
Mis à jour : Août 2018
Langue : français
Type : Texte
-
USGS Real-time Earthquakes
8 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
SWFUpload Process
6 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
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
-
Podcasting Legal guide
16 mai 2011, par
Mis à jour : Mai 2011
Langue : English
Type : Texte
-
Creativecommons informational flyer
16 mai 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (99)
-
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
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 (...) -
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
MediaSPIP v0.2
21 juin 2013, parMediaSPIP 0.2 est la première version de MediaSPIP stable.
Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)
Sur d’autres sites (15290)
-
On-premise analytics demand grows as Google Analytics GDPR uncertainties continue
7 janvier 2020, par Jake Thornton — Privacy -
How to save h264 frames as jpeg images using ffmpeg ?
17 août 2020, par Matthew CzarnekI would like to save thumbnails from a h264 stream that I'm turning into ffmpeg avpackets as jpegs.


I'm started with a h264 AVPacket (iframe) and decode it into an AVFrame using avcodec_send_packet/avcodec_receive_frame. Now trying to go from AVFrame and convert into AVPacket using avcodec_send_frame/avcodec_receive_packet


I can convert to png instead jpg, though I do get a the video looking like it's outputting three separate frames squeezed side by side into one. Wondering if it's one frame is R, next G, and finally B. I'm not sure, clearly I'm doing something wrong there. I figured it's possible it's the png encoder and I don't need it, so let's get jpg working first. But jpg is outputting unopenable files.


Any advice ?


Here is my code :


int output_thumbnails(AVPacket* video_packet)
{
 char png_file_name[max_chars_per_filename];
 char thumbnail_id_char[10];
 _itoa_s(thumbnail_id, thumbnail_id_char, 10);
 strcpy_s(png_file_name, max_chars_per_filename, time_stamped_filepath);
 strcat_s(png_file_name, max_chars_per_filename, time_stamped_filename);
 strcat_s(png_file_name, max_chars_per_filename, thumbnail_id_char);
 strcat_s(png_file_name, max_chars_per_filename, ".jpg");
 thumbnail_id++;

 int error_code = send_AVPacket_to_videocard(video_packet, av_codec_context_RTSP);

 //if (error_code == AVERROR_EOF)
 //{
 // // error_code = videocard_to_PNG(png_file_name, av_codec_context_RTSP, av_codec_RTSP);
 //}
 if (error_code == AVERROR(EAGAIN)) //send packets to videocard until function returns EAGAIN
 {
 error_code = videocard_to_PNG(png_file_name, av_codec_context_RTSP);

 //EAGAIN means that the video card buffer is ready to have the png pulled off of it
 if (error_code == AVERROR_EOF)
 {
 // error_code = videocard_to_PNG(png_file_name, av_codec_context_RTSP, av_codec_RTSP);
 }
 else if (error_code == AVERROR(EAGAIN))
 {

 }
 else
 {
 deal_with_av_errors(error_code, __LINE__, __FILE__);
 }
 }
 else
 {
 deal_with_av_errors(error_code, __LINE__, __FILE__);
 }
 
 return 0;
}



VideoThumbnailGenerator.h :
#include "VideoThumbnailGenerator.h"


bool decoder_context_created = false;
bool encoder_context_created = false;

AVCodecContext* h264_decoder_codec_ctx;
AVCodecContext* thumbnail_encoder_codec_ctx;

int send_AVPacket_to_videocard(AVPacket* packet, AVCodecContext* codec_ctx)
{
 if(!decoder_context_created)
 {
 AVCodec* h264_codec = avcodec_find_decoder(codec_ctx->codec_id);
 h264_decoder_codec_ctx = avcodec_alloc_context3(h264_codec);

 h264_decoder_codec_ctx->width = codec_ctx->width;
 h264_decoder_codec_ctx->height = codec_ctx->height;
 h264_decoder_codec_ctx->pix_fmt = AV_PIX_FMT_RGB24;
 h264_decoder_codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO;
 h264_decoder_codec_ctx->skip_frame = AVDISCARD_NONINTRA;//AVDISCARD_NONREF;//AVDISCARD_NONINTRA;
 
 h264_decoder_codec_ctx->time_base.num = 1;
 h264_decoder_codec_ctx->time_base.den = 30;

 h264_decoder_codec_ctx->extradata = codec_ctx->extradata;
 h264_decoder_codec_ctx->extradata_size = codec_ctx->extradata_size;
 
 int error_code = avcodec_open2(h264_decoder_codec_ctx, h264_codec, NULL);
 if (!h264_codec) {
 return -1;
 }

 if (error_code < 0)
 {
 return error_code;
 }
 decoder_context_created = true;
 }

 
 //use hardware decoding to decode video frame
 int error_code = avcodec_send_packet(h264_decoder_codec_ctx, packet);
 if(error_code == AVERROR(EAGAIN))
 {
 return AVERROR(EAGAIN);
 }
 if(error_code<0)
 {
 printf("Error: Could not send packet to video card");
 return error_code;
 }

 return 0;
}

int videocard_to_PNG(char *png_file_path, AVCodecContext* codec_ctx)
{
 if (!encoder_context_created)
 {
 //AVCodec* thumbnail_codec = avcodec_find_encoder(AV_CODEC_ID_PNG);
 AVCodec* thumbnail_codec = avcodec_find_encoder(AV_CODEC_ID_JPEG2000);
 thumbnail_encoder_codec_ctx = avcodec_alloc_context3(thumbnail_codec);

 thumbnail_encoder_codec_ctx->width = 128;
 thumbnail_encoder_codec_ctx->height = (int)(((float)codec_ctx->height/(float)codec_ctx->width) * 128);
 thumbnail_encoder_codec_ctx->pix_fmt = AV_PIX_FMT_RGB24; //AV_PIX_FMT_YUVJ420P
 thumbnail_encoder_codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO;

 thumbnail_encoder_codec_ctx->time_base.num = 1;
 thumbnail_encoder_codec_ctx->time_base.den = 30;

 bool thread_check = thumbnail_encoder_codec_ctx->thread_type & FF_THREAD_FRAME;
 bool frame_threads_check = thumbnail_encoder_codec_ctx->codec->capabilities & AV_CODEC_CAP_FRAME_THREADS;
 
 int error_code = avcodec_open2(thumbnail_encoder_codec_ctx, thumbnail_codec, NULL);
 if (!thumbnail_codec) {
 return -1;
 }

 if (error_code < 0)
 {
 return error_code;
 }
 encoder_context_created = true;
 }
 
 AVFrame* thumbnail_frame = av_frame_alloc();
 AVPacket* thumbnail_packet = av_packet_alloc();
 //av_init_packet(png_packet);
 int error_code = avcodec_receive_frame(h264_decoder_codec_ctx, thumbnail_frame);

 //check for errors everytime
 //note EAGAIN errors won't get here since they won't get past while
 if (error_code < 0 && error_code != AVERROR(EAGAIN))
 {
 printf("Error: Could not get frame from video card");
 return error_code;
 }
 //empty buffer if there are any more frames to pull (there shouldn't be)
 //while(error_code != AVERROR(EAGAIN))
 //{
 // //check for errors everytime
 // //note EAGAIN errors won't get here since they won't get past while
 // if (error_code < 0)
 // {
 // printf("Error: Could not get frame from video card");
 // return error_code;
 // }
 // 
 // error_code = avcodec_receive_frame(h264_decoder_codec_ctx, png_frame);
 //}

 //now we convert back to AVPacket, this time one holding PNG info, so we can store to file
 error_code = avcodec_send_frame(thumbnail_encoder_codec_ctx, thumbnail_frame);

 if (error_code >= 0) {
 error_code = avcodec_receive_packet(thumbnail_encoder_codec_ctx, thumbnail_packet);

 FILE* out_PNG;

 errno_t err = fopen_s(&out_PNG, png_file_path, "wb");
 if (err == 0) {
 fwrite(thumbnail_packet->data, thumbnail_packet->size, 1, out_PNG);
 }
 fclose(out_PNG);

 }
 return error_code;
}



-
Thumbnail is not created in php
21 novembre 2014, par Desipicforu BlogspotI am writing this code to create thumbnail of uploaded video. Video is successfully created but thumbnail is not crated to directory.
There is no error in apache error log file. And when i run this command in terminal thumbnail is successfully created to my directory, But it’s not working by php.
Here is my code :-
<?php
if(isset($_REQUEST['AddFiles'])){
$targetFolder = 'uploads'; //Path to the Uploads Folder
if (!empty($_FILES)) {
for($i=0;$i' . uniqid().".".$info->getExtension();
$fileParts = pathinfo($_FILES['upload_file']['name'][$i]);
if(isset($fileParts['extension'])){
//if (in_array($fileParts['extension'],$fileTypes))
{
move_uploaded_file($tempFile,$targetFile);
echo '<div class="success">'.$_FILES['upload_file']['name'][$i].' was saved successfully inside '. $_SERVER['HTTP_HOST']."/". dirname($_SERVER["REQUEST_URI"])."/".$targetFile.' Directory</div>';
$videoUrl=$_SERVER['HTTP_HOST']."/". dirname($_SERVER["REQUEST_URI"])."/".$targetFile;
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "a7630155_google";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO video (title, artist, duration,thumb_url,video)
VALUES ('".$_REQUEST['videoName']."', '".$_REQUEST['category']."','', 'john@example.com','".$videoUrl."')";
if ($conn->query($sql) === TRUE) {
// where ffmpeg is located
$ffmpeg = '/usr/bin/ffmpeg';
//video dir
$video = "http://".$videoUrl;
//where to save the image
$image = rtrim($targetFolder,'/');
//time to take screenshot at
$interval = 5;
//screenshot size
$size = '640x480';
//ffmpeg command
$cmd = "$ffmpeg -i $video -deinterlace -an -ss $interval -f mjpeg -t 1 -r 1 -y -s $size $image 2>&1";
shell_exec($cmd);
echo $cmd;
exit;
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br />" . $conn->error;
}
$conn->close();
}
/*else{
echo '<div class="fail">'.$_FILES['upload_file']['name'][$i].' couldn\'t be saved because of invalid file type.</div>';
}*/
}else{
echo '<div class="fail">'.$_FILES['upload_file']['name'][$i].' couldn\'t be saved because of invalid file type.</div>';
}
}
}
}
?>
<code class="echappe-js"><script src="//code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script><script><br />
var selDiv = "";<br />
document.addEventListener("DOMContentLoaded", init, false);<br />
<br />
function init() {<br />
document.querySelector('#upload_file').addEventListener('change', handleFileSelect, false);<br />
selDiv = document.querySelector("#selectedFiles");<br />
}<br />
<br />
function handleFileSelect(e) {<br />
if(!e.target.files) return;<br />
var files = e.target.files;<br />
for(var i=0; i<files.length; i++) {<br />
var f = files[i];<br />
selDiv.innerHTML += "<div class='file_list'>"+f.name + "</div>";<br />
}<br />
$('#uploadimages').show();<br />
}<br />
<br />
$(document).ready(function(){<br />
$("#uploadTrigger").click(function(){<br />
$("#upload_file").click();<br />
}); <br />
});<br />
<br />
</script>