
Recherche avancée
Autres articles (111)
-
MediaSPIP Core : La Configuration
9 novembre 2010, parMediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...) -
Submit bugs and patches
13 avril 2011Unfortunately a software is never perfect.
If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
You may also (...) -
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
Sur d’autres sites (4122)
-
FFMPEG encrypted HLS single file is unplayable
17 septembre 2019, par 3bodyZZi use this command to generate the byterange segments
ffmpeg -i test.mp4 -hls_time 20 -hls_flags single_file -hls_key_info_file key_info out.m3u8
here is the output m3u8#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:24
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-KEY:METHOD=AES-128,URI="key.bin"
#EXTINF:23.933333,
#EXT-X-BYTERANGE:1016328@0
out.ts
#EXTINF:19.200000,
#EXT-X-BYTERANGE:824192@1016328
out.ts
#EXTINF:16.866667,
#EXT-X-BYTERANGE:714024@1840520
out.ts
#EXT-X-ENDLISTand it does output incorrect byte range m3u8 file that is unplayable, i have tried the multiple segments and it works just fine but i need the single file, any one knows how to fix this ?
here is the logs from ffmpeg
ffmpeg version N-94167-ga514244319 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.1.1 (GCC) 20190621
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. 30.100 / 56. 30.100
libavcodec 58. 53.101 / 58. 53.101
libavformat 58. 28.101 / 58. 28.101
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 56.100 / 7. 56.100
libswscale 5. 4.101 / 5. 4.101
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'ttt.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:01:00.16, start: 0.000000, bitrate: 227 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 480x320, 157 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 64 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 000001df1e25dd80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000001df1e25dd80] profile Progressive High, level 2.1, 4:2:0, 8-bit
[libx264 @ 000001df1e25dd80] 264 - core 157 r2970 5493be8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[hls @ 000001df1e25ac80] Opening 'key_info' for reading
[hls @ 000001df1e25ac80] Opening 'key.bin' for reading
[hls @ 000001df1e25ac80] Opening 'crypto:out.ts' for writing
Output #0, hls, to 'out.m3u8':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.28.101
Stream #0:0(und): Video: h264 (libx264), yuv420p, 480x320, q=-1--1, 30 fps, 90k tbn, 30 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.53.101 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: aac (LC), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.53.101 aac
[hls @ 000001df1e25ac80] Opening 'out.m3u8.tmp' for writinge=N/A speed=25.4x
[hls @ 000001df1e25ac80] Opening 'out.m3u8.tmp' for writinge=N/A speed=23.8x
[hls @ 000001df1e25ac80] Opening 'out.m3u8.tmp' for writinge=N/A speed=23.7x
frame= 1800 fps=723 q=-1.0 Lsize=N/A time=00:01:00.11 bitrate=N/A speed=24.1x
video:1196kB audio:947kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 000001df1e25dd80] frame I:25 Avg QP:18.20 size: 18883
[libx264 @ 000001df1e25dd80] frame P:524 Avg QP:21.64 size: 1174
[libx264 @ 000001df1e25dd80] frame B:1251 Avg QP:30.70 size: 109
[libx264 @ 000001df1e25dd80] consecutive B-frames: 4.2% 7.6% 5.8% 82.4%
[libx264 @ 000001df1e25dd80] mb I I16..4: 29.1% 8.6% 62.3%
[libx264 @ 000001df1e25dd80] mb P I16..4: 1.1% 0.8% 1.1% P16..4: 14.6% 3.7% 2.2% 0.0% 0.0% skip:76.5%
[libx264 @ 000001df1e25dd80] mb B I16..4: 0.0% 0.0% 0.1% B16..8: 7.1% 0.5% 0.1% direct: 0.2% skip:92.0% L0:47.1% L1:51.6% BI: 1.3%
[libx264 @ 000001df1e25dd80] 8x8 transform intra:15.8% inter:36.0%
[libx264 @ 000001df1e25dd80] coded y,uvDC,uvAC intra: 47.5% 75.5% 54.9% inter: 1.7% 4.4% 0.7%
[libx264 @ 000001df1e25dd80] i16 v,h,dc,p: 48% 45% 5% 2%
[libx264 @ 000001df1e25dd80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 20% 48% 2% 2% 1% 2% 2% 3%
[libx264 @ 000001df1e25dd80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 27% 12% 7% 6% 5% 6% 5% 6%
[libx264 @ 000001df1e25dd80] i8c dc,h,v,p: 34% 37% 21% 7%
[libx264 @ 000001df1e25dd80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000001df1e25dd80] ref P L0: 83.5% 4.4% 9.5% 2.6%
[libx264 @ 000001df1e25dd80] ref B L0: 90.1% 8.9% 1.0%
[libx264 @ 000001df1e25dd80] ref B L1: 95.4% 4.6%
[libx264 @ 000001df1e25dd80] kb/s:163.19
[aac @ 000001df1e2138c0] Qavg: 357.178i have also tried different videos, and i have tried ffmpeg on windows and linux , i have tried compiling it myself and nothing seems to work the segments keeps repeating after reaching a certain point in the video
-
Encoding images to h264 and rtp output : SDP file without sprop-parameter-sets does not play
14 septembre 2021, par oarfishtl ;dr : I try to encode acquired camera frames to h264, send via RTP
and play this back on another device. SDP file generated by ffmpeg for
a sample video has info which my own SDP file misses. My SDP file
plays in ffplay, but not VLC, while both play ffmpeg's SDP file. I am
suspecting missing sprop-parameter-sets in my SDP file.


Ultimately I want to play this back in VLC.



I am writing code that encodes images to h264 and outputs to an RTP
server (or client ? anyway the part that is listening). I generate an
SDP file for this.


- 

- ffplay plays the stream without problem
- mplayer shows a green box embedded in a larger black box, but I read
somewhere it only supports mpegts over RTP, so not sure
- VLC does not play the SDP file.








Now when instead I use some random video and have ffmpeg output an SDP
file like so


ffmpeg -re -i some.mp4 -an -c:v copy -f rtp -sdp_file
video.sdp "rtp://127.0.0.1:5004"



I can see that the generated SDP file – which plays in both ffplay and
VLC – includes the base64 encoded
sprop-parameter-sets
field, and
removing this causes the stream to not play.

> cat video.sdp
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 58.76.100
m=video 5004 RTP/AVP 96
b=AS:1034
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;
sprop-parameter-sets=Z2QANKzZQDAA7fiMBagICAoAAAMAAgAAAwDwHjBjLA==,aOvjyyLA;
profile-level-id=640034



My own SDP file on the other hand, does not contain this information,
and VLC hangs for 10s and then stops trying with "no data received".


> cat test.sdp
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 58.76.100
m=video 44499 RTP/AVP 96
b=AS:2000
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1



So my theory is that my custom code must somehow add this SPS
information to the SDP file. But despite hours of searching, I could
not find a structured way to set the extradata field on the
AVStream
's
AVCodecParams
. The code I'm using is roughly this (I'm sure there's
unrelated errors in there) :

// variables
std::vector imgbuf;
AVFormatContext *ofmt_ctx = nullptr;
AVCodec *out_codec = nullptr;
AVStream *out_stream = nullptr;
AVCodecContext *out_codec_ctx = nullptr;
SwsContext *swsctx = nullptr;
cv::Mat canvas_;
unsigned int height_;
unsigned int width_;
unsigned int fps_;
AVFrame *frame_ = nullptr;

AVOutputFormat *format = av_guess_format("rtp", nullptr, nullptr);
const auto url = std::string("rtp://127.0.0.1:5001");
avformat_alloc_output_context2(ofmt_ctx, format, format->name, url.c_str());

out_codec = avcodec_find_encoder(AV_CODEC_ID_H264);
stream = avformat_new_stream(ofmt_ctx, out_codec);
out_codec_ctx = avcodec_alloc_context3(out_codec);

// then, for each incoming image:
while (receive_image) {
 static bool first_time = true;
 if (first_time) {
 // discover necessary params such as image dimensions from the first
 // received image
 first_time = false;
 height_ = image.rows;
 width_ = image.cols;

 codec_ctx->codec_tag = 0;
 codec_ctx->bit_rate = 2e6;
 // does nothing, unfortunately
 codec_ctx->thread_count = 1;
 codec_ctx->codec_id = AV_CODEC_ID_H264;
 codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO;
 codec_ctx->width = width_;
 codec_ctx->height = height_;
 codec_ctx->gop_size = 6;
 codec_ctx->pix_fmt = AV_PIX_FMT_YUV420P;
 codec_ctx->framerate = fps_;
 codec_ctx->time_base = av_inv_q(fps_);

 avcodec_parameters_from_context(stream, out_codec_ctx);

 // this stuff is empty: is that the problem?
 stream->codecpar->extradata = codec_ctx->extradata;
 stream->codecpar->extradata_size = codec_ctx->extradata_size;

 AVDictionary *codec_options = nullptr;
 av_dict_set(&codec_options, "profile", "high", 0);
 av_dict_set(&codec_options, "preset", "ultrafast", 0);
 av_dict_set(&codec_options, "tune", "zerolatency", 0);

 // open video encoder
 avcodec_open2(codec_ctx, codec, &codec_options);

 stream->time_base.num = 1;
 stream->time_base.den = fps_;
 avio_open(&(ofmt_ctx->pb), ofmt_ctx->filename, AVIO_FLAG_WRITE);

 /* Write a file for VLC */
 char buf[200000];
 AVFormatContext *ac[] = {ofmt_ctx};
 av_sdp_create(ac, 1, buf, 20000);
 printf("sdp:\n%s\n", buf);
 FILE *fsdp = fopen("test.sdp", "w");
 fprintf(fsdp, "%s", buf);
 fclose(fsdp);

 swsctx = sws_getContext(width_, height_, AV_PIX_FMT_BGR24, width_, height_,
 out_codec_ctx->pix_fmt, SWS_BICUBIC, nullptr,
 nullptr, nullptr);
 }

 if (!frame_) {
 frame_ = av_frame_alloc();

 std::uint8_t *framebuf = new uint8_t[av_image_get_buffer_size(
 codec_ctx->pix_fmt, width_, height_, 1)];
 av_image_fill_arrays(frame_->data, frame_->linesize, framebuf,
 codec_ctx->pix_fmt, width, height, 1);
 frame_->width = width_;
 frame_->height = height_;
 frame_->format = static_cast<int>(codec_ctx->pix_fmt);
 success = avformat_write_header(ofmt_ctx, nullptr);
 }
 if (imgbuf.empty()) {
 imgbuf.resize(height_ * width_ * 3 + 16);
 canvas_ = cv::Mat(height_, width_, CV_8UC3, imgbuf.data(), width_ * 3);
 } else {
 image.copyTo(canvas_);
 }

 const int stride[] = {static_cast<int>(image.step[0])};

 sws_scale(swsctx, &canvas_.data, stride, 0, canvas_.rows, frame_->data,
 frame_->linesize);
 frame_->pts += av_rescale_q(1, out_codec_ctx->time_base, stream->time_base);

 AVPacket pkt = {0};
 avcodec_send_frame(out_codec_ctx, frame_);
 avcodec_receive_packet(out_codec_ctx, &pkt);
 av_interleaved_write_frame(ofmt_ctx, &pkt);
}
</int></int>


Can anyone offer some advice here ?


—


Update


When setting


this->out_codec_ctx->flags |=AV_CODEC_FLAG_GLOBAL_HEADER;



extradata is actually present in the codec context, but I had to move
avcodec_parameters_from_context()
afteravcodec_open2()
, as the extradata is empty before opening the codec. I now getsprop-parameter-sets
in the SDP file, but VLC still does not play it.

-
Encoding images to h264 and rtp output : SDP file without sprop-parameter-sets does not play
14 septembre 2021, par oarfishtl ;dr : I try to encode acquired camera frames to h264, send via RTP
and play this back on another device. SDP file generated by ffmpeg for
a sample video has info which my own SDP file misses. My SDP file
plays in ffplay, but not VLC, while both play ffmpeg's SDP file. I am
suspecting missing sprop-parameter-sets in my SDP file.


Ultimately I want to play this back in VLC.



I am writing code that encodes images to h264 and outputs to an RTP
server (or client ? anyway the part that is listening). I generate an
SDP file for this.


- 

- ffplay plays the stream without problem
- mplayer shows a green box embedded in a larger black box, but I read
somewhere it only supports mpegts over RTP, so not sure
- VLC does not play the SDP file.








Now when instead I use some random video and have ffmpeg output an SDP
file like so


ffmpeg -re -i some.mp4 -an -c:v copy -f rtp -sdp_file
video.sdp "rtp://127.0.0.1:5004"



I can see that the generated SDP file – which plays in both ffplay and
VLC – includes the base64 encoded
sprop-parameter-sets
field, and
removing this causes the stream to not play.

> cat video.sdp
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 58.76.100
m=video 5004 RTP/AVP 96
b=AS:1034
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;
sprop-parameter-sets=Z2QANKzZQDAA7fiMBagICAoAAAMAAgAAAwDwHjBjLA==,aOvjyyLA;
profile-level-id=640034



My own SDP file on the other hand, does not contain this information,
and VLC hangs for 10s and then stops trying with "no data received".


> cat test.sdp
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 58.76.100
m=video 44499 RTP/AVP 96
b=AS:2000
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1



So my theory is that my custom code must somehow add this SPS
information to the SDP file. But despite hours of searching, I could
not find a structured way to set the extradata field on the
AVStream
's
AVCodecParams
. The code I'm using is roughly this (I'm sure there's
unrelated errors in there) :

// variables
std::vector imgbuf;
AVFormatContext *ofmt_ctx = nullptr;
AVCodec *out_codec = nullptr;
AVStream *out_stream = nullptr;
AVCodecContext *out_codec_ctx = nullptr;
SwsContext *swsctx = nullptr;
cv::Mat canvas_;
unsigned int height_;
unsigned int width_;
unsigned int fps_;
AVFrame *frame_ = nullptr;

AVOutputFormat *format = av_guess_format("rtp", nullptr, nullptr);
const auto url = std::string("rtp://127.0.0.1:5001");
avformat_alloc_output_context2(ofmt_ctx, format, format->name, url.c_str());

out_codec = avcodec_find_encoder(AV_CODEC_ID_H264);
stream = avformat_new_stream(ofmt_ctx, out_codec);
out_codec_ctx = avcodec_alloc_context3(out_codec);

// then, for each incoming image:
while (receive_image) {
 static bool first_time = true;
 if (first_time) {
 // discover necessary params such as image dimensions from the first
 // received image
 first_time = false;
 height_ = image.rows;
 width_ = image.cols;

 codec_ctx->codec_tag = 0;
 codec_ctx->bit_rate = 2e6;
 // does nothing, unfortunately
 codec_ctx->thread_count = 1;
 codec_ctx->codec_id = AV_CODEC_ID_H264;
 codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO;
 codec_ctx->width = width_;
 codec_ctx->height = height_;
 codec_ctx->gop_size = 6;
 codec_ctx->pix_fmt = AV_PIX_FMT_YUV420P;
 codec_ctx->framerate = fps_;
 codec_ctx->time_base = av_inv_q(fps_);

 avcodec_parameters_from_context(stream, out_codec_ctx);

 // this stuff is empty: is that the problem?
 stream->codecpar->extradata = codec_ctx->extradata;
 stream->codecpar->extradata_size = codec_ctx->extradata_size;

 AVDictionary *codec_options = nullptr;
 av_dict_set(&codec_options, "profile", "high", 0);
 av_dict_set(&codec_options, "preset", "ultrafast", 0);
 av_dict_set(&codec_options, "tune", "zerolatency", 0);

 // open video encoder
 avcodec_open2(codec_ctx, codec, &codec_options);

 stream->time_base.num = 1;
 stream->time_base.den = fps_;
 avio_open(&(ofmt_ctx->pb), ofmt_ctx->filename, AVIO_FLAG_WRITE);

 /* Write a file for VLC */
 char buf[200000];
 AVFormatContext *ac[] = {ofmt_ctx};
 av_sdp_create(ac, 1, buf, 20000);
 printf("sdp:\n%s\n", buf);
 FILE *fsdp = fopen("test.sdp", "w");
 fprintf(fsdp, "%s", buf);
 fclose(fsdp);

 swsctx = sws_getContext(width_, height_, AV_PIX_FMT_BGR24, width_, height_,
 out_codec_ctx->pix_fmt, SWS_BICUBIC, nullptr,
 nullptr, nullptr);
 }

 if (!frame_) {
 frame_ = av_frame_alloc();

 std::uint8_t *framebuf = new uint8_t[av_image_get_buffer_size(
 codec_ctx->pix_fmt, width_, height_, 1)];
 av_image_fill_arrays(frame_->data, frame_->linesize, framebuf,
 codec_ctx->pix_fmt, width, height, 1);
 frame_->width = width_;
 frame_->height = height_;
 frame_->format = static_cast<int>(codec_ctx->pix_fmt);
 success = avformat_write_header(ofmt_ctx, nullptr);
 }
 if (imgbuf.empty()) {
 imgbuf.resize(height_ * width_ * 3 + 16);
 canvas_ = cv::Mat(height_, width_, CV_8UC3, imgbuf.data(), width_ * 3);
 } else {
 image.copyTo(canvas_);
 }

 const int stride[] = {static_cast<int>(image.step[0])};

 sws_scale(swsctx, &canvas_.data, stride, 0, canvas_.rows, frame_->data,
 frame_->linesize);
 frame_->pts += av_rescale_q(1, out_codec_ctx->time_base, stream->time_base);

 AVPacket pkt = {0};
 avcodec_send_frame(out_codec_ctx, frame_);
 avcodec_receive_packet(out_codec_ctx, &pkt);
 av_interleaved_write_frame(ofmt_ctx, &pkt);
}
</int></int>


Can anyone offer some advice here ?


—


Update


When setting


this->out_codec_ctx->flags |=AV_CODEC_FLAG_GLOBAL_HEADER;



extradata is actually present in the codec context, but I had to move
avcodec_parameters_from_context()
afteravcodec_open2()
, as the extradata is empty before opening the codec. I now getsprop-parameter-sets
in the SDP file, but VLC still does not play it.