
Recherche avancée
Médias (1)
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (60)
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)
Sur d’autres sites (5663)
-
How to read a text file in c++ ?
16 mai 2017, par Sanduni WickramasingheI want to detect a predefined specific content in a video. For this I use an already identified piece of video separately and another input video. I have read the data in the identified video and bite array was saved in a text file. Now I want to compare the content of saved text file with the input video content.
This is my code
void CFfmpegmethods::VideoRead(){
av_register_all();
avformat_network_init();
ifstream inFile;
inFile.open("H:\\Sanduni_projects\\sample_ad.txt");
const char *url = "H:\\Sanduni_projects\\ad_1.mp4";
AVDictionary *options = NULL;
AVFormatContext *s = avformat_alloc_context();
AVPacket *pkt = new AVPacket(); //this structure stores compressed data
//open an input stream and read the header
int ret = avformat_open_input(&s, url, NULL,NULL);
//avformat_find_stream_info(s, &options); //finding the missing information
if (ret < 0)
abort();
if (!inFile) {
cerr << "Unable to open file datafile.txt";
exit(1); // call system to stop
}
av_dict_set(&options, "video_size", "640x480", 0);
av_dict_set(&options, "pixel_format", "rgb24", 0);
if (avformat_open_input(&s, url, NULL, &options) < 0){
abort();
}
av_dict_free(&options);
AVDictionaryEntry *e;
if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key);
abort();
}
int i = 1;
int64_t duration = 0;
int size = 0;
uint8_t *data; //Unsigned integer type with a width of exactly 8 bits.
int sum = 0;
int total_size = 0;
int64_t total_duration = 0;
int packet_size = 0;
int64_t stream_index = 0;
int64_t bit_rate = 0;
AVBufferRef *buf;
//writing data to a file
outdata.open("H:\\Sanduni_projects\\sample_ad.txt");
//outdata.open("H:\\Sanduni_projects\\log.txt");
if (!outdata){
cerr << "Error: file could not be opened" << endl;
exit(1);
}
//Split what is stored in the file into frames and return one for each call
//returns the next frame of the stream
while(1){
int frame = av_read_frame(s, pkt); //one frame is readed.
if (frame < 0) break;
size = pkt->size;
data = pkt->data;
for (int j = 0; j < size; j++){
for (int k = 0; k < 12; k++){
while (!inFile.eof){
}
//if (data[j] != ) break;
}
}
//int decode = avcodec_send_packet(avctx, pkt);
}
//make the packet free
av_packet_unref(pkt);
delete pkt;
cout << "total size: " << total_size << endl;
cout << "total duration:" << total_duration << endl;
outdata.close();
//Close the file after reading
avformat_close_input(&s);
}
void CFfmpegmethods::SampleAdCreation(){
av_register_all();
const char *url_ref = "H:\\Sanduni_projects\\sample_ad.mp4";
AVDictionary *options = NULL;
AVDictionary *options_ref = NULL;
AVFormatContext *s = avformat_alloc_context();
AVPacket *pkt = new AVPacket(); //this structure stores compressed data
//open an input stream and read the header
int ret = avformat_open_input(&s, url_ref, NULL, NULL);
if (ret < 0)
abort();
av_dict_set(&options, "video_size", "640x480", 0);
av_dict_set(&options, "pixel_format", "rgb24", 0);
if (avformat_open_input(&s, url_ref, NULL, &options) < 0){
abort();
}
av_dict_free(&options);
AVDictionaryEntry *e;
if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key);
abort();
}
uint8_t *data;
//writing data to a file
outdata.open("H:\\Sanduni_projects\\sample_ad.txt");
if (!outdata){
cerr << "Error: file could not be opened" << endl;
exit(1);
}
for (int m = 0; m < 12; m++){
int size = pkt->size;
int frame = av_read_frame(s, pkt);
if (frame < 0) break;
data = pkt->data;
for (int j = 0; j < size; j++){
outdata << data[j];
} outdata</make the packet free
av_packet_unref(pkt);
delete pkt;
outdata.close();
//Close the file after reading
avformat_close_input(&s);
} -
How to choose between openH264 and x264 decoder
21 avril 2021, par DarkoI'm using the dev build from zeranoe.com which has OpenH264 and libx264 in it.
How can i choose between these two Decoders to compare the decoding speed ?



avcodec_find_decoder(AVCodecID.AV_CODEC_ID_H264); 




only gives me the name "h264"
but which decoder is it ?



And tries to force a specific decoder failed, like :



codec = avcodec_find_decoder _by_name("x264");
codec = avcodec_find_decoder _by_name("libx264");




Which other options i have to improve the decoding speed of avcodec_decode_video2 for highres (4k and higher) RTSP video streams ?


-
FFmpeg remove silence with exact duration detected by detect silence
17 mars 2021, par davI have an audio file, that have some silences, which I am detecting with ffmpeg detectsilence and then trying to remove with removesilence, however there is some strange behavior. Specifically :


1) File's Basic info based on ffprobe show_streams


Input #0, mp3, from 'my_file.mp3':
 Metadata:
 encoder : Lavf58.64.100
 Duration: 00:00:25.22, start: 0.046042, bitrate: 32 kb/s
 Stream #0:0: Audio: mp3, 24000 Hz, mono, fltp, 32 kb/s



2) Using detectsilence


ffmpeg -i my_file.mp3 -af silencedetect=noise=-50dB:d=0.2 -f null -



I get this result


[mp3float @ 000001ee50074280] overread, skip -7 enddists: -1 -1
[silencedetect @ 000001ee5008a1c0] silence_start: 6.21417
[silencedetect @ 000001ee5008a1c0] silence_end: 6.91712 | silence_duration: 0.702958
[silencedetect @ 000001ee5008a1c0] silence_start: 16.44
[silencedetect @ 000001ee5008a1c0] silence_end: 17.1547 | silence_duration: 0.714708
[mp3float @ 000001ee50074280] overread, skip -10 enddists: -3 -3
[mp3float @ 000001ee50074280] overread, skip -5 enddists: -4 -4
[silencedetect @ 000001ee5008a1c0] silence_start: 24.4501
size=N/A time=00:00:25.17 bitrate=N/A speed=1.32e+03x
video:0kB audio:1180kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[silencedetect @ 000001ee5008a1c0] silence_end: 25.176 | silence_duration: 0.725917



That also match the values and points based on Adobe Audition




So far all good.


3) Now, based on some calculations (which is based on application's logic on what should be the final duration of the audio) I am trying to delete the silence with "0.725917"s duration. For that, based on ffmpeg docs (https://ffmpeg.org/ffmpeg-filters.html#silencedetect)




Trim all silence encountered from beginning to end where there is more
than 1 second of silence in audio :
silenceremove=stop_periods=-1:stop_duration=1:stop_threshold=-90dB




I run this command


ffmpeg -i my_file.mp3 -af silenceremove=stop_periods=-1:stop_threshold=-50dB:stop_duration=0.72 result1.mp3



So, I am expecting that it should delete only the silence with "0.725917" duration (the last one in the above image), however it is deleting the silence that starts at 16.44s with duration of "0.714708"s. Please see the following comparison :




4) Running detectsilence on result1.mp3 with same options gives even stranger results


ffmpeg -i result1.mp3 -af silencedetect=noise=-50dB:d=0.2 -f null -



result


[mp3float @ 0000017723404280] overread, skip -5 enddists: -4 -4
[silencedetect @ 0000017723419540] silence_start: 6.21417
[silencedetect @ 0000017723419540] silence_end: 6.92462 | silence_duration: 0.710458
[mp3float @ 0000017723404280] overread, skip -7 enddists: -6 -6
[mp3float @ 0000017723404280] overread, skip -7 enddists: -2 -2
[mp3float @ 0000017723404280] overread, skip -6 enddists: -1 -1
 Last message repeated 1 times
[silencedetect @ 0000017723419540] silence_start: 23.7308
size=N/A time=00:00:24.45 bitrate=N/A speed=1.33e+03x
video:0kB audio:1146kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[silencedetect @ 0000017723419540] silence_end: 24.456 | silence_duration: 0.725167



So, the results are :


- 

- With command to remove silences that are longer than "0.72 second", a silence that was "0.714708"s, got removed and - a silence with "0.725917"s remained as is (well, actually changed a little - as per 3rd point)
- The first silence that had started at "6.21417" and had a duration of "0.702958"s, suddenly now has a duration of "0.710458"s
- The 3rd silence that had started at "24.4501" (which now starts at 23.7308 - obviously because the 2nd silence was removed) and had a duration of "0.725917", now suddenly is "0.725167"s (this one is not a big difference, but still why even removing other silence, this silence's duration should change at all).








Accordingly the expected results are :


- 

- Only the silences that match the provided condition (stop_duration=0.72) should be removed. In this specific example only the last one, but in general any silence that matches the condition of the length - irrelevant of their positioning (start, end or in the middle)
- Other silences should remain with same exact duration they were before






FFMpeg : 4.2.4-1ubuntu0.1, Ubuntu : 20.04.2


Some attempts and results, while playing with ffmpeg options


a)


ffmpeg -i my_file.mp3 -af silenceremove=stop_periods=-1:stop_threshold=-50dB:stop_duration=0.72:detection=peak tmp1.mp3



result :
First and second silences are removed, 3rd silence's duration remains exactly the same


b)


ffmpeg -i my_file.mp3 -af silenceremove=stop_periods=-1:stop_threshold=-50dB:stop_duration=0.71 tmp_0.71.mp3



result :
First and second silences are removed, 3rd silence remains, but the duration becomes "0.72075"s


c)


ffmpeg -i my_file.mp3 -af silenceremove=stop_periods=-1:stop_threshold=-50dB:stop_duration=0.7 tmp_0.7.mp3



result :
all 3 silence are removed


d) the edge case


this command still removes the second silence (after which the first silence become exactly as in point #4 and last silence becomes "0.721375")


ffmpeg -i my_file.mp3 -af silenceremove=stop_periods=-1:stop_threshold=-50dB:stop_duration=0.72335499999 tmp_0.72335499999.mp3



but this one, again does not remove any silence :


ffmpeg -i my_file.mp3 -af silenceremove=stop_periods=-1:stop_threshold=-50dB:stop_duration=0.723355 tmp_0.723355.mp3



e) window param case 0.03


ffmpeg -i my_file.mp3 -af silenceremove=stop_periods=-1:stop_threshold=-50dB:stop_duration=0.72:window=0.03 window_0.03.mp3



does not remove any silence, but the detect silence


ffmpeg -i window_0.03.mp3 -af silencedetect=noise=-50dB:d=0.2 -f null -



gives this result (compare with silences in result1.mp3 - from point #4 )


[mp3float @ 000001c5c8824280] overread, skip -5 enddists: -4 -4
[silencedetect @ 000001c5c883a040] silence_start: 6.21417
[silencedetect @ 000001c5c883a040] silence_end: 6.92462 | silence_duration: 0.710458
[mp3float @ 000001c5c8824280] overread, skip -7 enddists: -6 -6
[mp3float @ 000001c5c8824280] overread, skip -7 enddists: -2 -2
[silencedetect @ 000001c5c883a040] silence_start: 16.4424
[silencedetect @ 000001c5c883a040] silence_end: 17.1555 | silence_duration: 0.713167
[mp3float @ 000001c5c8824280] overread, skip -6 enddists: -1 -1
 Last message repeated 1 times
[silencedetect @ 000001c5c883a040] silence_start: 24.4508
size=N/A time=00:00:25.17 bitrate=N/A speed=1.24e+03x
video:0kB audio:1180kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[silencedetect @ 000001c5c883a040] silence_end: 25.176 | silence_duration: 0.725167



f) window case 0.01


ffmpeg -i my_file.mp3 -af silenceremove=stop_periods=-1:stop_threshold=-50dB:stop_duration=0.72:window=0.01 window_0.01.mp3



removes first and second silences, the detect silence with same params has the following result


[mp3float @ 000001ea631d4280] overread, skip -5 enddists: -4 -4
 Last message repeated 1 times
[mp3float @ 000001ea631d4280] overread, skip -7 enddists: -2 -2
[mp3float @ 000001ea631d4280] overread, skip -6 enddists: -1 -1
 Last message repeated 1 times
[silencedetect @ 000001ea631ea1c0] silence_start: 23.0108
size=N/A time=00:00:23.73 bitrate=N/A speed=1.2e+03x
video:0kB audio:1113kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[silencedetect @ 000001ea631ea1c0] silence_end: 23.736 | silence_duration: 0.725167




Any thoughts, ideas, points are much appreciated.