
Recherche avancée
Médias (1)
-
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
Autres articles (36)
-
Support audio et vidéo HTML5
10 avril 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...) -
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 (6437)
-
How to set start time of video saved from RTSP stream with FFMPEG
12 janvier 2023, par hungI use FFMPEG to record video from a RTSP stream. What my code does is get current day time, create a folder with this format
year/month/day/hour/minute
and save the video to that folder.


When a new minute arrive, I create the new folder base on the new minute and run the record again to the new folder.
Basically It works, but the next video start time is continue the end of previous video. For example :



video1: 00:00 -> 00:55
video2: 00:56 -> ...




I hope I can set for all videos start from 00:00. Can I do that ?



Here my code



ffmpeg.h



class CtFfmpeg {
public:

 CtFfmpeg();
 ~CtFfmpeg();

 void init();
 int getInput();
 int getOutputName(const char *filename);
 int release();
 int ret;
 AVFormatContext *ifmt_ctx, *ofmt_ctx;
 AVStream *in_stream, *out_stream;
 AVPacket pkt;
 const char *in_filename;
 char *out_filename;

private:
 int setOutput(const char *outfilename);
 AVOutputFormat *ofmt;
};




ffmpeg.cpp



#include "ctffmpeg.h"

CtFfmpeg::CtFfmpeg() {
 in_filename = new char [1024];
 out_filename = new char [1024];
}

CtFfmpeg::~CtFfmpeg() {
 delete [] in_filename;
 delete [] out_filename;
}

void CtFfmpeg::init() {
 avcodec_register_all();
 av_register_all();
 avformat_network_init();
 pkt = { 0 };

 av_init_packet(&pkt);
 ofmt = NULL;
 ifmt_ctx = NULL;
 ofmt_ctx = NULL;
 return;
}

int CtFfmpeg::release() {
 av_write_trailer(ofmt_ctx);
 avcodec_close(out_stream->codec);

 // avcodec_close(in_stream->codec);
 // avformat_close_input(&ifmt_ctx);

 /* close output */
 if (!(ofmt->flags & AVFMT_NOFILE))
 avio_close(ofmt_ctx->pb);

 avformat_free_context(ofmt_ctx);
 av_free_packet(&pkt);
 if (ret < 0 && ret != AVERROR_EOF) {
 fprintf(stderr, "Error occurred\n");
 return 1;
 }
}

int CtFfmpeg::getInput() {
 if ((ret = avformat_open_input(&ifmt_ctx, in_filename, 0, 0)) < 0) {
 fprintf(stderr, "Could not open input file '%s'", in_filename);
 release();
 }

 if ((ret = avformat_find_stream_info(ifmt_ctx, 0)) < 0) {
 fprintf(stderr, "Failed to retrieve input stream information");
 release();
 }

 av_dump_format(ifmt_ctx, 0, in_filename, 0);
}


int CtFfmpeg::setOutput(const char *outfilename) {
 avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, outfilename);
 if (!ofmt_ctx) {
 fprintf(stderr, "Could not create output context\n");
 ret = AVERROR_UNKNOWN;
 release();
 }

 ofmt = ofmt_ctx->oformat;
 for (int i = 0; i < ifmt_ctx->nb_streams; i++) {
 in_stream = ifmt_ctx->streams[i];
 out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec);

 if (!out_stream) {
 fprintf(stderr, "Failed allocating output stream\n");
 ret = AVERROR_UNKNOWN;
 release();
 }
 ret = avcodec_copy_context(out_stream->codec, in_stream->codec);

 if (ret < 0) {
 fprintf(stderr, "Failed to copy context from input to output stream codec context\n");
 release();
 }

 out_stream->codec->codec_tag = 0;
 if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
 out_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
 } // for

 av_dump_format(ofmt_ctx, 0, outfilename, 1);
 if (!(ofmt->flags & AVFMT_NOFILE)) {
 ret = avio_open(&ofmt_ctx->pb, outfilename, AVIO_FLAG_WRITE);
 if (ret < 0) {
 fprintf(stderr, "Could not open output file '%s'", outfilename);
 release();
 }
 }
 ret = avformat_write_header(ofmt_ctx, NULL);
 if (ret < 0) {
 fprintf(stderr, "Error occurred when opening output file\n");
 release();
 }
}

int CtFfmpeg::getOutputName(const char *filename){
 sprintf(out_filename,filename);
 setOutput(out_filename);
}




main.cpp



#include "ctfolder.h"
#include "ctffmpeg.h"

CtFfmpeg * ff;

int main(int argc, char** argv) {

 if (argc < 2) {
 printf("usage: %s <rtsp link="link"> \n", argv[0]);
 return 1;
 }

 ff = new CtFfmpeg();

 ff->in_filename = argv[1]; //RTSP input link
 ff->init();
 ff->getInput();

 string filename;

 videoRecorder obj;
 int start, now;
 start = obj.get_current_min();

 if(obj.create_folder(0755))
 cout << "Cannot create folder, maybe it already exists" << endl;
 else
 cout << "Create folder succesfully" << endl;

 int skip = 0;

 while(1){

 filename = obj.update_filename();
 ff->getOutputName(filename.c_str());

 while((now = obj.get_current_min()) == start) {
 ff->ret = av_read_frame(ff->ifmt_ctx, &(ff->pkt));
 skip++;
 if(skip==1)
 continue;

 if(skip>2)
 skip=2;
 if (ff->ret < 0)
 continue;
 ff->pkt.pts = av_rescale_q_rnd(ff->pkt.pts, ff->in_stream->time_base, ff->out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX));
 ff->pkt.dts = av_rescale_q_rnd(ff->pkt.dts, ff->in_stream->time_base, ff->out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX));
 ff->pkt.duration = av_rescale_q(ff->pkt.duration, ff->in_stream->time_base, ff->out_stream->time_base);

 ff->pkt.pos = -1;
 ff->ret = av_interleaved_write_frame(ff->ofmt_ctx, &(ff->pkt));
 if (ff->ret < 0) {
 fprintf(stderr, "Error muxing packet\n");
 continue;
 }
 av_free_packet(&(ff->pkt));
 }
 ff->release();

 cout << "New minute!" << endl;

 if(obj.create_folder(0755))
 cout << "Cannot create folder, something's wrong" << endl;
 else
 cout << "Create folder succesfully" << endl;
 start = now;
 }

 return 0;
}
</rtsp>


-
Stream Live IP cam to Youtube on FFMPEG
24 juillet 2018, par Håkon BerntsenI`m streaming 2 IP cams (live webcam for tourists) from 2 Raspberry Pi, using FFMPEG (version 3.4.2) to YouTube. IPcam no.1 and Raspberry no.1 fails once a month or so, and that issue is solved with a Cron job that restarts the scripts if the service is not running.
The stream from IPcam no.2 fail after 1 hour to maybe 24 hours, even though its the same FFMPEG command and same setup.
FFMPEG keep streaming and the service is running on the Raspberry. YouTube stop receiving the stream, but there is no logs to be found at YouTube.The bandwidth is not an issue (fiber), and the cameras are both connect with Cat5 cable. The only way to restart the stream (so YouTube restart the stream) is to restart the service (since its an cronjob that restart the service only if the service is no longer running, I`m forced to do a pkill). I have also tried to set up another cron job that kills the service every 15 minutes, but its not really an elegant solution.
Both cameras streams H264.
Stream no.2 can be seen here : https://www.youtube.com/embed/live_stream?channel=UCEJJjA5IsjE0JjuiqfxZFaw
The command I`m using is :
COMMAND="sudo ffmpeg -f lavfi -i anullsrc -thread_queue_size 512 -rtsp_transport tcp -i ${RTSP_URL} -vcodec libx264 -pix_fmt + -c:v copy -c:a aac -f flv ${YOUTUBE_URL}/${YOUTUBE_KEY}"
I hope there is someone that can help with ideas to the command or to why the stream fail.
-
FFmpeg create output directory hierarchy
23 avril 2017, par DavidRecently bought an ip-cam which outputs a RTSP stream. I’m using the segment option of FFmpeg to create 60 minute long recordings.
I want FFmpeg to write the files to a directory based on
Year/Month/Date
, and write to a fileHour-Minute.mp4
For example :
/raid1/homes/share/public/recordings/queue/bedroom/2017/04/23/13-05.mp4
for a recording started on 23 april 2017, 13:05.Unfortunately FFmpeg seems to not create the directory hierarchy. FFmpeg quits since the directory can not be found.
Input #0, rtsp, from 'rtsp://192.168.1.240/unicast':
Metadata:
title : LIVE555 Streaming Media v2014.07.04
comment : LIVE555 Streaming Media v2014.07.04
Duration: N/A, start: 0.000750, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p, 1920x1080, 90k tbr, 90k tbn, 180k tbc
Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s
[segment @ 0x2557300] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
[segment @ 0x2557300] Failed to open segment '/raid1/homes/share/public/recordings/queue/bedroom/2017/04/23/14-19.mp4'
Output #0, segment, to '/raid1/homes/share/public/recordings/queue/bedroom/%Y/%m/%d/%H-%M.mp4':
Metadata:
title : LIVE555 Streaming Media v2014.07.04
comment : LIVE555 Streaming Media v2014.07.04
encoder : Lavf57.41.100
Stream #0:0: Video: h264, yuv420p, 1920x1080, q=2-31, 90k tbr, 90k tbn, 90k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): No such file or directoryrecord.sh is as follows :
#!/bin/sh
ffmpeg -stimeout 600\
-rtsp_transport udp \
-i rtsp://192.168.1.240/unicast \
-c copy \
-map 0:0 \
-f segment \
-segment_time 3600 \
-segment_wrap 100 \
-segment_format mov \
-strftime 1 \
-reset_timestamps 1 \
"/raid1/homes/share/public/recordings/queue/bedroom/%Y/%m/%d/%H-%M.mp4"I’ve tried not using a directory hierachy :
"/raid1/homes/share/public/recordings/queue/bedroom/%Y-%m-%d_%H-%M.mp4"
. This works fine.$ ffmpeg -version
ffmpeg version N-80901-gfebc862 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100Can FFmpeg create output directories on the go ?