
Recherche avancée
Médias (3)
-
MediaSPIP Simple : futur thème graphique par défaut ?
26 septembre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Video
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
-
GetID3 - Boutons supplémentaires
9 avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
Autres articles (50)
-
Modifier la date de publication
21 juin 2013, parComment changer la date de publication d’un média ?
Il faut au préalable rajouter un champ "Date de publication" dans le masque de formulaire adéquat :
Administrer > Configuration des masques de formulaires > Sélectionner "Un média"
Dans la rubrique "Champs à ajouter, cocher "Date de publication "
Cliquer en bas de la page sur Enregistrer -
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 -
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 (8323)
-
PHP script works when called from command line, does not when called as background via web server
6 juin 2014, par fNekI am facing a problem with a certain PHP script (CLI mode) I wrote. It should take certain arguments to convert a video with FFMPEG. When I call it from the command prompt, it works fine. However, I have to call it from a web server.
The PHP script that handles the request calls the PHP script in the background via code I found here at SE :
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec("nohup " . $cmd . " > /dev/null &");
}When run this way, however, the PHP script does not create the files, even after a much longer time than it took via the command prompt.
The script runs, I have checked that by letting it insert dummy entries into the database. It also has the permission to create files, which I verified by letting it create a text file.
What could be the difference that prevents my script from working properly ? I develop and test this code with XAMPP on Windows 7.
//EDIT : I forgot to give you this link to the background PHP script : http://pastebin.com/pfTZMfwi
//EDIT2 : I found out that the PHP process runs for a very short time (only until next refresh of the Windows task manager). Could it be that PHP kills its children when it exits ?
//EDIT3 : No, that seems not to be the problem. I cannot execute programs via exec() when the script is called as background from the web server. What could the problem be, and what would be a solution/workaround ?
//EDIT4 : The command that seems to cause the trouble is not exec()/etc. but the echo command I did before the exec(). I am going to remove it, but why does it cause a problem ?
-
ffmpeg won't start until java exits
9 août 2014, par user3925332I am trying to make a java program that automatically converts wtv files in an input folder to mpg files in output folder. The twist is that I make it run periodically, so it acts as a synchronizer.
The following code works for converting the .wtv to a .dvr-ms, which is required by ffmpeg since it cannot convert .wtv files directly.
Process p = Runtime.getRuntime().exec("C:\\Windows\\ehome\\WTVConverter C:\\Users\\Andrew\\Desktop\\test\\input\\input.wtv C:\\Users\\Andrew\\Desktop\\test\\output\\input.dvr-ms");
p.waitFor();WTVConverter has no problems running from a java application. ffmpeg is a different story. Once the above line runs, I then run this...
Process p = Runtime.getRuntime().exec("ffmpeg\\bin\\ffmpeg -y -i \"C:\\Users\\Andrew\\Desktop\\test\\output\\input.dvr-ms'" -vcodec copy -acodec copy -f dvd \"C:\Users\Andrew\Desktop\test\output\input.mpg\"");
p.waitFor();Suddenly, there is a problem... The application ffmpeg shows up in the task manager, but it’s cpu usage is 0, and no mpeg files is being generated. If I force the java application to close, though, suddenly it starts working ! Huh ?
What reason would there be for a command line application to wait for its calling application to quit before it executes ? I’m not incredibly command line savvy, so I don’t really know how to diagnose this problem.
-
Hardware accelerated decoding with FFmpeg falls back to software decoding
9 février 2024, par iexavSo I have followed the FFmpeg example for hardware accelerated decoding exactly as it is (I am referring to this example).


https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/hw_decode.c#L76



But I still seem to be decoding with the software decoder. When I open the task manager on windows the GPU isn't getting used. Before I make a call to av_hwframe_transfer_data() I check whether the frame is in the relevant hw_pix_fmt format and it is. Everything works, no errors, nothing, except the GPU is doing nothing. Now as an example I tried decoding a video that uses vp9 as a codec. If I specify the hardware accelerated codec I want by name it actually does work.


vidCodec=avcodec_find_decoder_by_name("vp9_cuvid"); 



When I do this and look at the task manager I can see that the CPU does much less work and my GPU actually does Video Decode work. Having to specify the hardware accelerated decoder for every single video I am decoding is ridiculous though.


Edit : as per user4581301's answer, here are the pieces of relevant code. (It's actually in java because I am using the java FFmpeg wrapper but it's basically just making a bunch of calls to FFmpeg functions.)



 ArrayList<string> deviceTypes = new ArrayList<>();
 int type = AV_HWDEVICE_TYPE_NONE;
 while ((type = av_hwdevice_iterate_types(type)) != AV_HWDEVICE_TYPE_NONE) {
 BytePointer p = av_hwdevice_get_type_name(type);

 deviceTypes.add(CString(p));
 }
 boolean flag=false;

 for(int j=0;j* Allocate a codec context for the decoder */
 if ((video_c = avcodec_alloc_context3(vidCodec)) == null) {
 throw new Exception("avcodec_alloc_context3() error: Could not allocate video decoding context.");
 }


 /* copy the stream parameters from the muxer */

 if ((ret = avcodec_parameters_to_context(video_c, video_st.codecpar())) < 0) {
 releaseUnsafe();
 throw new Exception("avcodec_parameters_to_context() error " + ret + ": Could not copy the video stream parameters.");
 }
 

 video_c.get_format(AvFormatGetter.getInstance());
 AVBufferRef hardwareDeviceContext =av_hwdevice_ctx_alloc(type);

 if ((ret = av_hwdevice_ctx_create(hardwareDeviceContext, type,(String) null, null, 0)) < 0) {
 System.err.println("Failed to create specified HW device. error " + ret);

 }else{
 video_c.hw_device_ctx(av_buffer_ref(hardwareDeviceContext));

 }
 


 
//The function that gets called for get_format
@Override
 public int call(AVCodecContext context, IntPointer format) {
 int p;


 for (int i=0;;i++) {
 if ((p=format.get(i)) == hw_pix_fmt) {
 return p;
 }
 if(p==-1){
 break;
 }
 }

 System.out.println(hw_pix_fmt +" is not found in the codec context");
 // Error

 return AV_PIX_FMT_NONE;
 }
 
//The method that's used for decoding video frames
 public Optional<boolean> decodeVideoFrame(AVPacket pkt, boolean readPacket, boolean keyFrames) throws Exception {

 int ret;
 // Decode video frame
 if (readPacket) {
 ret = avcodec_send_packet(video_c, pkt);
 
 if (ret < 0) {
 System.out.println("error during decoding");
 return Optional.empty();
 }

 if (pkt.data() == null && pkt.size() == 0) {
 pkt.stream_index(-1);
 }
 
 }

 // Did we get a video frame?
 while (true) {
 ret = avcodec_receive_frame(video_c, picture_hw);

 if (ret == AVERROR_EAGAIN() || ret == AVERROR_EOF()) {
 if (pkt.data() == null && pkt.size() == 0) {
 return Optional.empty();
 } else {

 return Optional.of(true);

 }
 } else if (ret < 0) {

 // Ignore errors to emulate the behavior of the old API
 // throw new Exception("avcodec_receive_frame() error " + ret + ": Error during video decoding.");
 return Optional.of(true);

 }

 if (!keyFrames || picture.pict_type() == AV_PICTURE_TYPE_I) {
 
 if(picture_hw.format()==hw_pix_fmt){
 if (av_hwframe_transfer_data(
 picture, // The frame that will contain the usable data.
 picture_hw, // Frame returned by avcodec_receive_frame()
 0) < 0) {
 throw new Exception("Could not transfer data from gpu to cpu. ");

 }
 }
 //... The rest of the method here
 return Optional.of(false);

 }
 }
 }
</boolean></string>