
Recherche avancée
Autres articles (95)
-
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
Gestion des droits de création et d’édition des objets
8 février 2011, parPar défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;
-
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
Sur d’autres sites (4425)
-
Révision 98073 : Report de r98071 : Report de r98068 : Certains flux RSS publient l’integralite de...
26 mai 2016, par cedric@yterium.comOn optimise les fonctions cdata_echappe et cdata_echappe_retour, et on limite la syndication aux 1000 premiers items, surchargeable par la constante _SYNDICATION_MAX_ITEMS
-
seeking with av_seek_frame returns invalid data
27 juin 2016, par mtadmkBased on dranger tutorial I’m trying to implement seeking in video file. Problem is with seeking to beginning milliseconds - it always returns 0 when seeking backward, or some place in file (based on file format).
I.e. with this video file and seeking forward to 500 pts there is always 6163 pts returned. Seeking backward to 500 is always returning 0. I have no idea why.
Code to do this :
import java.util.Arrays;
import java.util.List;
import org.bytedeco.javacpp.BytePointer;
import org.bytedeco.javacpp.DoublePointer;
import org.bytedeco.javacpp.PointerPointer;
import org.bytedeco.javacpp.avcodec;
import org.bytedeco.javacpp.avformat;
import org.bytedeco.javacpp.avutil;
import org.bytedeco.javacpp.swscale;
import static org.bytedeco.javacpp.avcodec.av_free_packet;
import static org.bytedeco.javacpp.avcodec.avcodec_close;
import static org.bytedeco.javacpp.avcodec.avcodec_decode_video2;
import static org.bytedeco.javacpp.avcodec.avcodec_find_decoder;
import static org.bytedeco.javacpp.avcodec.avcodec_flush_buffers;
import static org.bytedeco.javacpp.avcodec.avcodec_open2;
import static org.bytedeco.javacpp.avcodec.avpicture_fill;
import static org.bytedeco.javacpp.avcodec.avpicture_get_size;
import static org.bytedeco.javacpp.avformat.AVSEEK_FLAG_BACKWARD;
import static org.bytedeco.javacpp.avformat.av_dump_format;
import static org.bytedeco.javacpp.avformat.av_read_frame;
import static org.bytedeco.javacpp.avformat.av_register_all;
import static org.bytedeco.javacpp.avformat.av_seek_frame;
import static org.bytedeco.javacpp.avformat.avformat_close_input;
import static org.bytedeco.javacpp.avformat.avformat_find_stream_info;
import static org.bytedeco.javacpp.avformat.avformat_open_input;
import static org.bytedeco.javacpp.avutil.AVMEDIA_TYPE_VIDEO;
import static org.bytedeco.javacpp.avutil.AV_PIX_FMT_RGB24;
import static org.bytedeco.javacpp.avutil.AV_TIME_BASE;
import static org.bytedeco.javacpp.avutil.av_frame_alloc;
import static org.bytedeco.javacpp.avutil.av_frame_get_best_effort_timestamp;
import static org.bytedeco.javacpp.avutil.av_free;
import static org.bytedeco.javacpp.avutil.av_make_q;
import static org.bytedeco.javacpp.avutil.av_malloc;
import static org.bytedeco.javacpp.avutil.av_q2d;
import static org.bytedeco.javacpp.avutil.av_rescale_q;
import static org.bytedeco.javacpp.swscale.SWS_BILINEAR;
import static org.bytedeco.javacpp.swscale.sws_getContext;
import static org.bytedeco.javacpp.swscale.sws_scale;
public class SeekTest1 {
private avformat.AVFormatContext videoFile;
private final avcodec.AVPacket framePacket = new avcodec.AVPacket();
private avcodec.AVCodecContext videoCodec;
private avutil.AVFrame yuvFrame;
private swscale.SwsContext scalingContext;
private avutil.AVFrame rgbFrame;
private int streamId;
private long lastTime;
public static void main(String[] args) {
if (args.length > 0) {
new SeekTest1().start(args[0]);
} else {
new SeekTest1().start("/path/to/file");
}
}
private void start(String path) {
init(path);
//test for forward
// List<integer> seekPos = Arrays.asList(0, 100, 0, 200, 0, 300, 0, 400, 0, 500, 0, 600, 0, 700);
//test for backward
List<integer> seekPos = Arrays.asList(10000, 8000, 10000, 7000, 10000, 6000, 10000, 4000, 10000, 2000, 10000, 1000, 10000, 200);
seekPos.forEach(seekPosition -> {
readFrame();
seek(seekPosition);
});
readFrame();
cleanUp();
}
long seek(long seekPosition) {
final avutil.AVRational timeBase = fetchTimeBase();
long timeInBaseUnit = fetchTimeInBaseUnit(seekPosition, timeBase);
//changing flag to AVSEEK_FLAG_ANY does not change behavior
int flag = 0;
if (timeInBaseUnit < lastTime) {
flag = AVSEEK_FLAG_BACKWARD;
System.out.println("seeking backward to " + timeInBaseUnit);
} else {
System.out.println("seeking forward to " + timeInBaseUnit);
}
avcodec_flush_buffers(videoCodec);
av_seek_frame(videoFile, streamId, timeInBaseUnit, flag);
return timeInBaseUnit;
}
private long fetchTimeInBaseUnit(long seekPositionMillis, avutil.AVRational timeBase) {
return av_rescale_q((long) (seekPositionMillis / 1000.0 * AV_TIME_BASE), av_make_q(1, AV_TIME_BASE), timeBase);
}
private void readFrame() {
while (av_read_frame(videoFile, framePacket) >= 0) {
if (framePacket.stream_index() == streamId) {
// Decode video frame
final int[] frameFinished = new int[1];
avcodec_decode_video2(this.videoCodec, yuvFrame, frameFinished, framePacket);
if (frameFinished[0] != 0) {
av_free_packet(framePacket);
long millis = produceFinishedFrame();
System.out.println("produced time " + millis);
break;
}
}
av_free_packet(framePacket);
}
}
private long produceFinishedFrame() {
sws_scale(scalingContext, yuvFrame.data(), yuvFrame.linesize(), 0,
videoCodec.height(), rgbFrame.data(), rgbFrame.linesize());
final long pts = av_frame_get_best_effort_timestamp(yuvFrame);
final double timeBase = av_q2d(fetchTimeBase());
final long foundMillis = (long) (pts * 1000 * timeBase);
lastTime = foundMillis;
return foundMillis;
}
private avutil.AVRational fetchTimeBase() {
return videoFile.streams(streamId).time_base();
}
private void init(String videoPath) {
final avformat.AVFormatContext videoFile = new avformat.AVFormatContext(null);
av_register_all();
if (avformat_open_input(videoFile, videoPath, null, null) != 0) throw new RuntimeException("unable to open");
if (avformat_find_stream_info(videoFile, (PointerPointer) null) < 0) throw new RuntimeException("Couldn't find stream information");
av_dump_format(videoFile, 0, videoPath, 0);
final int streamId = findFirstVideoStream(videoFile);
final avcodec.AVCodecContext codec = videoFile.streams(streamId).codec();
final avcodec.AVCodec pCodec = avcodec_find_decoder(codec.codec_id());
if (pCodec == null) throw new RuntimeException("Unsupported codec");
if (avcodec_open2(codec, pCodec, (avutil.AVDictionary) null) < 0) throw new RuntimeException("Could not open codec");
final avutil.AVFrame yuvFrame = av_frame_alloc();
final avutil.AVFrame rgbFrame = av_frame_alloc();
if (rgbFrame == null) throw new RuntimeException("Can't allocate avframe");
final int numBytes = avpicture_get_size(AV_PIX_FMT_RGB24, codec.width(), codec.height());
final BytePointer frameBuffer = new BytePointer(av_malloc(numBytes));
final swscale.SwsContext swsContext = sws_getContext(codec.width(), codec.height(), codec.pix_fmt(), codec.width(), codec.height(),
AV_PIX_FMT_RGB24, SWS_BILINEAR, null, null, (DoublePointer) null);
avpicture_fill(new avcodec.AVPicture(rgbFrame), frameBuffer, AV_PIX_FMT_RGB24, codec.width(), codec.height());
this.videoFile = videoFile;
this.videoCodec = codec;
this.yuvFrame = yuvFrame;
this.scalingContext = swsContext;
this.rgbFrame = rgbFrame;
this.streamId = streamId;
}
private static int findFirstVideoStream(avformat.AVFormatContext videoFile) {
int videoStream = -1;
for (int i = 0; i < videoFile.nb_streams(); i++) {
if (videoFile.streams(i).codec().codec_type() == AVMEDIA_TYPE_VIDEO) {
videoStream = i;
break;
}
}
if (videoStream == -1) throw new RuntimeException("Didn't find video stream");
return videoStream;
}
private void cleanUp() {
av_free(this.rgbFrame);
av_free(yuvFrame);
avcodec_close(videoCodec);
avformat_close_input(videoFile);
}
}
</integer></integer>As input arg should be provided file from above.
-
converting all the mp4 audio files in a folder to mp3 using ffmpeg
21 juillet 2016, par Raulphow can I convert all of the
mp4
files in a given folder tomp3
using ffmpeg.
Almost all of the links I have seen on google is all about converting mp4 video to mp3.
I can do this via VLC player but I have got huge collection 1000 mp4 audio files and want this to be done over command line by some script or command.
Is it possible to do it via gstreamer ?