
Recherche avancée
Autres articles (92)
-
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...) -
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)
Sur d’autres sites (10911)
-
Encoding of video returns 0, and nothing written to the output file
14 juillet 2014, par AnilJI have written a code to record the webcam feed into a file on disk. I am attempting to do this using IContainer class rather than IMediaWriter class. I am pasting the code snippet below showing important sections of the code.
The problem I am facing is that nothing is being written to the file. Some of the observations I have made are as follows :
- In the Record() function, the ’while’ loop is kicked off, but the mVideoEncoder.encodeVideo(packet, frame, offset) ; method always returns zero (0). This results in no picture complete and no data is being written to the output file. Can you please provide clue as to what is missing ?
- I checked that the frame size is 80640, which confirms that frame has data.
- I see that only header and trailer is being written to the file.
Let me know if you need any other information.
public class WebcamRecorder {
private boolean StartVideoEncoder() {
boolean result = true;
// Open a container
mPositionInMicroseconds = 0;
mOutputContainer = IContainer.make();
mOutputContainer.open(mOutputFileName, IContainer.Type.WRITE, null);
// Create the video stream and get its coder
ICodec videoCodec = ICodec.findEncodingCodec(ICodec.ID.CODEC_ID_H264);
IStream videoStream = mOutputContainer.addNewStream(videoCodec);
mVideoEncoder = videoStream.getStreamCoder();
// Setup the stream coder
mFrameRate = IRational.make(1, 30);
mVideoEncoder.setWidth(Constants.RESAMPLE_PICT_WIDTH);
mVideoEncoder.setHeight(Constants.RESAMPLE_PICT_HEIGHT);
mVideoEncoder.setFrameRate(mFrameRate);
mVideoEncoder.setTimeBase(IRational.make(mFrameRate.getDenominator(),
mFrameRate.getNumerator()));
mVideoEncoder.setBitRate(350000);
mVideoEncoder.setNumPicturesInGroupOfPictures(30);
mVideoEncoder.setPixelType(IPixelFormat.Type.YUV420P);
mVideoEncoder.setFlag(IStreamCoder.Flags.FLAG_QSCALE, true);
mVideoEncoder.setGlobalQuality(0);
// Open the encoder
mVideoEncoder.open(null, null);
// Write the header
mOutputContainer.writeHeader();
return result;
}
public void Record() {
picture = GetNextPicture();
image = Utils.videoPictureToImage(picture);
// convert to the right image type
BufferedImage bgrScreen = ConvertToType(image, BufferedImage.TYPE_3BYTE_BGR);
IConverter converter = ConverterFactory.createConverter(bgrScreen, mVideoEncoder.getPixelType());
IVideoPicture frame = converter.toPicture(bgrScreen, mPositionInMicroseconds);
frame.setQuality(0);
IPacket packet = IPacket.make();
int offset = 0;
while (offset < frame.getSize()) {
int bytesEncoded = mVideoEncoder.encodeVideo(packet, frame, offset);
if (bytesEncoded < 0) {
throw new RuntimeException("Unable to encode video.");
}
offset += bytesEncoded;
if (packet.isComplete()) {
System.out.println("Packet is complete");
if (mOutputContainer.writePacket(packet) < 0) {
throw new RuntimeException(
"Could not write packet to container.");
}
// Update frame time
mPositionInMicroseconds += (mFrameRate.getDouble() * Math.pow(1000, 2));
break;
}
}
}
public void Cleanup() {
if (mOutputContainer != null) {
mOutputContainer.writeTrailer();
mOutputContainer.close();
// mOutputContainer.flushPackets();
}
if (mVideoEncoder != null) {
mVideoEncoder.close();
}
}
} -
Reading a File while it is being written by FFMPEG
29 mai 2014, par Haris TasawarAs the title suggests, i am in the process of creating a client/server application where the server(PHP) reads a file which is being written on by ffmpeg and then outputs it to the client(JAVA). I have succeeded in writing the server script in php which initiates the ffmpeg and then after a while starts to read the file and concurrently sends it to the JAVA client, the problem is that after a while the client stops to receive any sort of data and then just quits, For example if i have a 5MB file, it would read only 12KB and then it quits. Could someone tell what can be the issue here ? Is it on the server side or on the client side.
For References i am attaching both the reading of file code in php and the client side code.Code For Reading the file while FFMPEG converts the file(PHP) :
$file = 'D:\\'.$destination;
$fp = @fopen($file, 'r');
//ob_end_clean();
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header("Cache-control: private");
header('Pragma: private');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Content-Length: ' . filesize($file));
$buffer = 4096;
while(!feof($fp)) {
usleep(300000);
echo fread($fp, $buffer);
ob_flush();
flush();
}
fclose($fp);
exit();Code For reading the File transferred by PHP (JAVA) :
URL u = new URL(streamURL);
clientSocket = (HttpURLConnection) u.openConnection();
if( clientSocket.getResponseCode() == HttpURLConnection.HTTP_OK ){
//clientSocket.setReadTimeout(0);
inRemoteStream = clientSocket.getInputStream();
while (((count = inRemoteStream.read(buf)) != -1)) {
offset += count;
System.out.println(offset);
fileOutputStream.write(buf, 0, count);
setVideoOffset(offset, contentLength);
}I`ll be very happy if someone can solve this problem for me :) .
-
Reading from a stream while its constantly being written to
11 octobre 2017, par TomCrowI have a ip camera, which I need to read video stream from and get frames to bitmaps. For that I want to use NReco VideoConverter, which is ffmpeg .net wrapper. I use it like this :
liveTask = ffMpeg.ConvertLiveMedia(inputStream, Format.h264, outputStream, Format.raw_video, new ConvertSettings() { CustomOutputArgs = "-pix_fmt rgb32" });
liveTask.OutputDataReceived += new EventHandler(Recieved);
liveTask.Start();Works fine, but my problem is that I need to read frames from that outputStream. The video converter writes to the stream constantly and calls my "Recieved" after every write. What I have is something like this :
private void Recieved(object sender, EventArgs r)
{
int lenght = Width * Height * 4;
if (outputStream.Length > lenght)
{
outputStream.Seek(0, SeekOrigin.Begin);
byte[] buffer = new byte[lenght];
int ret = outputStream.Read(buffer, 0, buffer.Length);
Bitmap frame = CreateBitmapFromRawDataBuffer(buffer);
}
}Works great, but only for the first frame, cause the Seek is a problem, because I think position of the stream is always at the and and I also dont know how to check if there is written another frame, cause the lenght of the whole stream is only adding up. And that would be another problem, cause the streams lenght cant go up forever. The app is supposed to run nonstop 24/7, while decoding h264 data from a ip camera. Could anyone help me with this ? And if Iam using the stream the right way ? Thank you.
Edit : For reading and writing together I know I could make custom stream with locking and separated positions for reading and writing, but what bothers me is the still adding lenght of the innerstream or outputstream in general and checking if there is next Width * Height * 4 bytes available for reading.