
Recherche avancée
Médias (1)
-
SPIP - plugins - embed code - Exemple
2 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
Autres articles (48)
-
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 -
Support audio et vidéo HTML5
10 avril 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...) -
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 (7055)
-
Dynamically created QImage frames to ffmpeg stdin using QThread
11 mai 2021, par musicamanteI am trying to create video files with ffmpeg using frames dynamically created on a separate thread.


While I can create those frames and store them on disk/memory, I'd like to avoid that passage since the amount/size of the frames can be high and many "jobs" could be created with different format or options. But, also importantly, I'd like to better understand the logic behind this, as I admit I've not a very deep knowledge on how thread/processing actually works.


Right now I'm trying to create the QProcess in the QThread object, and then run the image creation thread as soon as the process is started, but it doesn't seem to work : no file is created, and I don't even get any output from standard error (but I know I should, since I can get it if I don't use the thread).


Unfortunately, due to my little knowledge on how QProcess deals with threads and piping (and, obviously, all possible ffmpeg options), I really don't understand how can achieve this.


Besides obviously getting the output file created, the expected result is to be able to launch the encoding (and possibly queue more encodings in the meantime) while keeping the UI responding and get notifications of the current processing state.


import re
from PyQt5 import QtCore, QtGui, QtWidgets

logRegExp = r'(?:(n:\s+)(?P\d+)\s).*(?:(pts_time:\s*)(?P<time>\d+.\d*))'

class Encoder(QtCore.QThread):
 completed = QtCore.pyqtSignal()
 frameDone = QtCore.pyqtSignal(object)
 def __init__(self, width=1280, height=720, frameCount=100):
 super().__init__()
 self.width = width
 self.height = height
 self.frameCount = frameCount

 def start(self):
 self.currentLog = ''
 self.currentData = bytes()
 self.process = QtCore.QProcess()
 self.process.setReadChannel(self.process.StandardError)
 self.process.finished.connect(self.completed)
 self.process.readyReadStandardError.connect(self.stderr)
 self.process.started.connect(super().start)
 self.process.start('ffmpeg', [
 '-y', 
 '-f', 'png_pipe', 
 '-i', '-', 
 '-c:v', 'libx264', 
 '-b:v', '800k', 
 '-an', 
 '-vf', 'showinfo',
 '/tmp/test.h264', 
 ])

 def stderr(self):
 self.currentLog += str(self.process.readAllStandardError(), 'utf-8')
 *lines, self.currentLog = self.currentLog.split('\n')
 for line in lines:
 print('STDERR: {}'.format(line))
 match = re.search(logRegExp, line)
 if match:
 data = match.groupdict()
 self.frameDone.emit(int(data['frame']))

 def run(self):
 font = QtGui.QFont()
 font.setPointSize(80)
 rect = QtCore.QRect(0, 0, self.width, self.height)
 for frame in range(1, self.frameCount + 1):
 img = QtGui.QImage(QtCore.QSize(self.width, self.height), QtGui.QImage.Format_ARGB32)
 img.fill(QtCore.Qt.white)
 qp = QtGui.QPainter(img)
 qp.setFont(font)
 qp.setPen(QtCore.Qt.black)
 qp.drawText(rect, QtCore.Qt.AlignCenter, 'Frame {}'.format(frame))
 qp.end()
 img.save(self.process, 'PNG')
 print('frame creation complete')


class Test(QtWidgets.QWidget):
 def __init__(self):
 super().__init__()
 layout = QtWidgets.QVBoxLayout(self)
 self.startButton = QtWidgets.QPushButton('Start')
 layout.addWidget(self.startButton)

 self.frameLabel = QtWidgets.QLabel()
 layout.addWidget(self.frameLabel)

 self.process = Encoder()
 self.process.completed.connect(lambda: self.startButton.setEnabled(True))
 self.process.frameDone.connect(self.frameLabel.setNum)
 self.startButton.clicked.connect(self.create)

 def create(self):
 self.startButton.setEnabled(False)
 self.process.start()


import sys
app = QtWidgets.QApplication(sys.argv)
test = Test()
test.show()
sys.exit(app.exec_())
</time>


If I add the following lines at the end of
run()
, then the file is actually created and I get the stderr output, but I can see that it's processed after the completion of the for cycle, which obviously is not the expected result :

self.process.closeWriteChannel()
 self.process.waitForFinished()
 self.process.terminate()



Bonus : I'm on Linux, I don't know if it works differently on Windows (and I suppose it would work similarly on MacOS), but in any case I'd like to know if there are differences and how to possibly deal with them.


-
Adding Text to Video with ffmpeg in Flutter
9 mars 2024, par AimanI am trying to add text to a video using ffmpeg package but it returns an error i.e. Return Code 1
Here's my code.


final videoPath = _controller.file.path;
 final outputName = videoPath.hashCode.toString();

 final output =
 File('${(await getTemporaryDirectory()).path}/$outputName.mp4');

 String command =
 "-y -i $videoPath -filter_complex '[0]scale=540:-1[s];[s]drawtext=fontfile=/storage/emulated/0/Download/SuperDessert.ttf:text='MY_TEXT':fontsize=24:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2' ${output.path}";

 final session = await FFmpegKit.execute(command);

 final returnCode = await session.getReturnCode();

 if (ReturnCode.isSuccess(returnCode)) {
 log("Success full text added");
 } else {
 log("Error adding text: ${await session.getFailStackTrace()}");
 }



I have tried changing the output directory, changed
fontfile
tofont


-
File Decryption in (AESMode.ctr) mode showing Exception Failed to decode data using encoding 'utf-8' in dart ?
20 novembre 2020, par JaiWhile decoding the video file using
aes-ctr
mode am getting error like below,

Unhandled Exception: FileSystemException: Failed to decode data using encoding 'utf-8'


Used ffmpeg for encrypting file :


ffmpeg -i samplevideo.mp4 -vcodec copy -acodec copy -encryption_scheme cenc-aes-ctr -encryption_key 76a6c65c5ea762046bd749a2e632ccbb -encryption_kid a7e61c373e219033c21091fa607bf3b8 enc_v1_file.mp4


Used Dart to decode video file :


Future<string> decryptFile(filePath) async {
 // filePath - Local encrypted file path
 var encodedKey = 'NzZhNmM2NWM1ZWE3NjIwNDZiZDc0OWEyZTYzMmNjYmI=';
 var encodedIv = 'YTdlNjFjMzczZTIxOTAzM2MyMTA5MWZhNjA3YmYzYjg=';
 var encryptedBase64EncodedString = new File(filePath).readAsStringSync();
 var decoded = base64.decode(encryptedBase64EncodedString); // Error in this line
 final key1 = enc.Key.fromBase64(encodedKey);
 final iv = enc.IV.fromBase64(encodedIv);
 final encrypter = enc.Encrypter(enc.AES(key1, mode: enc.AESMode.ctr));
 final decrypted = encrypter.decryptBytes(enc.Encrypted(decoded), iv: iv);
 final filename = '${p.basenameWithoutExtension(filePath)}.mp4';
 final directoryName = p.dirname(filePath);
 final newFilePath = p.join(directoryName, filename);
 var newFile = new File(newFilePath);
 await newFile.writeAsBytes(decrypted);
 return newFilePath;
}
</string>