
Recherche avancée
Médias (1)
-
Richard Stallman et le logiciel libre
19 octobre 2011, par
Mis à jour : Mai 2013
Langue : français
Type : Texte
Autres articles (66)
-
Submit bugs and patches
13 avril 2011Unfortunately a software is never perfect.
If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
You may also (...) -
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...) -
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 (8645)
-
how to cut video with specific time using c code ffmpeg ?
17 avril 2017, par FidonaI’m using ffmpeg c code to skip some scene on video. so i have a script like this.
#include <libavutil></libavutil>timestamp.h>
#include <libavformat></libavformat>avformat.h>
#include <libavutil></libavutil>time.h> // av_gettime()
#include
int64_t total = 0;
static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt, const char *tag, int hours, int mins, int secs, int us, int *time )
{
AVRational *time_base = &fmt_ctx->streams[pkt->stream_index]->time_base;
total = total + pkt->duration;
*time = av_q2d(*time_base) * pkt->pts ; //ts
}
int iexclude[50];
int nexclude=0;
static int inexclude( int v ) {
for( int i=0; i < nexclude; ) {
if( iexclude[i] <= v && v <= iexclude[i+1] )
return 1;
i = i + 2;
}
return 0;
}
int main(int argc, char **argv)
{
AVOutputFormat *ofmt = NULL;
AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
AVPacket pkt;
const char *in_filename, *out_filename;
char *ex_time, *token;
int ret, i;
int stream_index = 0;
int *stream_mapping = NULL;
int stream_mapping_size = 0;
int hours, mins, secs, us, time, insec;
int tex[ ] = { 1760, 3060, 4500, 4850, 6235 };
if (argc < 4 ) {
printf("usage: %s input output time_exclude\n"
"API example program to remux a media file with libavformat and libavcodec.\n"
"The output format is guessed according to the file extension.\n"
" time_exclude ex : 29:17-29:26,50:53-51:20 (without space, comma separated) \n", argv[0]);
return 1;
}
in_filename = argv[1];
out_filename = argv[2];
ex_time = argv[3];
token = strtok( ex_time, ",-" );
/* walk through other tokens */
while( token != NULL )
{
sscanf( token, "%2d:%2d:%2d", &hours, &mins, &secs ) ;
insec = hours*3600 + mins*60 + secs;
iexclude[ nexclude++ ] = insec;
printf( "%s - %2d:%2d:%2d - %6d\n", token, hours, mins, secs, insec );
token = strtok(NULL, ",-" );
}
for( int i=0; i<5; i++ )
printf( "%d\n", inexclude( tex[i] ));
av_register_all();
if ((ret = avformat_open_input(&ifmt_ctx, in_filename, 0, 0)) < 0) {
fprintf(stderr, "Could not open input file '%s'", in_filename);
goto end;
}
if ((ret = avformat_find_stream_info(ifmt_ctx, 0)) < 0) {
fprintf(stderr, "Failed to retrieve input stream information");
goto end;
}
av_dump_format(ifmt_ctx, 0, in_filename, 0);
avformat_alloc_output_context2(&ofmt_ctx, NULL, NULL, out_filename);
if (!ofmt_ctx) {
fprintf(stderr, "Could not create output context\n");
ret = AVERROR_UNKNOWN;
goto end;
}
stream_mapping_size = ifmt_ctx->nb_streams;
stream_mapping = av_mallocz_array(stream_mapping_size, sizeof(*stream_mapping));
if (!stream_mapping) {
ret = AVERROR(ENOMEM);
goto end;
}
ofmt = ofmt_ctx->oformat;
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
AVStream *out_stream;
AVStream *in_stream = ifmt_ctx->streams[i];
AVCodecParameters *in_codecpar = in_stream->codecpar;
if (in_codecpar->codec_type != AVMEDIA_TYPE_AUDIO &&
in_codecpar->codec_type != AVMEDIA_TYPE_VIDEO &&
in_codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) {
stream_mapping[i] = -1;
continue;
}
stream_mapping[i] = stream_index++;
out_stream = avformat_new_stream(ofmt_ctx, NULL);
if (!out_stream) {
fprintf(stderr, "Failed allocating output stream\n");
ret = AVERROR_UNKNOWN;
goto end;
}
ret = avcodec_parameters_copy(out_stream->codecpar, in_codecpar);
if (ret < 0) {
fprintf(stderr, "Failed to copy codec parameters\n");
goto end;
}
out_stream->codecpar->codec_tag = 0;
}
av_dump_format(ofmt_ctx, 0, out_filename, 1);
if (!(ofmt->flags & AVFMT_NOFILE)) {
ret = avio_open(&ofmt_ctx->pb, out_filename, AVIO_FLAG_WRITE);
if (ret < 0) {
fprintf(stderr, "Could not open output file '%s'", out_filename);
goto end;
}
}
ret = avformat_write_header(ofmt_ctx, NULL);
if (ret < 0) {
fprintf(stderr, "Error occurred when opening output file\n");
goto end;
}
int64_t pts = INT64_MIN + 1;
int64_t now;
AVRational ar;
int loop = 0;
while (1) {
loop++;
AVStream *in_stream, *out_stream;
ret = av_read_frame(ifmt_ctx, &pkt);
if (ret < 0)
break;
in_stream = ifmt_ctx->streams[pkt.stream_index];
if (pkt.stream_index >= stream_mapping_size ||
stream_mapping[pkt.stream_index] < 0) {
av_packet_unref(&pkt);
continue;
}
pkt.stream_index = stream_mapping[pkt.stream_index];
out_stream = ofmt_ctx->streams[pkt.stream_index];
//log_packet(ifmt_ctx, &pkt, "in");
/* copy packet */
pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);
pkt.pos = -1;
log_packet(ofmt_ctx, &pkt, "out", hours, mins, secs, us, &time );
//if ( time <= 30 || time >= 150 )
if( ! inexclude( time ) )
ret = av_interleaved_write_frame(ofmt_ctx, &pkt);
if (ret < 0) {
fprintf(stderr, "Error muxing packet\n");
break;
}
av_packet_unref(&pkt);
}
printf("Loop %d\n", loop );
av_write_trailer(ofmt_ctx);
end:
avformat_close_input(&ifmt_ctx);
/* close output */
if (ofmt_ctx && !(ofmt->flags & AVFMT_NOFILE))
avio_closep(&ofmt_ctx->pb);
avformat_free_context(ofmt_ctx);
av_freep(&stream_mapping);
if (ret < 0 && ret != AVERROR_EOF) {
fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
return 1;
}
and the resul
printf( "Total = %u AV_TIME_BASE=%d\n", total , AV_TIME_BASE );
return 0;
}the code is save with the extension .c
when i compile this code to skip some scene in specific time, the video was skipped, but it stay freeze until the specified time that i input is finished. what should i add on the code to make the freeze scene get cut ? -
Issue opening video file with OpenCV VideoCapture
1er mai 2017, par user1938805I’ve been reviewing the multitudes of similar questions for this issue, but I’m afraid I just cannot figure out why I cannot open a file in opencv
I have a file "small.avi", which is a reencoding of "small.mp4" that I got from the internet. I reencoded it with ffmpeg -i small.mp4 small.avi, and I did this because I couldn’t open a mp4 file either and online it recommended trying an avi format first.
Here is my code (mostly copied from a tutorial, with a few lines to show some relevant info) :
import cv2
import os
for _, __, files in os.walk("."):
for file in files:
print file
print ""
cap = cv2.VideoCapture("small.mp4")
print cap.isOpened()
print cap.open("small.avi")
i = 0
while cap.isOpened() and i < 10:
i += 1
ret, frame = cap.read()
print "read a frame"
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame', gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()This produces the following output :
"A:\Program Files\AnacondaPY\Anaconda\python.exe" A:/Documents/Final/VideoProcessor.py
small.avi
small.mp4
VideoProcessor.py
False
False
Process finished with exit code 0My program does not appear to properly open either file. Following the advice of
Can not Read or Play a Video in OpenCV+Python using VideoCapture
and
Cannot open ".mp4" video files using OpenCV 2.4.3, Python 2.7 in Windows 7 machine,
I found my cv2 version to be 3.0.0, went to
A :\Downloads\opencv\build\x86\vc12\bin
and copied the file opencv_ffmpeg300.dll to
A :\Program Files\AnacondaPY\Anaconda
Despite this, the code still does not successfully open the video file. I even tried the x64 versions, and tried naming the file opencv_ffmpeg.dll, opencv_ffmpeg300.dll, and opencv_ffmpeg300_64.dll (for the x64 version). Is there anything else I can try to fix this ?
Thanks for any help
-
OpenCv is giving error to play the downloaded video
17 août 2015, par Prat_yowProgram a code for a tiny system, which should run on Linux :
A routine (P) accepts strings from an unknown remote Internet source,
which contain just an URL and a file name.The URL and the file name point to a multimedia file, in our case a video
(P) separates the file name from the string
(P) checks if the file already exists on the system’s internal memory card, as
(P) is running on a tiny Linux machine connected to a screenIf it does not exist, (P) downloads the video file from the given URL and
stores it in the memory cardFinally, (P) opens the file and plays it as a full screen video (no external video
player allowed !)After this (P) starts from the beginning
There is no user action involved and nobody enters data by hand or mouse
clicksI have written code in python. But when I run it it just not load the cv module. Can someone suggest if my approach is correct.? Will doing in java or other compiled language will be easy.?
My code is :
import os
import urllib
import cv
import sys
"""
The following program will take the url as input. Separate the file name of the video from the url
and check if the file is present in the current memory location or not. If the same file is present
it will indicate its presence. If the file is not present it will download the file and play it.
urrlib: to download the video file.
cv: For playing the video.
"""
#NOTE Configuration of FFMPEG and OpenCV is required.
#NOTE Assuming that the given code is execute from the internal memory location.
#NOTE Assuming the URL is of the form <initial part="part" of="of" the="the" url="url"></initial><filename>.<format>
sys.path.append('/opt/ros/hydro/lib/python2.7/dist-packages')
def myVideo(url):
search_folder = "."
videoFile = url.split('/')[-1].split('#')[0].split('?')[0] #stripping the name of the file.
for root, dirs, files in os.walk(search_folder): # using the os.walk module to find the files.
for name in files:
#print os.path.join(name)
"""Checking the videofile in the current directory and the sub-directories"""
if videoFile == os.path.join(name): #checking if the file is already present in the internal memory.
print "The file is already present in the internal memory"
return -1 # Returning the confirmation that the file is present.
else:
print "Downloading the file"
video = urllib.FancyURLopener() #downloading the file using urllib.
video.retrieve(url,videoFile)
curDir = os.getcwd() # getting the current working directory.
fullVideoPath = os.path.join(curDir,videoFile) # Making the full path of the video file.
"""For playing the file using openCV first read the file.
Find the number of frames and the frame rate.
Finally use these parameters to display each extracted frame on the screen"""
vFile = cv.CaptureFromFile(fullVideoPath)
nFrames = int( cv.GetCaptureProperty( vidFile, cv.CV_CAP_PROP_FRAME_COUNT ) ) #Number of frames in the video.
fps = cv.GetCaptureProperty( vidFile, cv.CV_CAP_PROP_FPS ) # Frame rate
waitPerFrameInMillisec = int( 1/fps * 1000/1 ) # Wait time between frames.
for f in xrange( nFrames ):
frameImg = cv.QueryFrame( vidFile )
cv.ShowImage( "My Show", frameImg )
cv.WaitKey( waitPerFrameInMillisec )
cv.DestroyWindow( "My Show" ) # Deleting the window once the playing is done.
return 1 # returning the confimation that the file was played successfully.
if __name__ == "__main__":
url = "http://techslides.com/demos/sample-videos/small.mp4"
myVideo(url)
</format></filename>