Recherche avancée

Médias (1)

Mot : - Tags -/epub

Autres articles (74)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • Sélection de projets utilisant MediaSPIP

    29 avril 2011, par

    Les exemples cités ci-dessous sont des éléments représentatifs d’usages spécifiques de MediaSPIP pour certains projets.
    Vous pensez avoir un site "remarquable" réalisé avec MediaSPIP ? Faites le nous savoir ici.
    Ferme MediaSPIP @ Infini
    L’Association Infini développe des activités d’accueil, de point d’accès internet, de formation, de conduite de projets innovants dans le domaine des Technologies de l’Information et de la Communication, et l’hébergement de sites. Elle joue en la matière un rôle unique (...)

Sur d’autres sites (7055)

  • Consume Flask video streaming with ffmpeg

    10 avril 2018, par Vitor Silva de Deus

    I’ve created a python Flask video file streamer resource that works well when getting the file in a web browser but is not working when using ffmpeg.
    The flask resource is :

    from flask_restful import Resource, Api

    class Mp4(Resource):
       def get(self,grtv,data,canal,arquivo):

           path = os.path.abspath('../mp4/' + str(canal) + '/' + str(data) + '/' + str(arquivo))

           print(path)
           def generate():
               with open(path, "rb") as f:
                   chunk = f.read(1024)
                   while chunk:
                       yield chunk
                       chunk = f.read(1024)

           try:
               t = os.stat(path)
               size = str(t.st_size)
               return Response(generate(),mimetype='video/mp4',headers={"Content-Type":"video/mp4","Content-Disposition":"inline","Content-Transfer-Enconding":"binary","Content-Length":size})
           except Exception as e:
               result = {'result': e}
               return result

    The ffmpeg command is :

    ffmpeg -loglevel debug -i <url> out_teste4.mp4
    </url>

    where url is de address of the streaming video.

    The ffmpeg most important output is :

    ffmpeg output screenshot 1

    ffmpeg output screenshot 2

    I’ve already tried increasing ’analyzeduration’ and ’probesize’ options.

    ffmpeg version : 3.4.2-1 16.04.york0.2.

    python version : 3.5.2.

    Does anyone can help me to get the video files with ffmpeg ? Suggestions can be both on changing the API or the ffmpeg command.

    Thank you all !

  • FFMPEG : decode h264 with multiple frames

    30 avril 2018, par Jasim Khan Afridi

    Please excuse my knowledge of video decoding, I am new to this.

    I need to decode video frames from h264 to bitmap images in C#. I am using FFmpeg.AutoGen for this. But unfortunately, I failed to get any results.

    I have the following data at my disposal.

    • nFrameType = IFrame, PFrame or BFrame
    • nSequence = Frame sequence
    • nWidth = width of resolution
    • nHeight = Height of resolution
    • nVideoSize = size of video data
    • pVideo = video data

    My method at current is the following (Similar to the example shown here) :

    initialization

    private unsafe AVCodecContext* _codecContext;
    private unsafe AVFormatContext* _formatContext;
    private unsafe AVFrame* _frame;
    AVCodecID codecID;
    private unsafe AVCodec* _avCodec;
    private bool decoderInitialized = false;

       if (!decoderInitialized)
       {
           if (nCodecType == 2)
           {
               codecID = AVCodecID.AV_CODEC_ID_H264;
           }
           unsafe
           {
               _avCodec = ffmpeg.avcodec_find_decoder(codecID);
               _codecContext = ffmpeg.avcodec_alloc_context3(_avCodec);
               ffmpeg.avcodec_open2(_codecContext, _avCodec, null);
               _frame = ffmpeg.av_frame_alloc();
           }
           decoderInitialized = true;

       }

    decoding

               AVPacket packet;
               ffmpeg.av_init_packet(&amp;packet);
               packet.data = (byte*)pVideo;
               packet.size = (int)nVideoSize;
               int isFrameFinished = 0;

               int response = ffmpeg.avcodec_decode_video2(_codecContext, _frame, &amp;isFrameFinished, &amp;packet);

    I always get response = -22 and isFrameFinished = 0. I do have a hunch that I am doing something wrong here. But I am unable to find a resource to guide me in some direction. E.g. I know, I need to use nFrameType (IFrame, BFrame and PFrame). But I don’t know how ? Further, I know that I need to use width and height to decode the image properly, but again, I don’t know how to go about it.

  • Building and integrating FFmpeg with FFplay enabled for android

    19 avril 2018, par Sunit Ranjan Poddar

    I’ve been trying to build FFmpeg with FFplay enabled for my Android project using guardian project’s https://github.com/guardianproject/android-ffmpeg/tree/61ea21c932d7498b8d330a421425e50e65c805aa on Ubuntu 17.10 without changing anything in any build/configure.sh files except for setting the NDK_BASE path. After successfully compiling the FFmpeg binaries i tested it on Ububtu and both the binaries(FFmpeg and FFplay) ran perfectly. I copied the same binaries in my project’s res/raw folder and used guardian project’s https://github.com/guardianproject/android-ffmpeg-java/blob/master/src/org/ffmpeg/android/FfmpegController.java wrapper class and customized the same for FFplay for only executing the command without output directory as follows -

       public class FfplayController{
       public String mffplayBin;
       private final static String TAG = "ffplay";
       private File mFileTemp;
       private String mCmdCat = "sh cat";

       public FfplayController(Context context, File fileTemp, boolean overwrite) throws FileNotFoundException, IOException {
           mFileTemp = fileTemp;
           installBinaries(context, overwrite);
       }

       public FfplayController(Context context, File fileTemp) throws FileNotFoundException, IOException {
           mFileTemp = fileTemp;
           installBinaries(context, false);
       }
       public void installBinaries(Context context, boolean overwrite) {
           mffplayBin = installBinary(context, R.raw.ffplay, "ffplay", overwrite);
       }

       public String getBinaryPath() {
           return mffplayBin;
       }

       private static String installBinary(Context ctx, int resId, String filename, boolean upgrade) {
           try {
               File f = new File(ctx.getDir("bin", 0), filename);
               if (upgrade) {
                   if (f.exists()) {
                       f.delete();
                   }
                   copyRawFile(ctx, resId, f, "0755");
               }
               return f.getCanonicalPath();
           } catch (Exception e) {
           Log.e(TAG, "installBinary failed: " + e.getLocalizedMessage());
           return null;
       }
    }

    /**
    * Copies a raw resource file, given its ID to the given location
    *
    * @param ctx   context
    * @param resid resource id
    * @param file  destination file
    * @param mode  file permissions (E.g.: "755")
    * @throws IOException          on error
    * @throws InterruptedException when interrupted
    */
    private static void copyRawFile(Context ctx, int resid, File file, String mode) throws IOException, InterruptedException {
       final String abspath = file.getAbsolutePath();
       // Write the iptables binary
       final FileOutputStream out = new FileOutputStream(file);
       final InputStream is = ctx.getResources().openRawResource(resid);
       byte buf[] = new byte[1024];
       int len;
       while ((len = is.read(buf)) > 0) {
           out.write(buf, 0, len);
       }
       out.close();
       is.close();
       // Change the permissions
       Runtime.getRuntime().exec("chmod " + mode + " " + abspath).waitFor();
    }


    public void execffplay(List<string> cmd, ShellCallback sc, File fileExec) throws IOException, InterruptedException {

       enablePermissions();

       execProcess(cmd, sc, fileExec);
    }

    private void enablePermissions() throws IOException {
       Runtime.getRuntime().exec("chmod 755 " + mffplayBin);

    }

    public void execffplay(List<string> cmd, ShellCallback sc) throws IOException, InterruptedException {
       execffplay(cmd, sc, new File(mffplayBin).getParentFile());
    }

    private int execProcess(List<string> cmds, ShellCallback sc, File fileExec) throws IOException, InterruptedException {

       //ensure that the arguments are in the correct Locale format
       for (String cmd : cmds) {
           cmd = String.format(Locale.US, "%s", cmd);
       }

       ProcessBuilder pb = new ProcessBuilder(cmds);
       pb.directory(fileExec);

       StringBuffer cmdlog = new StringBuffer();

       for (String cmd : cmds) {
           cmdlog.append(cmd);
           cmdlog.append(' ');
       }

       sc.shellOut(cmdlog.toString());

       //pb.redirectErrorStream(true);

       Process process = pb.start();


       // any error message?
       StreamGobbler errorGobbler = new StreamGobbler(
               process.getErrorStream(), "ERROR", sc);

       // any output?
       StreamGobbler outputGobbler = new
               StreamGobbler(process.getInputStream(), "OUTPUT", sc);

       errorGobbler.start();
       outputGobbler.start();

       int exitVal = process.waitFor();

       sc.processComplete(exitVal);

       return exitVal;

    }
    }
    </string></string></string>

    And i execute it as follows -

       List<string> previewCmd = new ArrayList<string>();
       previewCmd.add(fc.mffplayBin);
       previewCmd.add("-f");
       previewCmd.add("mpegts");
       previewCmd.add("-ast");
       previewCmd.add("1");
       previewCmd.add("-vst");
       previewCmd.add("0");
       previewCmd.add("-ar");
       previewCmd.add("48000");
       previewCmd.add("udp://192.168.1.14:8090");
       previewCmd.add(videoRoot);

       FfplayController fc = new FfplayController (context, new File(videoroot), true);
       fc.execffplay(previewCmd, new ShellUtils.ShellCallback() {
           @Override
           public void shellOut(String shellLine) {
               Log.e("SHELL OUT", shellLine);
           }

           @Override
           public void processComplete(int exitValue) {
               Log.e("SHELL EXIT VAL", String.valueOf(exitValue));
           }
       });
    </string></string>

    where videoroot is the local path of the video i want to play and udp:192.168.1.14:8090 is android device’s local ip for ffplay.

    While execution it throws error

    04-19 09:03:39.201 6615-6615/com.demo.ffplaypreview E/SHELL OUT :
    /data/data/com.demo.ffplaypreview/app_bin/ffplay
    /storage/emulated/0/testPreview.mp4 -f mpegts -ast 1 -vst 0 -ar 48000
    udp ://192.168.1.14:8090
    04-19 09:03:39.251 6615-7248/com.demo.ffplaypreview E/SHELL OUT : /data/data/com.demo.ffplaypreview/app_bin/ffplay[1] : syntax error : ’)’
    unexpected
    04-19 09:03:39.251 6615-6615/com.demo.ffplaypreview E/SHELL EXIT VAL : 1