
Recherche avancée
Autres articles (48)
-
Multilang : améliorer l’interface pour les blocs multilingues
18 février 2011, parMultilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela. -
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 -
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 (9583)
-
How to convert a ffmpeg command to work with ffmpy ?
8 juillet 2021, par DaveguyI am trying to extract a certain audio segment from an entire audio file using ffmpy, which I haven't really worked with before. So far, I have looked into extracting a certain time range, which suggests to use a command like this :


ffmpeg -ss 00:01:00 -i input.mp3 -to 00:02:00 -c copy output.mp3


In my case, I am trying to write a Python script to do this over multiple audio files. Since I am reading from a csv and all that, I am storing important information in variables. However, being a first time user of ffmpy and ffmpeg I'm really not sure how I'm supposed to do that.


Below is the code that I have so far (including what I attempted to do to so far to extract the audio bits) :


for line in reader:
 # Get access to the stored file as found in the audio_files dir
 print(line)
 folder_name = line[1].split("/")[len(line[1].split("/")) - 2]
 file_name = line[1].split("/")[len(line[1].split("/")) - 1]

 
 audio_file_path = "./audio_files/" + folder_name + "/" + file_name.split(".")[0] + ".mp3"
 print(audio_file_path)

 start_time = line[2]
 end_time = line[3]

 # Use ffmpy/ffmpeg to extract the audio bits
 ff = FFmpeg(inputs={file_name + ".mp3": "None"}, outputs={file_name + "_truncated.mp3": "None"})
 ff.cmd = 'ffmpeg -i "' + audio_file_path + '" -ss ' + start_time + ' -to ' + end_time + ' -async 1 ' + '"./audio_files/' + folder_name + '/' + file_name.split(".")[0] + '_cut.mp3"'
 print(ff.cmd)
 ff.run()



The main issue which I am currently facing is I am having issues running with
ff.run()
. Even though running the same command on command line (using ffmpeg) seems to go flawlessly, when trying to run withffmpy
it gives me "FFRuntime Exited With Status Code 1", and I'm not sure what could be causing this. As I have only just started using ffmpy and ffmpeg I'm not entirely sure what I'm doing is right, so any help would be greatly appreciated.

-
How to Make Video from Arraylist of images with Music
6 avril 2018, par hardik sojitraI am making an app which makes video from selected images which is stored in SD card I have implement the
group : ’com.github.hiteshsondhi88.libffmpeg’, name : ’FFmpegAndroid’, version : ’0.2.5’ this library and make this classes but it does not workUtility.java
public class Utility {
private final static String TAG = Utility.class.getName();
private static Context mContext;
public Utility(Context context) {
mContext = context;
}
public static String excuteCommand(String command)
{
try {
Log.d(TAG, "execute command : " + command);
Process process = Runtime.getRuntime().exec(command);
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
process.waitFor();
Log.d(TAG, "command result: " + output.toString());
return output.toString();
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
} catch (InterruptedException e) {
Log.e(TAG, e.getMessage(), e);
}
return "";
}
public String getPathOfAppInternalStorage()
{
return Environment.getExternalStorageDirectory().getAbsolutePath();
}
public void saveFileToAppInternalStorage(InputStream inputStream, String fileName)
{
File file = new File(getPathOfAppInternalStorage() + "/" + fileName);
if (file.exists())
{
Log.d(TAG, "SaveRawToAppDir Delete Exsisted File");
file.delete();
}
FileOutputStream outputStream;
try {
outputStream = mContext.openFileOutput(fileName, Context.MODE_PRIVATE);
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) > 0)
{
outputStream.write(buffer, 0, length);
}
outputStream.close();
inputStream.close();
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
}
}
public static boolean isFileExsisted(String filePath)
{
File file = new File(filePath);
return file.exists();
}
public static void deleteFileAtPath(String filePath)
{
File file = new File(filePath);
file.delete();
}
}ffmpegController.java
package com.example.admin.imagetovideowithnative;
import android.content.Context;
import android.util.Log;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
public class FfmpegController {
private static Context mContext;
private static Utility mUtility;
private static String mFfmpegBinaryPath;
public FfmpegController(Context context) {
mContext = context;
mUtility = new Utility(context);
initFfmpeg();
}
private void initFfmpeg()
{
mFfmpegBinaryPath = mContext.getApplicationContext().getFilesDir().getAbsolutePath() + "/ffmpeg";
if (Utility.isFileExsisted(mFfmpegBinaryPath))
return;
InputStream inputStream = mContext.getResources().openRawResource(R.raw.ffmpeg);
mUtility.saveFileToAppInternalStorage(inputStream, "ffmpeg");
Utility.excuteCommand(CommandHelper.commandChangeFilePermissionForExecuting(mFfmpegBinaryPath));
}
public void convertImageToVideo(String inputImgPath)
{
Log.e("Image Parth", "inputImgPath - "+inputImgPath);
if (Utility.isFileExsisted(pathOuputVideo()))
Utility.deleteFileAtPath(pathOuputVideo());
saveShellCommandImg2VideoToAppDir(inputImgPath);
Utility.excuteCommand("sh" + " " + pathShellScriptImg2Video());
}
public String pathOuputVideo()
{
return mUtility.getPathOfAppInternalStorage() + "/out.mp4";
}
private String pathShellScriptImg2Video()
{
return mUtility.getPathOfAppInternalStorage() + "/img2video.sh";
}
private void saveShellCommandImg2VideoToAppDir(String inputImgPath)
{
String command = CommandHelper.commandConvertImgToVideo(mFfmpegBinaryPath, inputImgPath, pathOuputVideo());
InputStream is = new ByteArrayInputStream(command.getBytes());
mUtility.saveFileToAppInternalStorage(is, "img2video.sh");
}
}CommandHelper.java
package com.example.admin.imagetovideowithnative;
import android.util.Log;
public class CommandHelper {
public static String commandConvertImgToVideo(String ffmpegBinaryPath, String inputImgPath, String outputVideoPath) {
Log.e("ffmpegBinaryPath", "ffmpegBinaryPath - " + ffmpegBinaryPath);
Log.e("inputImgPath", "inputImgPath - " + inputImgPath);
Log.e("outputVideoPath", "outputVideoPath - " + outputVideoPath);
return ffmpegBinaryPath + " -r 1/1 -i " + inputImgPath + " -c:v libx264 -crf 23 -pix_fmt yuv420p -s 640x480 " + outputVideoPath;
}
public static String commandChangeFilePermissionForExecuting(String filePath) {
return "chmod 777 " + filePath;
}
}AsynckTask
class Asynck extends AsyncTask {
FfmpegController mFfmpegController = new FfmpegController(PhotosActivity.this);
Utility mUtility = new Utility(PhotosActivity.this);
@Override
protected void onPreExecute() {
super.onPreExecute();
Log.e("Video Process Start", "======================== Video Process Start ======================================");
}
@Override
protected Void doInBackground(Object... objects) {
mFfmpegController.convertImageToVideo("");
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
Log.e("Video Process Complete", "======================== Video Process Complete ======================================");
Log.e("Video Path", "Path - " + mFfmpegController.pathOuputVideo());
Toast.makeText(PhotosActivity.this, "Video Process Complete", Toast.LENGTH_LONG).show();
}
} -
How can ffmpeg concat MP3s with full metadata incl. cover art ?
13 décembre 2022, par TENAudio books inconveniently split into dozens of MP3s (with spaces in their names) should be merged into one MP3 in a subdirectory (in which ffmpeg version 4.2.7-0ubuntu0.1 is invoked), without time-consuming and possibly degrading conversions, reliably preserving all metadata incl. cover art (present and similar in all MP3s of a title, their differences being significant only in lengths and track numbers).


However, rather than picking the latter from the first input MP3, the https://trac.ffmpeg.org/wiki/Concatenate#protocol loses the cover art, the https://trac.ffmpeg.org/wiki/Concatenate#demuxer documented as more flexible even loses all metadata :


ffmpeg -v verbose -f concat -safe 0 -i <(printf "file '$PWD/%s'\n" ../in\ track*.mp3) -c copy "out.mp3"
...
Input #0, concat, from '/dev/fd/63':
Duration: N/A, start: 0.000000, bitrate: 192 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 192 kb/s
Stream #0:1: Video: png, 1 reference frame, rgba(pc), 300x300, 90k tbr, 90k tbn, 90k tbc
Metadata:
title : 12ae3b8152eaf255ae0315c59400c540.png
comment : Cover (front)
...
Output #0, mp3, to 'out.mp3':
Metadata:
TSSE : Lavf58.29.100
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 192 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
...
[AVIOContext @ 0x561459f3dac0] Statistics: 1958050 bytes read, 0 seeks
[mp3 @ 0x561459f3f900] Skipping 0 bytes of junk at 110334.
[mp3 @ 0x561459f3f900] Estimating duration from bitrate, this may be inaccurate
No more output streams to write to, finishing.
size= 75793kB time=00:53:03.12 bitrate= 195.1kbits/s speed= 636x
video:0kB audio:75793kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000865%
Input file #0 (/dev/fd/63):
Input stream #0:0 (audio): 121847 packets read (77611658 bytes);
Input stream #0:1 (video): 40 packets read (4358440 bytes);
Total: 121887 packets (81970098 bytes) demuxed
Output file #0 (out.mp3):
Output stream #0:0 (audio): 121847 packets muxed (77611658 bytes);
Total: 121847 packets (77611658 bytes) muxed
[AVIOContext @ 0x561459ef6700] Statistics: 2 seeks, 298 writeouts
[AVIOContext @ 0x561459f39e40] Statistics: 2006324 bytes read, 0 seeks
[AVIOContext @ 0x561459ee0300] Statistics: 5040 bytes read, 0 seek



The metadata incl. cover PNG as detected (as single-frame "video") should end up in the output MP3, but doesn't (even when adding -movflags use_metadata_tags possibly intended for other formats).


-metadata track="1/1" (or without the /1 ?) may be required as the first input MP3 sometimes wrongly starts at a higher number.


How do I make sure no metadata (incl. image) other than track numbers is lost when concatenating MP3s (by protocol or demuxer, from a set of input files with spaces in their names and a wildcard to match across track numbers) ?