
Recherche avancée
Autres articles (36)
-
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 -
Other interesting software
13 avril 2011, parWe don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
We don’t know them, we didn’t try them, but you can take a peek.
Videopress
Website : http://videopress.com/
License : GNU/GPL v2
Source code : (...) -
Création définitive du canal
12 mars 2010, parLorsque votre demande est validée, vous pouvez alors procéder à la création proprement dite du canal. Chaque canal est un site à part entière placé sous votre responsabilité. Les administrateurs de la plateforme n’y ont aucun accès.
A la validation, vous recevez un email vous invitant donc à créer votre canal.
Pour ce faire il vous suffit de vous rendre à son adresse, dans notre exemple "http://votre_sous_domaine.mediaspip.net".
A ce moment là un mot de passe vous est demandé, il vous suffit d’y (...)
Sur d’autres sites (6970)
-
ffmpeg concatenating videos of different fps while keeping the total length not changed
23 novembre 2017, par A_MatarI wanna pad an
mp4
video stream with another video clip of a static image that I created using :def generate_white_vid (duration):
output_filename = os.path.join(p_path,'white_vid_'+" 0:.2f}".format(duration)+'.mp4')
ffmpeg_create_vid_from_static_img = 'ffmpeg -loop 1 -i /path/WhiteBackground.jpg -c:v libx264 -t %f -pix_fmt yuv420p -vf scale=1920:1080 %s' % (duration, output_filename)
p = subprocess.Popen(ffmpeg_create_vid_from_static_img, shell=True)
p.communicate()
return output_filenameI use the following to concatenate :
def concat_vids(clip_paths):
filenames_txt = open('clips_to_join.txt','w')
for clip in clip_paths:
filenames_txt.write ('file \''+ clip+'\'\n')
filenames_txt.close()
output_filename = clip_paths[0].split('.', 2)[0]
output_file_path = os.path.join(root_path, output_filename+'-padded.mp4')
# join the clips
ffmpeg_command = ["ffmpeg", "-f", "concat", "-safe", "0", "-i", "clips_to_join.txt", "-codec", "copy", output_file_path] # output_filename = ch0X-start_time-end_time
p = subprocess.Popen(ffmpeg_command)
p.communicate() # wait till the subprocess finishes. You can send commands to process as well.
return output_file_pathWhen I check the length of the resulting video after concatenation, I find that it is not equal to the sum of the two segments that I concatenated, and sometimes it is even less by some seconds !!
Here is how I get the video length in seconds :
def ffmpeg_len(vid_path):
'''
Returns length in seconds using ffmpeg
'''
ffmpeg_get_mediafile_length = ['sh', '-c', 'ffmpeg -i "$1" 2>&1 | grep Duration', '_', vid_path]
p = subprocess.Popen(ffmpeg_get_mediafile_length, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, err = p.communicate()
length_regexp = 'Duration: (\d{2}):(\d{2}):(\d{2})(\.\d+),'
re_length = re.compile(length_regexp)
matches = re_length.search(output)
if matches:
video_length = int(matches.group(1)) * 3600 + \
int(matches.group(2)) * 60 + \
int(matches.group(3)) + float(matches.group(4))
return video_length
else:
print("Can't determine video length.")
print err
raise SystemExitMy guess is that maybe the concatenation unifies the
fps
rate for the all the clips to be joined, if this is the case, how to prevent this from happening ? How can I get a video of the desired length exactly.Maybe it worth mentioning that the video to padded is very short
0.42 second
, the original video is210.58
and the resultant video is210.56
!I have verified that ffmpeg does generate the desired padding region and it is of the desired length
0.42
I got a 0.43 segment when I forced30 fps
but it is okay. -
How to save image from the middle of a video ?
29 octobre 2017, par puppon -suI need to make a thumbnail for a video, to seek to the 25% of a video and save the image. Here is what I’m doing right now, but it only saves black image.
#include
#include <libavformat></libavformat>avformat.h>
#include <libavutil></libavutil>dict.h>
int main (int argc, char **argv)
{
av_register_all();
AVFormatContext *pFormatCtx = avformat_alloc_context();
int res;
res = avformat_open_input(&pFormatCtx, "test.mp4", NULL, NULL);
if (res) {
return res;
}
avformat_find_stream_info(pFormatCtx, NULL);
int64_t duration = pFormatCtx->duration;
// Find the first video stream
int videoStream=-1;
for(int i=0; inb_streams; i++) {
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) {
videoStream=i;
break;
}
}
if(videoStream==-1) {
return -1;
}
AVCodecContext *pCodecCtxOrig = NULL;
// Get a pointer to the codec context for the video stream
pCodecCtxOrig=pFormatCtx->streams[videoStream]->codec;
AVCodec *pCodec = NULL;
// Find the decoder for the video stream
pCodec=avcodec_find_decoder(pCodecCtxOrig->codec_id);
if(pCodec==NULL) {
fprintf(stderr, "Unsupported codec!\n");
return -1; // Codec not found
}
AVCodecContext *pCodecCtx = NULL;
// Copy context
pCodecCtx = avcodec_alloc_context3(pCodec);
if(avcodec_copy_context(pCodecCtx, pCodecCtxOrig) != 0) {
fprintf(stderr, "Couldn't copy codec context");
return -1; // Error copying codec context
}
// Open codec
if(avcodec_open2(pCodecCtx, pCodec, NULL)<0) {
return -1; // Could not open codec
}
AVFrame *pFrame = NULL;
pFrame=av_frame_alloc();
AVFrame *pFrameRGB = NULL;
pFrameRGB=av_frame_alloc();
// Determine required buffer size and allocate buffer
int numBytes=avpicture_get_size(AV_PIX_FMT_RGB24, pCodecCtx->width,
pCodecCtx->height);
uint8_t *buffer = NULL;
buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
// Assign appropriate parts of buffer to image planes in pFrameRGB
// Note that pFrameRGB is an AVFrame, but AVFrame is a superset
// of AVPicture
res = avpicture_fill((AVPicture *)pFrameRGB, buffer, AV_PIX_FMT_RGB24,
pCodecCtx->width, pCodecCtx->height);
if (res<0) {
return;
}
// I've set this number randomly
res = av_seek_frame(pFormatCtx, videoStream, 20.0, AVSEEK_FLAG_FRAME);
if (res<0) {
return;
}
AVPacket packet;
while(1) {
av_read_frame(pFormatCtx, &packet);
if(packet.stream_index==videoStream) {
int frameFinished;
avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
if(frameFinished) {
SaveFrame(pFrameRGB, pCodecCtx->width,
pCodecCtx->height);
break;
}
}
}
avformat_close_input(&pFormatCtx);
return 0;
}
void SaveFrame(AVFrame *pFrame, int width, int height) {
FILE *pFile;
char szFilename[] = "frame.ppm";
int y;
// Open file
pFile=fopen(szFilename, "wb");
if(pFile==NULL)
return;
// Write header
fprintf(pFile, "P6\n%d %d\n255\n", width, height);
// Write pixel data
for(y=0; ydata[0]+y*pFrame->linesize[0], 1, width*3, pFile);
// Close file
fclose(pFile);
}I was following this tutorial http://dranger.com/ffmpeg/tutorial01.html http://dranger.com/ffmpeg/tutorial07.html . It says that it was updated in 2015, but there already are some warnings about deprecated code, for example here :
pFormatCtx->streams[i]->codec
.I got video duration (in microseconds), but I don’t understand what I should send to
av_seek_frame
. Can I somehow use frame number for both duration and seeking, instead of time ? -
How to set comma delimited values from stdout ?
28 octobre 2017, par gregmI have a batch file that processes the output of an ffprobe query. It retrieves several bits of data that I use to determine some ffmpeg directives. In particular I’m converting h264 videos into h265 if the video frame height is 720 or greater. I also convert the audio stream to aac if it isn’t already and if that stream is higher than 128 kbps I convert it down to 128.
I can do all of that by calling ffprobe a number of times and use if statements to decide what my ffmpeg command will be.
I’d like my batch file to be more efficient so I was thinking that if I could take the output of one (maybe two) ffprobe queries and then stick that output into a for /f token=.... loop then I could set each ffprobe data point to a variable and then just check the variables to decide what the resulting ffmpeg command will be.
Here’s what I have right now to simply check if the video stream is hevc. If it isn’t then ffmpeg converts the video to hevc and copies the audio to aac.
for %%a in ("*.*") do (
ffprobe -v quiet -show_entries stream=index,codec_name,height -of csv "%%a" 2>&1 | findstr "hevc"
if errorlevel 1 (
ffmpeg.exe -hwaccel cuvid -i "%%a" -pix_fmt p010le -c:v hevc_nvenc -preset slow -rc vbr_hq -b:v 4M -maxrate:v 10M -c:a aac "%%~na.h265-convert.mp4"
))That ffprobe query output looks like this :
stream,0,h264,480
I was thinking if I could tokenize that output with something like :
for /f "tokens=1,2,3,4 delims= " %%a in ("______") do set codec=%%b&set fheight=%%d
I don’t know what to put in the spot where I have the _______. I really don’t want to create a temp file unless that’s the only option though.
1) Is this an efficient way to achieve what I’m trying to do ?
2) What do I use where I have a blank line above ________ to call the output of the ffprobe query to use in my for loop ?