
Recherche avancée
Médias (2)
-
Granite de l’Aber Ildut
9 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
Géodiversité
9 septembre 2011, par ,
Mis à jour : Août 2018
Langue : français
Type : Texte
Autres articles (15)
-
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...) -
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
Gestion des droits de création et d’édition des objets
8 février 2011, parPar défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;
Sur d’autres sites (3910)
-
how to send audio or video by packet though udp
20 janvier 2019, par Wei Wenhow to send part of video and audio from mp4 as packet though udp from server
Client will play the part of packet resevice.import java.awt.Dimension ; import java.awt.image.BufferedImage ; import
java.io.ByteArrayOutputStream ; import java.io.IOException ; import
java.io.ObjectOutputStream ; import java.math.BigInteger ; import
java.net.DatagramPacket ; import java.net.DatagramSocket ; import
java.net.ServerSocket ; import java.net.Socket ; import
java.nio.ByteBuffer ; import java.nio.ShortBuffer ; import
java.util.ArrayList ; import java.util.Arrays ; import
javax.imageio.ImageIO ; import javax.sound.sampled.AudioFileFormat ;
import javax.sound.sampled.AudioFormat ; import javax.swing.JTextArea ;import org.bytedeco.javacv.FFmpegFrameGrabber ; import
org.bytedeco.javacv.Frame ; import
org.bytedeco.javacv.Java2DFrameConverter ;import Enum.EType.ClientState ; import View.SingleDisplayWindow ;
import java.security.InvalidKeyException ; import
java.security.NoSuchAlgorithmException ; import java.util.Timer ; import
java.util.TimerTask ; import java.util.concurrent.CountDownLatch ;
import java.util.concurrent.ExecutionException ;import javax.crypto.BadPaddingException ; import
javax.crypto.IllegalBlockSizeException ; import
javax.crypto.NoSuchPaddingException ; import
org.bytedeco.javacv.FrameGrabber ;public class SCon private final static int PORT = 8888 ;
private final JTextArea TEXT_AREA ; private volatile
SingleDisplayWindow DISPLAY ; /////private final String BD_USER_NAME, DB_PASSWORD ; private Database
database ;private boolean isRunning ;
private RSA serverRSA, clientRSA ;
private int keyIndex, typeID = 0 ; private String mediatype = "" ;
private ArrayList sHandlers ;private FileStreamingThread fileStreamingThread ; private
VideoStreamingThread videoStreamingThread ; private BroadcastThread
broadcastThread ; private ConnectThread connectThread ;private volatile static byte[] currentVideoFrame = new byte[0],
currentAudioFrame = new byte[0] ; // current image musicpublic void run() startServer() ;
isRunning = true; fileStreamingThread = new
FileStreamingThread(videoFile) ; videoStreamingThread = new
VideoStreamingThread(videoFile) ;
//CountDownLatch latch = new CountDownLatch(1) ; fileStreamingThread.start() ; videoStreamingThread.start() ;
//latch.countDown() ;broadcastThread = new BroadcastThread(); broadcastThread.start();
connectThread = new ConnectThread(); connectThread.start(); }public void stop() isRunning = false ;
try { new Socket("localhost", PORT);
} catch (IOException e) { e.printStackTrace(); }
while (fileStreamingThread.isAlive()) {
}
while (broadcastThread.isAlive()) {
}
while (connectThread.isAlive()) {
}
for (SHandler sHandler : sHandlers) { sHandler.connectionClose();
} sHandlers.clear(); DISPLAY.dispose();
TEXT_AREA.append("\nServer stop\n"); }
private class VideoStreamingThread extends Thread { privateFFmpegFrameGrabber grabber ; // Used to extract frames from video file.
private Java2DFrameConverter converter ; // Used to convert frames to
image private int curIndex ; // Current key indexpublic VideoStreamingThread(String video_file) { videoFile =
videoFile ; grabber = new FFmpegFrameGrabber(videoFile) ;
converter = new Java2DFrameConverter() ; try
grabber.restart() ;} catch (FrameGrabber.Exception e) {
e.printStackTrace(); } curIndex = keyIndex; }
public void run() { try {
while (isRunning) {
curIndex = keyIndex;
Frame frame = null;
System.out.println("v1");
if ((frame = grabber.grab()) != null) { // Grab next frame from video file
if (frame.image != null) { // image frame
BufferedImage bi = converter.convert(frame); // convert frame to image
// Convert BufferedImage to byte[]
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bi, "jpg", baos);
// Encrypt data and store as the current image of byte[] type
currentVideoFrame = ciphers[curIndex].doFinal(baos.toByteArray());
//////////////////
DISPLAY.setSize(new Dimension(bi.getWidth(), bi.getHeight()));
DISPLAY.updateImage(bi); // Display image
// Thread.sleep((long) ( 999 / grabber.getFrameRate()));
///////////////
typeID = 1;
mediatype = grabber.getFormat();
}
} else {
grabber.restart();
} // Restart when reached end of video
}
grabber.close();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} //catch (InterruptedException e) {e.printStackTrace(); } }
public synchronized int getCurKeyIndex() { return curIndex; }
public synchronized void getVideoFile(String video_file) {
videoFile = video_file; grabber = newFFmpegFrameGrabber(video_file) ; converter = new
Java2DFrameConverter() ;try {
grabber.release();
grabber.restart();
} catch (FrameGrabber.Exception e) {
e.printStackTrace(); } } } private class FileStreamingThread extends Thread { private FFmpegFrameGrabbergrabber ; // Used to extract frames from video file. private int
curIndex ; // Current key indexpublic FileStreamingThread(String video_file) { videoFile =
videoFile ; grabber = new FFmpegFrameGrabber(videoFile) ; try
grabber.restart() ;} catch (FrameGrabber.Exception e) {
e.printStackTrace(); } curIndex = keyIndex; }
public void run() { try {
while (isRunning) {
curIndex = keyIndex;
Frame frame = null;
System.out.println("a2");
if ((frame = grabber.grabSamples()) != null) { // Grab next frame from video file
if (frame.samples != null) { // audio frame
// Encrypt audio
ShortBuffer channelSamplesShortBuffer = (ShortBuffer) frame.samples[0];
channelSamplesShortBuffer.rewind();
ByteBuffer outBuffer = ByteBuffer.allocate(channelSamplesShortBuffer.capacity() * 2);
for (int i = 0; i < channelSamplesShortBuffer.capacity(); i++) {
short val = channelSamplesShortBuffer.get(i);
outBuffer.putShort(val);
}
AudioFileFormat audiofileFormat = new AudioFileFormat(null, null, typeID);
AudioFormat audioFormat = new AudioFormat(44100, 16, 2, true, true);
//System.out.println(grabber.getSampleFormat());
// Encrypt data and store as the current audio of byte[] type
currentAudioFrame = ciphers[curIndex].doFinal(outBuffer.array());
DISPLAY.updateAudio(outBuffer.array(), grabber.getFormat()); // Display image audio
// Thread.sleep((long) (1000 / grabber.getSampleRate()));
// Thread.sleep((long) (1000 / grabber.getAudioBitrate()));
// System.out.println(grabber.getFormat());
// System.out.println("audioInputStream.getFormat() = " +grabber.getFormat()) ; // System.out.println("Sample.length
= " + grabber.length) ; // System.out.println("FrameLength :" + grabber.getFrameLength()) ; //
System.out.println("Frame Size :" + grabber.getFrameSize()) ; //
System.out.println("SampleSizeInBits :" +
grabber.getSampleSizeInBits()) ; //
System.out.println("Frame Rate : " + grabber.getFrameRate()) ; //
System.out.println("Sample Rate :" + grabber.getSampleRate()) ; //
System.out.println("Encoding :" + grabber.getEncoding()) ; //
System.out.println("Channels : " + grabber.getChannels()) ;
// AudioFormat audioFormat = new AudioFormat(grabber.getSampleRate(), grabber.getAudioBitrate(),
grabber.getAudioChannels(), true, true) ;
// DISPLAY.updateAudio(outBuffer.array(), audioFormat) ; //
Display image audio
outBuffer.clear() ;typeID = 2;
mediatype = grabber.getFormat();
}
} else {
grabber.restart();
} // Restart when reached end of video
}
grabber.close();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} }
public synchronized int getCurKeyIndex() { return curIndex; }
public synchronized void getVideoFile(String video_file) {
videoFile = video_file; grabber = newFFmpegFrameGrabber(video_file) ;
try {
grabber.release();
grabber.restart();
} catch (FrameGrabber.Exception e) {
e.printStackTrace(); } } }public void setVideoFile(String videoFile) this.videoFile =
videoFile ;public void setThreadFile(String video_file)
fileStreamingThread.getVideoFile(video_file) ;
videoStreamingThread.getVideoFile(video_file) ;private class BroadcastThread extends Thread public void run()
while (isRunning)
Thread.yield() ;for (int i = 0; i < sHandlers.size(); i++) {
if (sHandlers.get(i).getClientState() == ClientState.R) {
sHandlers.get(i).setClientState(ClientState.W);
BroadcastWorker workerThread = new BroadcastWorker(sHandlers.get(i));
workerThread.start();
}
} } } }private class BroadcastWorker extends Thread SHandler sHandler =
null ;public BroadcastWorker(SHandler sHandler) { this.sHandler =
sHandler ;
public void run() { try {
DatagramSocket out = new DatagramSocket(); // used to send UDP packets
while (sHandler.getClientState() == ClientState.W) {
Thread.yield();
StreamFile s = new StreamFile(typeID, currentVideoFrame, currentAudioFrame, mediatype);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(outputStream);
os.writeObject(s);
byte[] data = outputStream.toByteArray();
// Create and send UDP packet
DatagramPacket videoPacket = new DatagramPacket(data, data.length,
sHandler.getClientSocket().getInetAddress(),
Integer.parseInt(sHandler.getClientPort()));
out.send(videoPacket);
} } catch (IOException e) {
e.printStackTrace(); } } }private class ConnectThread extends Thread public void run()
TEXT_AREA.append("\nWaiting for clients’ connection.....\n") ;try {
ServerSocket serverSocket = new ServerSocket(PORT);
Socket clientSocket = null;
while (isRunning) {
clientSocket = serverSocket.accept();
if (isRunning) {
SHandler sHandler = new SHandler(clientSocket, serverRSA, clientRSA, sessionKeys[keyIndex],
TEXT_AREA);
sHandler.start();
sHandlers.add(sHandler);
}
}
serverSocket.close();
if (clientSocket != null) {
clientSocket.close();
}
} catch (IOException e) {
e.printStackTrace(); } } } }my audio and image not sync.
-
Error while creating thumb from video ubuntu ffmpeg
1er janvier 2019, par dev21using below line to generate thumb from the video saved in the public folder in the laravel 4.2 application.
exec("ffmpeg -ss 00:00:05 -i /var/www/html/project/public/".$directory."".$filename." -vf 'select=not(mod(n\,1000)),scale=320:240' /var/www/html/project/public/".$d.$thumb." >> log_file.log 2>&1 &",$output, $exit_code);
but "log_file.log" contains the following line :
cannot create user data directory: /var/www/snap/ffmpeg/411: Read-only file system
I used snap to install the ffmpeg.
-
Parsing The Clue Chronicles
30 décembre 2018, par Multimedia Mike — Game HackingA long time ago, I procured a 1999 game called Clue Chronicles : Fatal Illusion, based on the classic board game Clue, a.k.a. Cluedo. At the time, I was big into collecting old, unloved PC games so that I could research obscure multimedia formats.
Surveying the 3 CD-ROMs contained in the box packaging revealed only Smacker (SMK) videos for full motion video which was nothing new to me or the multimedia hacking community at the time. Studying the mix of data formats present on the discs, I found a selection of straightforward formats such as WAV for audio and BMP for still images. I generally find myself more fascinated by how computer games are constructed rather than by playing them, and this mix of files has always triggered a strong “I could implement a new engine for this !” feeling in me, perhaps as part of the ScummVM project which already provides the core infrastructure for reimplementing engines for 2D adventure games.
Tying all of the assets together is a custom high-level programming language. I have touched on this before in a blog post over a decade ago. The scripts are in a series of files bearing the extension .ini (usually reserved for configuration scripts, but we’ll let that slide). A representative sample of such a script can be found here :
What Is This Language ?
At the time I first analyzed this language, I was still primarily a C/C++-minded programmer, with a decent amount of Perl experience as a high level language, and had just started to explore Python. I assessed this language to be “mildly object oriented with C++-type comments (‘//’) and reliant upon a number of implicit library functions”. Other people saw other properties. When I look at it nowadays, it reminds me a bit more of JavaScript than C++. I think it’s sort of a Rorschach test for programming languages.Strangely, I sort of had this fear that I would put a lot of effort into figuring out how to parse out the language only for someone to come along and point out that it’s a well-known yet academic language that already has a great deal of supporting code and libraries available as open source. Google for “spanish dolphins far side comic” for an illustration of the feeling this would leave me with.
It doesn’t matter in the end. Even if such libraries exist, how easy would they be to integrate into something like ScummVM ? Time to focus on a workable approach to understanding and processing the format.
Problem Scope
So I set about to see if I can write a program to parse the language seen in these INI files. Some questions :- How large is the corpus of data that I need to be sure to support ?
- What parsing approach should I take ?
- What is the exact language format ?
- Other hidden challenges ?
To figure out how large the data corpus is, I counted all of the INI files on all of the discs. There are 138 unique INI files between the 3 discs. However, there are 146 unique INI files after installation. This leads to a hidden challenge described a bit later.
What parsing approach should I take ? I worried a bit too much that I might not be doing this the “right” way. I’m trying to ignore doubts like this, like how “SQL Shame” blocked me on a task for a little while a few years ago as I concerned myself that I might not be using the purest, most elegant approach to the problem. I know I covered language parsing a lot time ago in university computer science education and there is a lot of academic literature to the matter. But sometimes, you just have to charge in and experiment and prototype and see what falls out. In doing so, I expect to have a better understanding of the problems that need to solved and the right questions to ask, not unlike that time that I wrote a continuous integration system from scratch because I didn’t actually know that “continuous integration” was the keyword I needed.
Next, what is the exact language format ? I realized that parsing the language isn’t the first and foremost problem here– I need to know exactly what the language is. I need to know what the grammar are keywords are. In essence, I need to reverse engineer the language before I write a proper parser for it. I guess that fits in nicely with the historical aim of this blog (reverse engineering).
Now, about the hidden challenges– I mentioned that there are 8 more INI files after the game installs itself. Okay, so what’s the big deal ? For some reason, all of the INI files are in plaintext on the CD-ROM but get compressed (apparently, according to file size ratios) when installed to the hard drive. This includes those 8 extra INI files. I thought to look inside the CAB installation archive file on the CD-ROM and the files were there… but all in compressed form. I suspect that one of the files forms the “root” of the program and is the launching point for the game.
Parsing Approach
I took a stab at parsing an INI file. My approach was to first perform lexical analysis on the file and create a list of 4 types : symbols, numbers, strings, and language elements ([]{}()=., :). Apparently, this is the kind of thing that Lex/Flex are good at. This prototyping tool is written in Python, but when I port this to ScummVM, it might be useful to call upon the services of Lex/Flex, or another lexical analyzer, for there are many. I have a feeling it will be easier to use better tools when I understand the full structure of the language based on the data available.
The purpose of this tool is to explore all the possibilities of the existing corpus of INI files. To that end, I ran all 138 of the plaintext files through it, collected all of the symbols, and massaged the results, assuming that the symbols that occurred most frequently are probably core language features. These are all the symbols which occur more than 1000 times among all the scripts :6248 false 5734 looping 4390 scripts 3877 layer 3423 sequentialscript 3408 setactive 3360 file 3257 thescreen 3239 true 3008 autoplay 2914 offset 2599 transparent 2441 text 2361 caption 2276 add 2205 ge 2197 smackanimation 2196 graphicscript 2196 graphic 1977 setstate 1642 state 1611 skippable 1576 desc 1413 delayscript 1298 script 1267 seconds 1019 rect
About That Compression
I have sorted out at least these few details of the compression :bytes 0-3 "COMP" (a pretty strong sign that this is, in fact, compressed data) bytes 4-11 unknown bytes 12-15 size of uncompressed data bytes 16-19 size of compressed data (filesize - 20) bytes 20- compressed payload
The compression ratios are on the same order of gzip. I was hoping that it was stock zlib data. However, I have been unable to prove this. I wrote a Python script that scrubbed through the first 100 bytes of payload data and tried to get Python’s zlib.decompress to initialize– no luck. It’s frustrating to know that I’ll have to reverse engineer a compression algorithm that deals with just 8 total text files if I want to see this effort through to fruition.
Update, January 15, 2019
Some folks expressed interest in trying to sort out the details of the compression format. So I have posted a followup in which I post some samples and go into deeper details about things I have tried :Reverse Engineering Clue Chronicles Compression
The post Parsing The Clue Chronicles first appeared on Breaking Eggs And Making Omelettes.