
Recherche avancée
Médias (91)
-
Les Miserables
9 décembre 2019, par
Mis à jour : Décembre 2019
Langue : français
Type : Textuel
-
VideoHandle
8 novembre 2019, par
Mis à jour : Novembre 2019
Langue : français
Type : Video
-
Somos millones 1
21 juillet 2014, par
Mis à jour : Juin 2015
Langue : français
Type : Video
-
Un test - mauritanie
3 avril 2014, par
Mis à jour : Avril 2014
Langue : français
Type : Textuel
-
Pourquoi Obama lit il mes mails ?
4 février 2014, par
Mis à jour : Février 2014
Langue : français
-
IMG 0222
6 octobre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Image
Autres articles (65)
-
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...) -
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page. -
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 (...)
Sur d’autres sites (9446)
-
How can I display the video on sdl converted to emscripten ?
3 février 2021, par pleasehelpI am trying to view video in a browser using ffmpeg's decoder.


So, I made the decoder into a js file using emscripten.


By the way, the decoder seems to work, but only the last scene is displayed.


How can a video come out from start to finish ?


Here is my code



#include 
#include 
#include 

#include <libavcodec></libavcodec>avcodec.h>

#include <sdl2></sdl2>SDL.h>

#define INBUF_SIZE 128

static void decode(AVCodecContext *dec_ctx, AVFrame *frame, AVPacket *pkt,
 const char *filename,
 SDL_Window * screen, SDL_Renderer * renderer, SDL_Texture * texture)
{
 char buf[1024];
 int ret;

 ret = avcodec_send_packet(dec_ctx, pkt);
 if (ret < 0) {
 fprintf(stderr, "Error sending a packet for decoding\n");
 exit(1);
 }

 while (ret >= 0) {
 ret = avcodec_receive_frame(dec_ctx, frame);
 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
 return;
 else if (ret < 0) {
 fprintf(stderr, "Error during decoding\n");
 exit(1);
 }

 printf("saving frame %3d\n", dec_ctx->frame_number);
 fflush(stdout);

 SDL_Rect rect;
 rect.x = 0;
 rect.y = 0;
 rect.w = dec_ctx->width;
 rect.h = dec_ctx->height;

 SDL_UpdateYUVTexture(
 texture, // the texture to update
 &rect, // a pointer to the rectangle of pixels to update, or NULL to update the entire texture
 frame->data[0], // the raw pixel data for the Y plane
 frame->linesize[0], // the number of bytes between rows of pixel data for the Y plane
 frame->data[1], // the raw pixel data for the U plane
 frame->linesize[1], // the number of bytes between rows of pixel data for the U plane
 frame->data[2], // the raw pixel data for the V plane
 frame->linesize[2] // the number of bytes between rows of pixel data for the V plane
 );

 SDL_RenderClear(renderer);

 SDL_RenderCopy(
 renderer, // the rendering context
 texture, // the source texture
 NULL, // the source SDL_Rect structure or NULL for the entire texture
 NULL // the destination SDL_Rect structure or NULL for the entire rendering
 // target; the texture will be stretched to fill the given rectangle
 );

 SDL_RenderPresent(renderer);
 SDL_UpdateWindowSurface(screen);
 }
}

int main(int argc, char **argv)
{
 const char *filename, *outfilename;
 const AVCodec *codec;
 AVCodecParserContext *parser;
 AVCodecContext *c= NULL;
 FILE *f;
 AVFrame *frame;
 uint8_t inbuf[INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
 uint8_t *data;
 size_t data_size;
 int ret;
 AVPacket *pkt;

 if (argc <= 2) {
 fprintf(stderr, "Usage: %s <input file="file" /> <output file="file">\n"
 "And check your input file is encoded by mpeg1video please.\n", argv[0]);
 exit(0);
 }
 filename = argv[1];
 outfilename = argv[2];

 pkt = av_packet_alloc();
 if (!pkt)
 exit(1);

 /* set end of buffer to 0 (this ensures that no overreading happens for damaged MPEG streams) */
 memset(inbuf + INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);

 ret = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER); // [1]
 if (ret != 0)
 {
 // error while initializing SDL
 printf("Could not initialize SDL - %s\n.", SDL_GetError());

 // exit with error
 // return -1;
 }

 /* find the MPEG-1 video decoder */
 codec = avcodec_find_decoder(AV_CODEC_ID_H265);
 if (!codec) {
 fprintf(stderr, "Codec not found\n");
 exit(1);
 }

 parser = av_parser_init(codec->id);
 if (!parser) {
 fprintf(stderr, "parser not found\n");
 exit(1);
 }

 c = avcodec_alloc_context3(codec);
 if (!c) {
 fprintf(stderr, "Could not allocate video codec context\n");
 exit(1);
 }

 /* open it */
 if (avcodec_open2(c, codec, NULL) < 0) {
 fprintf(stderr, "Could not open codec\n");
 exit(1);
 }

 f = fopen(filename, "rb");
 if (!f) {
 fprintf(stderr, "Could not open %s\n", filename);
 exit(1);
 }

 frame = av_frame_alloc();
 if (!frame) {
 fprintf(stderr, "Could not allocate video frame\n");
 exit(1);
 }

 // Create a window with the specified position, dimensions, and flags.
 SDL_Window * screen = SDL_CreateWindow( // [2]
 "SDL Video Player",
 SDL_WINDOWPOS_UNDEFINED,
 SDL_WINDOWPOS_UNDEFINED,
 640,
 360,
 SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI
 );

 if (!screen)
 {
 // could not set video mode
 printf("SDL: could not set video mode - exiting.\n");

 // exit with Error
 // return -1;
 }

 // //
 // SDL_GL_SetSwapInterval(1);

 // A structure that contains a rendering state.
 SDL_Renderer * renderer = NULL;

 // Use this function to create a 2D rendering context for a window.
 renderer = SDL_CreateRenderer(screen, -1, SDL_RENDERER_ACCELERATED); // [3]

 // A structure that contains an efficient, driver-specific representation
 // of pixel data.
 SDL_Texture * texture = NULL;

 // Use this function to create a texture for a rendering context.
 texture = SDL_CreateTexture( // [4]
 renderer,
 SDL_PIXELFORMAT_YV12,
 SDL_TEXTUREACCESS_STREAMING,
 640,
 360
 );

 while (!feof(f)) {
 /* read raw data from the input file */
 data_size = fread(inbuf, 1, INBUF_SIZE, f);
 if (!data_size)
 break;

 /* use the parser to split the data into frames */
 data = inbuf;
 while (data_size > 0) {
 ret = av_parser_parse2(parser, c, &pkt->data, &pkt->size,
 data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
 if (ret < 0) {
 fprintf(stderr, "Error while parsing\n");
 exit(1);
 }
 data += ret;
 data_size -= ret;

 if (pkt->size)
 decode(c, frame, pkt, outfilename, screen, renderer, texture);
 }
 }

 /* flush the decoder */
 decode(c, frame, NULL, outfilename, screen, renderer, texture);

 fclose(f);

 av_parser_close(parser);
 avcodec_free_context(&c);
 av_frame_free(&frame);
 av_packet_free(&pkt);

 return 0;
}

</output>


Is it possible to continuously play sdl in a browser ?


-
Gaps in audio when pushing rtsp stream to rtmp with ffmpeg
13 avril 2020, par user13300863I push the stream like so :



% ffmpeg -rtsp_transport tcp -i "rtsp://**********************" -codec copy -f flv rtmp://x.rtmp.youtube.com/live2/****************

ffmpeg version N-94664-g0821bc4eee Copyright (c) 2000-2019 the FFmpeg developers
 built with gcc 9.1.1 (GCC) 20190807
 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
 libavutil 56. 33.100 / 56. 33.100
 libavcodec 58. 55.101 / 58. 55.101
 libavformat 58. 31.104 / 58. 31.104
 libavdevice 58. 9.100 / 58. 9.100
 libavfilter 7. 58.101 / 7. 58.101
 libswscale 5. 6.100 / 5. 6.100
 libswresample 3. 6.100 / 3. 6.100
 libpostproc 55. 6.100 / 55. 6.100
Input #0, rtsp, from 'rtsp:*************************':
 Metadata:
 title : Media Server
 Duration: N/A, start: 0.040000, bitrate: N/A
 Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1280x720, 12 fps, 25 tbr, 90k tbn, 24 tbc
 Stream #0:1: Audio: aac (LC), 32000 Hz, mono, fltp
Output #0, flv, to 'rtmp://x.rtmp.youtube.com/live2/********************':
 Metadata:
 title : Media Server
 encoder : Lavf58.31.104
 Stream #0:0: Video: h264 (Main) ([7][0][0][0] / 0x0007), yuvj420p(pc, bt709, progressive), 1280x720, q=2-31, 12 fps, 25 tbr, 1k tbn, 90k tbc
 Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 32000 Hz, mono, fltp
Stream mapping:
 Stream #0:0 -> #0:0 (copy)
 Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[flv @ 000000000310d540] Non-monotonous DTS in output stream 0:0; previous: 557, current: 120; changing to 557. This may result in incorrect timestamps in the output file.
[flv @ 000000000310d540] Non-monotonous DTS in output stream 0:0; previous: 557, current: 200; changing to 557. This may result in incorrect timestamps in the output file.
[flv @ 000000000310d540] Non-monotonous DTS in output stream 0:0; previous: 557, current: 320; changing to 557. This may result in incorrect timestamps in the output file.
[flv @ 000000000310d540] Non-monotonous DTS in output stream 0:0; previous: 557, current: 400; changing to 557. This may result in incorrect timestamps in the output file.
[flv @ 000000000310d540] Non-monotonous DTS in output stream 0:0; previous: 557, current: 480; changing to 557. This may result in incorrect timestamps in the output file.
frame= 7 fps=0.0 q=-1.0 size= 74kB time=00:00:00.56 bitrate=1079.1kbits/s speed=1.06x 
frame= 25 fps= 19 q=-1.0 size= 188kB time=00:00:02.08 bitrate= 741.5kbits/s speed=1.61x 
frame= 49 fps= 22 q=-1.0 size= 330kB time=00:00:04.08 bitrate= 661.9kbits/s speed=1.83x 
frame= 67 fps= 25 q=-1.0 size= 392kB time=00:00:05.66 bitrate= 567.3kbits/s speed=2.07x 
frame= 72 fps= 22 q=-1.0 size= 410kB time=00:00:06.06 bitrate= 553.9kbits/s speed=1.84x 
frame= 76 fps= 20 q=-1.0 size= 488kB time=00:00:06.38 bitrate= 626.5kbits/s speed=1.67x 
frame= 86 fps= 20 q=-1.0 size= 519kB time=00:00:07.26 bitrate= 585.5kbits/s speed=1.68x 
frame= 92 fps= 19 q=-1.0 size= 538kB time=00:00:07.74 bitrate= 569.5kbits/s speed= 1.6x 
frame= 97 fps= 17 q=-1.0 size= 618kB time=00:00:08.11 bitrate= 623.8kbits/s speed=1.45x 
frame= 108 fps= 18 q=-1.0 size= 658kB time=00:00:09.02 bitrate= 597.6kbits/s speed=1.48x 
frame= 114 fps= 17 q=-1.0 size= 679kB time=00:00:09.50 bitrate= 585.3kbits/s speed=1.44x 
frame= 120 fps= 17 q=-1.0 size= 698kB time=00:00:10.02 bitrate= 570.5kbits/s speed=1.41x 
frame= 121 fps= 16 q=-1.0 size= 764kB time=00:00:10.09 bitrate= 619.8kbits/s speed=1.32x 
frame= 132 fps= 16 q=-1.0 size= 802kB time=00:00:11.01 bitrate= 596.7kbits/s speed=1.35x 
frame= 138 fps= 16 q=-1.0 size= 820kB time=00:00:11.57 bitrate= 580.6kbits/s speed=1.34x 
frame= 144 fps= 16 q=-1.0 size= 841kB time=00:00:12.05 bitrate= 571.5kbits/s speed=1.32x 
frame= 149 fps= 15 q=-1.0 size= 923kB time=00:00:12.45 bitrate= 606.8kbits/s speed=1.29x 
frame= 157 fps= 15 q=-1.0 size= 949kB time=00:00:13.13 bitrate= 592.0kbits/s speed=1.28x 
frame= 163 fps= 15 q=-1.0 size= 969kB time=00:00:13.65 bitrate= 581.3kbits/s speed=1.27x 
frame= 169 fps= 15 q=-1.0 size= 1051kB time=00:00:14.09 bitrate= 610.9kbits/s speed=1.22x 
frame= 180 fps= 15 q=-1.0 size= 1091kB time=00:00:15.05 bitrate= 593.6kbits/s speed=1.24x 
frame= 187 fps= 15 q=-1.0 size= 1113kB time=00:00:15.61 bitrate= 583.8kbits/s speed=1.23x 
frame= 192 fps= 15 q=-1.0 size= 1130kB time=00:00:16.05 bitrate= 576.7kbits/s speed=1.21x 
frame= 197 fps= 14 q=-1.0 size= 1212kB time=00:00:16.45 bitrate= 603.2kbits/s speed= 1.2x 
frame= 206 fps= 14 q=-1.0 size= 1241kB time=00:00:17.17 bitrate= 592.1kbits/s speed= 1.2x 
frame= 213 fps= 14 q=-1.0 size= 1265kB time=00:00:17.77 bitrate= 582.8kbits/s speed= 1.2x 
frame= 217 fps= 14 q=-1.0 size= 1340kB time=00:00:18.09 bitrate= 606.6kbits/s speed=1.16x 
frame= 228 fps= 14 q=-1.0 size= 1380kB time=00:00:19.05 bitrate= 593.4kbits/s speed=1.18x 
frame= 234 fps= 14 q=-1.0 size= 1399kB time=00:00:19.57 bitrate= 585.6kbits/s speed=1.17x 
frame= 240 fps= 14 q=-1.0 size= 1418kB time=00:00:20.05 bitrate= 579.4kbits/s speed=1.16x 
[flv @ 000000000310d540] Failed to update header with correct duration.
[flv @ 000000000310d540] Failed to update header with correct filesize.
frame= 241 fps= 14 q=-1.0 Lsize= 1486kB time=00:00:20.05 bitrate= 606.8kbits/s speed=1.14x 
video:1317kB audio:153kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.058846%
Exiting normally, received signal 2.





When viewed on youtube the stream audio is distorted i.e. it has regular 7ms gaps between each 32ms sound portions.



However, when I save the input stream to a file the audio is fine.
I've experimented with different input/output options for ffmpeg including transcoding the audio stream but nothing helped fix the issue. I think ffmpeg is the culprit here, since VLC or other streaming services like angelcam etc can play the rtsp stream without any distortions.


-
Streaming by ffserver and ffmpeg on RaspberryPi
15 septembre 2018, par saitoibI want to ditribute the video of the UVC Camera on Rpsberry Pi
I edited /etc/ffserver.conf as follows.HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 20
MaxClients 10
MaxBandwidth 500000
CustomLog -
<feed>
File /tmp/feed1.ffm
FileMaxSize 50M
</feed>
<stream>
Format status
ACL allow 192.168.12.0 192.168.12.255
</stream>
<stream>
Feed feed1.ffm
Format mpeg
VideoSize hd720
VideoFrameRate 15
VideoBitRate 4096
VideoBufferSize 4096
VideoQMin 5
VideoQMax 51
Strict -1
</stream>Then, I started ffserver
Next, I executed the following commandffmpeg -f v4l2 -s 1280x720 -i /dev/video0 -ac 1 -f alsa -i hw:1,0 http://localhost:8090/feed1.ffm
I requested 192.168.12.101 : 8090 / test.mpeg from FireFox on the same network,
but no video is displayed and a program to open or a file save dialog opens.What should I do ?
Execution result of Raspberry Pi
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 519134.790720, bitrate: 147456 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, 147456 kb/s, 10 fps, 10 tbr, 1000k tbn, 1000k tbc
Guessed Channel Layout for Input Stream #1.0 : mono
Input #1, alsa, from 'hw:1,0':
Duration: N/A, start: 1536994777.250578, bitrate: 768 kb/s
Stream #1:0: Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s
[tcp @ 0x23ec7f0] Connection to tcp://localhost:8090 failed (Connection refused), trying next address
Sat Sep 15 15:59:37 2018 [ffm @ 0xf10e40]Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Sat Sep 15 15:59:37 2018 [ffm @ 0xf10e40]Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Sat Sep 15 15:59:37 2018 127.0.0.1 - - [GET] "/feed1.ffm HTTP/1.1" 200 4175
[tcp @ 0x2401d50] Connection to tcp://localhost:8090 failed (Connection refused), trying next address
Output #0, ffm, to 'http://localhost:8090/feed1.ffm':
Metadata:
creation_time : now
encoder : Lavf57.56.101
Stream #0:0: Audio: mp2, 22050 Hz, mono, s16, 64 kb/s
Metadata:
encoder : Lavc57.64.101 mp2
Stream #0:1: Video: mpeg1video, yuv420p, 1280x720, q=5-51, 4096 kb/s, 10 fps, 1000k tbn, 15 tbc
Metadata:
encoder : Lavc57.64.101 mpeg1video
Side data:
cpb: bitrate max/min/avg: 8192000/0/4096000 buffer size: 33554432 vbv_delay: -1
Stream mapping:
Stream #1:0 -> #0:0 (pcm_s16le (native) -> mp2 (native))
Stream #0:0 -> #0:1 (rawvideo (native) -> mpeg1video (native))
Press [q] to stop, [?] for help
[alsa @ 0x23ebee0] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[alsa @ 0x23ebee0] ALSA buffer xrun. 48kB time=00:00:00.13 bitrate=2949.1kbits/s dup=3 drop=0 speed=0.251x
[video4linux2,v4l2 @ 0x23ea230] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
[alsa @ 0x23ebee0] ALSA buffer xrun.276kB time=00:00:02.40 bitrate= 942.1kbits/s dup=30 drop=0 speed=0.201x
Sat Sep 15 15:59:55 2018 [mpeg @ 0xf136d0]VBV buffer size not set, using default size of 130KB speed=0.844x
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
frame= 107 fps=3.1 q=2.0 Lsize= 856kB time=00:00:14.06 bitrate= 498.6kbits/s dup=80 drop=0 speed=0.413x
video:844kB audio:2kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.120285%
Sat Sep 15 16:00:11 2018 127.0.0.1 - - [POST] "/feed1.ffm HTTP/1.1" 200 876544
Sat Sep 15 16:00:11 2018 [mpeg @ 0xf136d0]buffer underflow st=0 bufi=0 size=418
Sat Sep 15 16:00:11 2018 192.168.12.150 - - [GET] "/test.mpeg HTTP/1.1" 200 29263
Exiting normally, received signal 2.Result of 192.168.12.101:8090
ffserver Status
Available Streams
Path Served
Conns
bytes Format Bit rate
kbit/s Video
kbit/s
Codec Audio
kbit/s
Codec Feed
index.html 1 0 - - - -
test.mpeg 0 0 mpeg 4160 4096 mpeg1video 64 mp2 feed1.ffm
Feed feed1.ffm
Stream type kbit/s codec Parameters
0 audio 64 mp2 1 channel(s), 22050 Hz
1 video 4096 mpeg1video 1280x720, q=5-51, fps=15
Connection Status
Number of connections: 1 / 10
Bandwidth in use: 0k / 10000k
# File IP Proto State Target bit/s Actual bit/s Bytes transferred
1 index.html 192.168.12.150 HTTP/1.1 HTTP_WAIT_REQUEST 0 0 0