Recherche avancée

Médias (91)

Autres articles (87)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP 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" (...)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

Sur d’autres sites (5915)

  • Is there a way to batch split a file by chapter with ffmpeg and then reassemble with mkvmerge in windows ?

    13 avril, par Sipherdrakon

    So I made a batch script originally with the ability to relatively precision trim a video into chapters without having to run by keyframes, but the code looks horrible and I can't get it to loop through all mp4 files nor get mkvmerge to append the files after splitting them. Code is below but be gentle it is my first try.

    


    @echo off
setlocal enableDelayedExpansion

REM CODE BELOW CREATES JSON FILES FOR ALL MP4 FILES WITHIN THE SAME DIRECTORY
ffprobe -v quiet -print_format json -show_chapters -loglevel error "01x01.mp4" > "01x01.json"

REM CODE BELOW SETS VARIABLES FROM EACH SPECIFIC JSON
FOR /F "delims=" %%i in ('jq .chapters[2].start ^< 01x01.json') DO SET /A start1=%%i
FOR /F "delims=" %%j in ('jq .chapters[2].end ^< 01x01.json') DO SET /A end1=%%j

FOR /F "delims=" %%k in ('jq .chapters[4].start ^< 01x01.json') DO SET /A start2=%%k
FOR /F "delims=" %%l in ('jq .chapters[4].end ^< 01x01.json') DO SET /A end2=%%l

FOR /F "delims=" %%m in ('jq .chapters[6].start ^< 01x01.json') DO SET /A start3=%%m
FOR /F "delims=" %%n in ('jq .chapters[6].end ^< 01x01.json') DO SET /A end3=%%n

FOR /F "delims=" %%o in ('jq .chapters[8].start ^< 01x01.json') DO SET /A start4=%%o
FOR /F "delims=" %%p in ('jq .chapters[8].end ^< 01x01.json') DO SET /A end4=%%p

REM SETS THE DURATION OF EACH FILE TO USE PRECISION TIMING FOR START AND STOP TIMES
CALL vbs (%end1%-%start1%)/1000
SET duration1=%val%
CALL vbs (%end2%-%start2%)/1000
SET duration2=%val%
CALL vbs (%end3%-%start3%)/1000
SET duration3=%val%
CALL vbs (%end4%-%start4%)/1000
SET duration4=%val%

REM SETS THE START TIME IN SECONDS VS MILLISECONDS
CALL vbs (%start1%)/1000
SET start1=%val%
CALL vbs (%start2%)/1000
SET start2=%val%
CALL vbs (%start3%)/1000
SET start3=%val%
CALL vbs (%start4%)/1000
SET start4=%val%

REM TRIM AND SPLIT ORIGINAL FILE INTO SEPERATE SECTIONS BASED ON CHAPTER MARKERS
ffmpeg -ss %START1% -i 01x01.mp4 -ss 0 -c copy -to %DURATION1% -avoid_negative_ts make_zero 01x01-1.mp4
ffmpeg -ss %START2% -i 01x01.mp4 -ss 0 -c copy -to %DURATION2% -avoid_negative_ts make_zero 01x01-2.mp4
ffmpeg -ss %START3% -i 01x01.mp4 -ss 0 -c copy -to %DURATION3% -avoid_negative_ts make_zero 01x01-3.mp4
ffmpeg -ss %START4% -i 01x01.mp4 -ss 0 -c copy -to %DURATION4% -avoid_negative_ts make_zero 01x01-4.mp4

REM DELETES UNNEEDED JSON AFTER USE
del /s *.json

REM APPEND ALL MP4 FILES INTO COHESIVE MKV
for /d /r %%D in (*) do (
    pushd %%D
    set files=
    for %%F in (*.mp4) do set files=!files! + ^( "%%F" ^)
    if not "!files!"=="" %mkvmerge% -o "01x01-FINAL.mkv" !files:~2!
    popd
)

REM DELETE UNNEEDED MP4 ORIGINALS AND SPLIT FILES
del /s *.mp4


    


    I know it is super long and every time I try to use a variable or a loop to run through all files it can't read the json file. I've been at this all day and I can use the script as is but I have to make a file for each iteration.

    


    I was also hoping to be able to have it only pull chapters labeled as "video" but I haven't quite figured that one out yet.

    


    I'll add the vbs batch file for the arithmetic section as well as the sample json if it will help.

    


    @echo off
>"%temp%\VBS.vbs" echo Set fso = CreateObject("Scripting.FileSystemObject") : Wscript.echo (%*)
for /f "delims=" %%a in ('cscript /nologo "%temp%\VBS.vbs"') do set "val=%%a"
del "%temp%\VBS.vbs"


    


    {
    "chapters": [
        {
            "id": 0,
            "time_base": "1/1000",
            "start": 0,
            "start_time": "0.000000",
            "end": 5590,
            "end_time": "5.590000",
            "tags": {
                "title": "Video"
            }
        },
        {
            "id": 1,
            "time_base": "1/1000",
            "start": 5590,
            "start_time": "5.590000",
            "end": 13994,
            "end_time": "13.994000",
            "tags": {
                "title": "Advertisement"
            }
        },
        {
            "id": 2,
            "time_base": "1/1000",
            "start": 13994,
            "start_time": "13.994000",
            "end": 163964,
            "end_time": "163.964000",
            "tags": {
                "title": "Video"
            }
        },
        {
            "id": 3,
            "time_base": "1/1000",
            "start": 163964,
            "start_time": "163.964000",
            "end": 195940,
            "end_time": "195.940000",
            "tags": {
                "title": "Advertisement"
            }
        },
        {
            "id": 4,
            "time_base": "1/1000",
            "start": 195940,
            "start_time": "195.940000",
            "end": 547849,
            "end_time": "547.849000",
            "tags": {
                "title": "Video"
            }
        },
        {
            "id": 5,
            "time_base": "1/1000",
            "start": 547849,
            "start_time": "547.849000",
            "end": 595850,
            "end_time": "595.850000",
            "tags": {
                "title": "Advertisement"
            }
        },
        {
            "id": 6,
            "time_base": "1/1000",
            "start": 595850,
            "start_time": "595.850000",
            "end": 1413588,
            "end_time": "1413.588000",
            "tags": {
                "title": "Video"
            }
        },
        {
            "id": 7,
            "time_base": "1/1000",
            "start": 1413588,
            "start_time": "1413.588000",
            "end": 1477569,
            "end_time": "1477.569000",
            "tags": {
                "title": "Advertisement"
            }
        },
        {
            "id": 8,
            "time_base": "1/1000",
            "start": 1477569,
            "start_time": "1477.569000",
            "end": 1529696,
            "end_time": "1529.696000",
            "tags": {
                "title": "Video"
            }
        }
    ]
}


    


    I also tried using the start_time so I didn't have to do extra calculations but jq didn't like that either.

    


    mkvmerge doesn't even try to run when I have it in here and I still need to cut 7 seconds off the end and 12 seconds off the front of it once it is all one file again.

    


    Any help would be appreciated, I know it's a lot but I seem to have hit a roadblock or just sleep deprived at this point.

    


    UPDATE

    


    This works amazing I just need to figure out how to use files with spaces and I'm all set. I guess I could run a batch before hand replacing all spaces with underscores. That would probably work but I would like to not change filenames if I can help it.

    


    @echo off

for %%i in (*.mp4) do (
FOR /F "delims=" %%A IN ('ffprobe -v quiet -print_format json -show_chapters -loglevel error "%%i" ^| xidel - -se "$json/(chapters)()[id!=0 and tags/title='Video']/concat('ffmpeg -ss ',start div 1000,' -i %%i -to ',((end - start) div 1000),' -c copy -avoid_negative_ts make_zero %%~ni-',position(),'.mp4')"') DO %%A
FOR /F "delims=" %%A IN ('xidel -s --xquery "concat('mkvmerge -o "%%~ni-FINAL.mkv" "',join(file:list(.,false(),'%%~ni-*.mp4'),'" + "'),'"')"') DO %%A
)


    


  • Android : Pass video path to FFmpeg

    29 septembre 2020, par marian

    I have developed an app that play video from gallery. I would like to add watermark using FFmpeg command in the video selected. But I do not know how to pass the path to the FFmpeg command. I could not find proper tutorials or reference regarding this. My coding are as follows :

    


    MainActivity.java :

    


    public class MainActivity extends Activity {
public ProgressDialog progressBar;

String workFolder = null;
String demoVideoFolder = null;
String demoVideoPath = null;
String vkLogPath = null;
LoadJNI vk;
private final int STOP_TRANSCODING_MSG = -1;
private final int FINISHED_TRANSCODING_MSG = 0;
private boolean commandValidationFailedFlag = false;

Button button;
VideoView videoView;
private static final int PICK_FROM_GALLERY = 1;


private void runTranscodingUsingLoader() {
    Log.i(Prefs.TAG, "runTranscodingUsingLoader started...");

    PowerManager powerManager = (PowerManager)MainActivity.this.getSystemService(Activity.POWER_SERVICE);
    PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "VK_LOCK");
    Log.d(Prefs.TAG, "Acquire wake lock");
    wakeLock.acquire();

    

    String[] complexCommand = {"ffmpeg","-y" ,"-i", "/sdcard/videokit/in.mp4","-strict","experimental",
            "-vf", "movie=/sdcard/videokit/watermark.png [watermark];" +
            " [in][watermark] overlay=main_w-overlay_w-10:10 [out]","-s",
            "320x240","-r", "30", "-b", "15496k", "-vcodec", "mpeg4","-ab",
            "48000", "-ac", "2", "-ar", "22050", "/sdcard/videokit/out1.mp4"};
    ///////////////////////////////////////////////////////////////////////


    vk = new LoadJNI();
    try {
        // running complex command with validation
        vk.run(complexCommand, workFolder, getApplicationContext());

        // running without command validation
        //vk.run(complexCommand, workFolder, getApplicationContext(), false);

        // running regular command with validation
        //vk.run(GeneralUtils.utilConvertToComplex(commandStr), workFolder, getApplicationContext());

        Log.i(Prefs.TAG, "vk.run finished.");
        // copying vk.log (internal native log) to the videokit folder
        GeneralUtils.copyFileToFolder(vkLogPath, demoVideoFolder);

    } catch (CommandValidationException e) {
        Log.e(Prefs.TAG, "vk run exeption.", e);
        commandValidationFailedFlag = true;

    } catch (Throwable e) {
        Log.e(Prefs.TAG, "vk run exeption.", e);
    }
    finally {
        if (wakeLock.isHeld()) {
            wakeLock.release();
            Log.i(Prefs.TAG, "Wake lock released");
        }
        else{
            Log.i(Prefs.TAG, "Wake lock is already released, doing nothing");
        }
    }

    // finished Toast
    String rc = null;
    if (commandValidationFailedFlag) {
        rc = "Command Vaidation Failed";
    }
    else {
        rc = GeneralUtils.getReturnCodeFromLog(vkLogPath);
    }
    final String status = rc;
    MainActivity.this.runOnUiThread(new Runnable() {
        public void run() {
            Toast.makeText(MainActivity.this, status, Toast.LENGTH_LONG).show();
            if (status.equals("Transcoding Status: Failed")) {
                Toast.makeText(MainActivity.this, "Check: " + vkLogPath + " for more information.", Toast.LENGTH_LONG).show();
            }
        }
    });
}


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    button = (Button) findViewById(R.id.button);
    
    videoView = (VideoView) findViewById(R.id.videoview);

    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent();

            intent.setType("video/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);

            startActivityForResult(Intent.createChooser(intent, "Complete action using"), PICK_FROM_GALLERY);
        }
    });

}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != RESULT_OK) return;

    if (requestCode == PICK_FROM_GALLERY) {
        Uri mVideoURI = data.getData();
        videoView.setVideoURI(mVideoURI);
        videoView.start();
        demoVideoFolder = mVideoURI.getPath();
        demoVideoPath = demoVideoFolder;
        savevideo(mVideoURI);

    }


}
private Handler handler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        Log.i(Prefs.TAG, "Handler got message");
        if (progressBar != null) {
            progressBar.dismiss();

            // stopping the transcoding native
            if (msg.what == STOP_TRANSCODING_MSG) {
                Log.i(Prefs.TAG, "Got cancel message, calling fexit");
                vk.fExit(getApplicationContext());


            }
        }
    }
};

public void runTranscoding() {
    progressBar = new ProgressDialog(MainActivity.this);
    progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressBar.setTitle("FFmpeg4Android Direct JNI");
    progressBar.setMessage("Press the cancel button to end the operation");
    progressBar.setMax(100);
    progressBar.setProgress(0);

    progressBar.setCancelable(false);
    progressBar.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            handler.sendEmptyMessage(STOP_TRANSCODING_MSG);
        }
    });

    progressBar.show();

    new Thread() {
        public void run() {
            Log.d(Prefs.TAG,"Worker started");
            try {
                //sleep(5000);
                runTranscodingUsingLoader();
                handler.sendEmptyMessage(FINISHED_TRANSCODING_MSG);

            } catch(Exception e) {
                Log.e("threadmessage",e.getMessage());
            }
        }
    }.start();

    // Progress update thread
    new Thread() {
        ProgressCalculator pc = new ProgressCalculator(vkLogPath);
        public void run() {
            Log.d(Prefs.TAG,"Progress update started");
            int progress = -1;
            try {
                while (true) {
                    sleep(300);
                    progress = pc.calcProgress();
                    if (progress != 0 && progress < 100) {
                        progressBar.setProgress(progress);
                    }
                    else if (progress == 100) {
                        Log.i(Prefs.TAG, "==== progress is 100, exiting Progress update thread");
                        pc.initCalcParamsForNextInter();
                        break;
                    }
                }

            } catch(Exception e) {
                Log.e("threadmessage",e.getMessage());
            }
        }
    }.start();
}

public void savevideo (Uri mVideoURI){
    demoVideoFolder = mVideoURI.getPath();
    demoVideoPath = demoVideoFolder;
    Log.i(Prefs.TAG, getString(R.string.app_name) + " version: " + GeneralUtils.getVersionName(getApplicationContext()));

    Button invoke = (Button) findViewById(R.id.button);
    invoke.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Log.i(Prefs.TAG, "run clicked.");
            runTranscoding();
        }
    });

    workFolder = getApplicationContext().getFilesDir() + "/";
    Log.i(Prefs.TAG, "workFolder (license and logs location) path: " + workFolder);
    vkLogPath = workFolder + "vk.log";
    Log.i(Prefs.TAG, "vk log (native log) path: " + vkLogPath);
    GeneralUtils.copyLicenseFromAssetsToSDIfNeeded(this, workFolder);
    GeneralUtils.copyDemoVideoFromAssetsToSDIfNeeded(this, demoVideoFolder);
    int rc = GeneralUtils.isLicenseValid(getApplicationContext(), workFolder);
    Log.i(Prefs.TAG, "License check RC: " + rc);

}
}


    


    FFmpeg command :

    


    String[] complexCommand = {"ffmpeg","-y" ,"-i",  "/sdcard/videokit/in.mp4","-strict","experimental",
            "-vf", "movie=/sdcard/videokit/watermark.png [watermark];" +
            " [in][watermark] overlay=main_w-overlay_w-10:10 [out]","-s",
            "320x240","-r", "30", "-b", "15496k", "-vcodec", "mpeg4","-ab",
            "48000", "-ac", "2", "-ar", "22050", "/sdcard/videokit/out1.mp4"};


    


    Tis command is from a sample project. How do I pass the video path to this command ? I do not know how to edit the command to support my requirement. Can someone guide me through this. Any help will be really helpful. Thank you.

    


  • Evolution #4552 : Appliquer tout le temps la classe demandée à lien_ou_expose

    17 septembre 2020, par RastaPopoulos ♥

    +1 pour pouvoir spécifier la classe d’exposition aussi, encore plus, parce que "on" ok par défaut, mais c’est super chiant d’imposer des classes quand on a un système cohérent déjà en place