
Recherche avancée
Médias (1)
-
Somos millones 1
21 juillet 2014, par
Mis à jour : Juin 2015
Langue : français
Type : Video
Autres articles (55)
-
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 ) (...) -
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 (6709)
-
How to add a subtitle to a video using ffmpeg in Flutter ?
3 juillet 2024, par Mohammed BekeleI'm using flutter_ffmpeg_kit_full package to add subtitles to my video. First I loop through all words and create an srt file and stored it in temp folder :


Future<string> _createSrtFile() async {
 String filePath = await getSrtOutputFilePath();

 final file = File(filePath);
 final buffer = StringBuffer();

 for (int i = 0; i < widget.words.length; i++) {
 final word = widget.words[i];
 final startTime = _formatSrtTime(word['startTime'].toDouble());
 final endTime = _formatSrtTime(word['endTime'].toDouble());
 final text = word['word'];

 buffer.writeln('${i + 1}');
 buffer.writeln('$startTime --> $endTime');
 buffer.writeln('$text');
 buffer.writeln('');
 }

 await file.writeAsString(buffer.toString());
 return filePath;
 }

 String _formatSrtTime(double seconds) {
 final int hours = seconds ~/ 3600;
 final int minutes = ((seconds % 3600) ~/ 60);
 final int secs = (seconds % 60).toInt();
 final int millis = ((seconds - secs) * 1000).toInt() % 1000;

 return '${hours.toString().padLeft(2, '0')}:${minutes.toString().padLeft(2, '0')}:${secs.toString().padLeft(2, '0')},${millis.toString().padLeft(3, '0')}';
 }
</string>


Then I create a future function to handle the export by using ffmpeg command :


Future<void> _exportVideo() async {
 final hasPermission = await _requestStoragePermission();
 if (!hasPermission) {
 ScaffoldMessenger.of(context).showSnackBar(
 const SnackBar(content: Text('Storage permission denied')));
 return;
 }

 setState(() {
 _isProcessing = true;
 _outputFilePath = "";
 });

 try {
 final srtFilePath = await _createSrtFile();

 String videoPath = widget.videoFile!.path;

 String _outputPath = await getOutputFilePath();

 final command =
 '-i $videoPath -vf "drawtext="text=\'Stack Overflow\':fontcolor=white:fontsize=24:box=1:boxcolor=black@0.5:boxborderw=5:x=(w-text_w)/2:y=(h-text_h)/2"" -codec:a copy $_outputPath';

 // final cmd = [
 // '-i',
 // videoPath,
 // '-preset',
 // 'ultrafast',
 // '-vf',
 // 'subtitles=$srtFilePath:force_style=\'Fontname=Roboto Bold,FontSize=30,MarginV=70,PrimaryColour=ffffff,OutlineColour=000000\'',
 // _outputPath
 // ];
 // FFmpegKit.executeWithArguments(cmd)

 print('Executing FFmpeg command: $command');

 await FFmpegKit.execute(command).then((session) async {
 final returnCode = await session.getReturnCode();
 final output = await session.getOutput();
 final failStackTrace = await session.getFailStackTrace();

 print('FFmpeg Output: $output');
 if (failStackTrace != null) {
 print('FFmpeg Fail StackTrace: $failStackTrace');
 }

 if (ReturnCode.isSuccess(returnCode)) {
 setState(() {
 _outputFilePath = _outputPath;
 });
 ScaffoldMessenger.of(context).showSnackBar(
 const SnackBar(content: Text('Export successful!')));
 } else {
 final logs = await session.getLogsAsString();
 print('FFmpeg Logs: $logs');
 ScaffoldMessenger.of(context)
 .showSnackBar(const SnackBar(content: Text('Export failed!')));
 }
 });
 } catch (e) {
 print('Error: $e');
 ScaffoldMessenger.of(context).showSnackBar(
 SnackBar(content: Text('Export failed with error: $e')));
 } finally {
 setState(() {
 _isProcessing = false;
 });
 }
 }
</void>


I did the export without the subtitles and it works. but the issue is when I try to do it with subtitles. I don't know what fault I'm making but this code is failing to export. Here is the path for the srt and video itself :


Future<string> getOutputFilePath() async {
 final Directory? downloadsDir = await getDownloadsDirectory();
 final timestamp = DateTime.now().millisecondsSinceEpoch;
 final name = "output-$timestamp.avi";
 return '${downloadsDir!.path}/$name'; // Save in downloads folder
 }

 Future<string> getSrtOutputFilePath() async {
 final Directory? downloadsDir = await getDownloadsDirectory();
 final timestamp = DateTime.now().millisecondsSinceEpoch;
 final name = "caption-$timestamp.srt";
 return '${downloadsDir!.path}/$name'; // Save in downloads folder
 }
</string></string>


-
Join two flv files with PHP and ffmpeg
14 avril 2015, par SergioOn my website I’m using phpmotion to convert videos into FLV files.
What I want to do is that after the successful conversion of any new FLV file add short FLV file at the beginning.So, I need FFMPEG command in PHP which will join the file 1.flv (intro file) with 2.flv (successful converted file) and as a result create final.flv
I tried with :
ffmpeg -i 1.flv -i 2.flv -vcodec copy -acodec copy final.flv
But without result.
Thanks for any suggestion.
-
How to cut and merge avi videos with java
17 août 2017, par MonticleI want to cut and merge some avi videos(same codec, same resolution, same fps) using java library.
Now I am trying this using Humble video(https://github.com/artclarke/humble-video), which is based on ffmpeg.
I want to use the seek function to cut the input video first, but the result is not correct.
this is my code.
public void cutjob(String input, String output, int starttime) {
final Demuxer demuxer = Demuxer.make();
final Muxer muxer = Muxer.make(output, null, "avi");
try {
demuxer.open(input, null, false, true, null, null);
final MuxerFormat format = MuxerFormat.guessFormat("avi", null, null);
int n = demuxer.getNumStreams();
final Decoder[] decoders = new Decoder[n];
for (int i = 0; i < n; i++) {
final DemuxerStream ds = demuxer.getStream(i);
decoders[i] = ds.getDecoder();
final Decoder d = decoders[i];
if (d != null) {
if (format.getFlag(MuxerFormat.Flag.GLOBAL_HEADER))
d.setFlag(Coder.Flag.FLAG_GLOBAL_HEADER, true);
d.open(null, null);
muxer.addNewStream(d);
}
}
muxer.open(null, null);
demuxer.seek(-1, Long.MIN_VALUE, (long)starttime* Global.getDefaultTimeBase().getDenominator(), Long.MAX_VALUE, Demuxer.SeekFlag.SEEK_ANY.swigValue());
final MediaPacket packet = MediaPacket.make();
long dts = -1;
while (demuxer.read(packet) >= 0) {
System.out.println("dts:"+packet.getDts() + ",pts:"+packet.getPts());
final Decoder d = decoders[packet.getStreamIndex()];
if (packet.isComplete() && d != null) {
dts = dts == -1 ? packet.getDts() : dts;
packet.setDts(packet.getDts() - dts);
packet.setPosition(-1);
muxer.write(packet, false);
}
}
muxer.close();
demuxer.close();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}The video source is about 190 seconds long, and I set the "starttime" as 180,
want to cut the last 10 seconds and write to a new avi file.The output avi file is 10 seconds long, but only the last 5s of the video is correct, the first 5s seems no data.
Is there any wrong in my code.
Thanks.