
Advanced search
Medias (1)
-
Rennes Emotion Map 2010-11
19 October 2011, by
Updated: July 2013
Language: français
Type: Text
Other articles (53)
-
Keeping control of your media in your hands
13 April 2011, byThe vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...) -
Les images
15 May 2013 -
Mediabox : ouvrir les images dans l’espace maximal pour l’utilisateur
8 February 2011, byLa visualisation des images est restreinte par la largeur accordée par le design du site (dépendant du thème utilisé). Elles sont donc visibles sous un format réduit. Afin de profiter de l’ensemble de la place disponible sur l’écran de l’utilisateur, il est possible d’ajouter une fonctionnalité d’affichage de l’image dans une boite multimedia apparaissant au dessus du reste du contenu.
Pour ce faire il est nécessaire d’installer le plugin "Mediabox".
Configuration de la boite multimédia
Dès (...)
On other websites (7695)
-
How to send large x264 NAL over RTMP?
17 September 2017, by samgakI’m trying to stream video over RTMP using x264 and rtmplib in C++ on Windows.
So far I have managed to encode and stream a test video pattern consisting of animated multi-colored vertical lines that I generate in code. It’s possible to start and stop the stream, and start and stop the player, and it works every time. However, as soon as I modify it to send encoded camera frames instead of the test pattern, the streaming becomes very unreliable. It only starts <20% of the time, and stopping and restarting doesn’t work.
After searching around for answers I concluded that it must be because the NAL size is too large (my test pattern is mostly flat color so it encodes to a very small size), and there is an Ethernet packet limit of around 1400 bytes that affects it. So, I tried to make x264 only output NALs under 1200 bytes, by setting
i_slice_max_size
in my x264 setup:if (x264_param_default_preset(&param, "veryfast", "zerolatency") < 0)
return false;
param.i_csp = X264_CSP_I420;
param.i_threads = 1;
param.i_width = width; //set frame width
param.i_height = height; //set frame height
param.b_cabac = 0;
param.i_bframe = 0;
param.b_interlaced = 0;
param.rc.i_rc_method = X264_RC_ABR;
param.i_level_idc = 21;
param.rc.i_bitrate = 128;
param.b_intra_refresh = 1;
param.b_annexb = 1;
param.i_keyint_max = 25;
param.i_fps_num = 15;
param.i_fps_den = 1;
param.i_slice_max_size = 1200;
if (x264_param_apply_profile(&param, "baseline") < 0)
return false;This reduces the NAL size, but it doesn’t seem to make any difference to the reliability issues.
I’ve also tried fragmenting the NALs, using this Java code and RFC 3984 (RTP Payload Format for H.264 Video) as a reference, but it doesn’t work at all (code below), the server says "stream has stopped" immediately after it starts. I’ve tried including and excluding the NAL header (with the timestamp etc) in each fragment or just the first, but it doesn’t work for me either way.
I’m pretty sure my issue has to be with the NAL size and not PPS/SPS or anything like that (as in this question) or with my network connection or test server, because everything works fine with the test pattern.
I’m sending
NAL_PPS
andNAL_SPS
(only once), and allNAL_SLICE_IDR
andNAL_SLICE
packets. I’m ignoringNAL_SEI
and not sending it.One thing that is confusing me is that the source code that I can find on the internet that does similar things to what I want doesn’t match up with what the RFC specifies. For example, RFC 3984 section 5.3 defines the NAL octet, which should have the NAL type in the lower 5 bits and the NRI in bits 5 and 6 (bit 7 is zero). The types NAL_SLICE_IDR and NAL_SLICE have values of 5 and 1 respectively, which are the ones in table 7-1 of this document (PDF) referenced by the RFC and also the ones output by x264. But the code that actually works sets the NAL octet to 39 (0x27) and 23 (0x17), for reasons unknown to me. When implementing fragmented NALs, I’ve tried both following the spec and using the values copied over from the working code, but neither works.
Any help appreciated.
void sendNAL(unsigned char* buf, int len)
{
Logging::LogNumber("sendNAL", len);
RTMPPacket * packet;
long timeoffset = GetTickCount() - startTime;
if (buf[2] == 0x00) { //00 00 00 01
buf += 4;
len -= 4;
}
else if (buf[2] == 0x01) { //00 00 01
buf += 3;
len -= 3;
}
else
{
Logging::LogStdString("INVALID x264 FRAME!");
}
int type = buf[0] & 0x1f;
int maxNALSize = 1200;
if (len <= maxNALSize)
{
packet = (RTMPPacket *)malloc(RTMP_HEAD_SIZE + len + 9);
memset(packet, 0, RTMP_HEAD_SIZE);
packet->m_body = (char *)packet + RTMP_HEAD_SIZE;
packet->m_nBodySize = len + 9;
unsigned char *body = (unsigned char *)packet->m_body;
memset(body, 0, len + 9);
body[0] = 0x27;
if (type == NAL_SLICE_IDR) {
body[0] = 0x17;
}
body[1] = 0x01; //nal unit
body[2] = 0x00;
body[3] = 0x00;
body[4] = 0x00;
body[5] = (len >> 24) & 0xff;
body[6] = (len >> 16) & 0xff;
body[7] = (len >> 8) & 0xff;
body[8] = (len) & 0xff;
memcpy(&body[9], buf, len);
packet->m_hasAbsTimestamp = 0;
packet->m_packetType = RTMP_PACKET_TYPE_VIDEO;
if (rtmp != NULL) {
packet->m_nInfoField2 = rtmp->m_stream_id;
}
packet->m_nChannel = 0x04;
packet->m_headerType = RTMP_PACKET_SIZE_LARGE;
packet->m_nTimeStamp = timeoffset;
if (rtmp != NULL) {
RTMP_SendPacket(rtmp, packet, QUEUE_RTMP);
}
free(packet);
}
else
{
packet = (RTMPPacket *)malloc(RTMP_HEAD_SIZE + maxNALSize + 90);
memset(packet, 0, RTMP_HEAD_SIZE);
// split large NAL into multiple smaller ones:
int sentBytes = 0;
bool firstFragment = true;
while (sentBytes < len)
{
// decide how many bytes to send in this fragment:
int fragmentSize = maxNALSize;
if (sentBytes + fragmentSize > len)
fragmentSize = len - sentBytes;
bool lastFragment = (sentBytes + fragmentSize) >= len;
packet->m_body = (char *)packet + RTMP_HEAD_SIZE;
int headerBytes = firstFragment ? 10 : 2;
packet->m_nBodySize = fragmentSize + headerBytes;
unsigned char *body = (unsigned char *)packet->m_body;
memset(body, 0, fragmentSize + headerBytes);
//key frame
int NALtype = 0x27;
if (type == NAL_SLICE_IDR) {
NALtype = 0x17;
}
// Set FU-A indicator
body[0] = (byte)((NALtype & 0x60) & 0xFF); // FU indicator NRI
body[0] += 28; // 28 = FU - A (fragmentation unit A) see RFC: https://tools.ietf.org/html/rfc3984
// Set FU-A header
body[1] = (byte)(NALtype & 0x1F); // FU header type
body[1] += (firstFragment ? 0x80 : 0) + (lastFragment ? 0x40 : 0); // Start/End bits
body[2] = 0x01; //nal unit
body[3] = 0x00;
body[4] = 0x00;
body[5] = 0x00;
body[6] = (len >> 24) & 0xff;
body[7] = (len >> 16) & 0xff;
body[8] = (len >> 8) & 0xff;
body[9] = (len) & 0xff;
//copy data
memcpy(&body[headerBytes], buf + sentBytes, fragmentSize);
packet->m_hasAbsTimestamp = 0;
packet->m_packetType = RTMP_PACKET_TYPE_VIDEO;
if (rtmp != NULL) {
packet->m_nInfoField2 = rtmp->m_stream_id;
}
packet->m_nChannel = 0x04;
packet->m_headerType = RTMP_PACKET_SIZE_LARGE;
packet->m_nTimeStamp = timeoffset;
if (rtmp != NULL) {
RTMP_SendPacket(rtmp, packet, TRUE);
}
sentBytes += fragmentSize;
firstFragment = false;
}
free(packet);
}
} -
php shell_exec() command pop out error and permission denied ffmpeg
19 October 2016, by user3711175This is the main index.php file where I run my code to generate a video thumbnail with ffmpeg but it has no lucks at all I have been searching online for a lot of solution but nothing comes out i will be very appreciate if you guys can help me out. The shell_exec() keep giving me error
<form action="index.php" method="POST" enctype="multipart/form-data">
<input type="file" /><input type="submit" value="upload" />
</form>
<?php
if(isset($_POST['submit'])){
$ffmpeg = "/Users/mac/Documents/ffmpeg/3.1.4/bin/ffmpeg";
$videoFile = $_FILES["file"]["tmp_name"];
$imageFile = "1.jpg";
$size = "320x240";
$getFromSecond = 5;
$cmd = "$ffmpeg -i $videoFile -an -ss $getFromSecond -s $size $imageFile 2>&1";
echo shell_exec($cmd);
echo shell_exec('whoami');
if(!shell_exec($cmd)){
echo "thumbnail created";
}else{
echo "error creating thumbnail";
}
}
?> -
php shell_exec() command pop out error and permission denied ffmpeg
3 June 2023, by user3711175This is the main index.php file where I run my code to generate a video thumbnail with ffmpeg but it has no lucks at all I have been searching online for a lot of solution but nothing comes out i will be very appreciate if you guys can help me out. The shell_exec() keep giving me error







<form action="index.php" method="POST" enctype="multipart/form-data">
<input type="file" /><input type="submit" value="upload" />

</form>

<?php

if(isset($_POST['submit'])){


$ffmpeg = "/Users/mac/Documents/ffmpeg/3.1.4/bin/ffmpeg";
$videoFile = $_FILES["file"]["tmp_name"];
$imageFile = "1.jpg";
$size = "320x240";
$getFromSecond = 5;
$cmd = "$ffmpeg -i $videoFile -an -ss $getFromSecond -s $size $imageFile 2>&1";

 echo shell_exec($cmd);


echo shell_exec('whoami');
if(!shell_exec($cmd)){


 echo "thumbnail created";
}else{
 echo "error creating thumbnail";
}






}

?>