
Recherche avancée
Autres articles (83)
-
Organiser par catégorie
17 mai 2013, parDans 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 (...) -
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...) -
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)
Sur d’autres sites (9507)
-
FFMPEG C++ API audio/video sync, video is longer [closed]
11 mai 2023, par Gábor GomborI create a video from frames in C++ with a given FPS and supply it to FFMPEG API. I record from an Unreal engine viewport and feed FFMPEG with the images. In this interval I have also an audio track in FLAC which I want sync with the video. When the music ends, I close the video and merge them, but the final video has sync problems, the video is a little bit longer than the audio, so I will have an increasing delay. For example I record 0:55 secs, the audio is ok=same length, but the video from frames will be 0:56 secs.


I think the following code is problematic :


bool MyVideoExporter::writeFrame(OutputStream* oStream, AVFrame* frame, int& framePTS)
{
 auto* packet = oStream->pkt->pkt;
 auto* codecContext = oStream->enc->codecContext;

 frame->pts = framePTS;
 frame->pkt_dts = frame->pts;

 auto ret = avcodec_send_frame(codecContext, frame);
 if (ret >= 0) {
 auto retVal = 0;
 while (retVal >= 0) {
 retVal = avcodec_receive_packet(codecContext, packet);
 if (retVal == AVERROR(EAGAIN) || retVal == AVERROR_EOF) break;
 else if (retVal < 0) {
 return false;
 }

 // rescale to audio, usually 1/44100
 av_packet_rescale_ts(packet, m_audiotimestamp, oStream->st->time_base);
 // rescale to FPS, usually 1/30 or 1/60
 av_packet_rescale_ts(packet, codecContext->time_base, oStream->st->time_base);

 packet->stream_index = oStream->st->index;

 retVal = av_interleaved_write_frame(m_avFormatContext.avFormatContext, packet);
 if (retVal < 0) {
 return false;
 }

 framePTS++;
 }

 return retVal == AVERROR_EOF;
 }

 return false;
}




Any idea what is wrong ?


I tried change the order of av_packet_rescale_ts lines or move the frame increase code to another places, but getting far worse results.


-
Last subprocess call not working in concatenation code with FFMPEG. How should I go about fixing this ?
28 novembre 2019, par S1mpleclips = []
#generates a list of mp4 files in a folder
def clipFinder(CurrentDir, fileType):
clips.clear()
for r,d,f in os.walk(CurrentDir):
for file in f:
if fileType in file:
clips.append(r+file)
random.shuffle(clips)
#removes all files that have the string 'vod' in them as they cause problems during concatenation
def removeVods(r):
for f in clips:
if 'vod' in clips:
os.remove(r+f)
#generates a string using the clips list to insert into the ffmpeg command
def clipString():
string = 'intermediate'
clipList = []
clipNum = 1
for f in clips:
clipList.append(string+str(clipNum)+'.ts'+'|')
clipNum+=1
string1 = ''.join(clipList)
string2 = string1[0:len(string1)-1]
return string2
#concatenates the mp4 files in the clipString
def concatFiles():
clipFinder('***', '.mp4')
removeVods('***')
i = 0
intermediates = []
for f in clips:
subprocess.call(['***', '-i', clips[i], '-c', 'copy', '-bsf:v', 'h264_mp4toannexb', '-f', 'mpegts', 'intermediate'+ str(i+1) +'.ts'])
i += 1
clipsLength = len(clips)
subprocess.call['***', '-i', '"concat:' + clipString() + '"', '-c', 'copy', '-bsf:a
aac_adtstoasc', 'output.mp4']I am trying to make a clip concatenator, but the last subprocess call won’t run and gives me no error. When I run the script the first FFmpeg call works fine and gives me my intermediate mp4 files, however, the second command, which works when I run it in terminal, does not work when I run it from python using subprocess.call.
Problematic code :
subprocess.call(['***', '-i', '"concat:' + clipString() + '"', '-c', 'copy', '-bsf:a aac_adtstoasc', 'output.mp4'])
all places with * were paths such as : /davidscomputer/bin/ffmpeg/
-
Python gets stuck at pipe.stdin.write(image.tostring())
10 mars 2020, par Vandana RajanI am reading each frame of video and adding time stamp to it as given below.
command = ['ffmpeg',
'-y', # (optional) overwrite output file if it exists
'-f', 'rawvideo', #Input is raw video
'-pix_fmt', 'bgr24', #Raw video format
'-s', str(int(width)) + 'x' + str(int(height)), # size of one frame
'-i', '-', # The input comes from a pipe
'-an', # Tells FFMPEG not to expect any audio
'-vcodec', 'mpeg4',
'-b:v', '10M', #Sets a maximum bit rate
Output_name]
#Open the pipe
pipe = sp.Popen(command, stdin=sp.PIPE, stderr=sp.PIPE)
print('Processing....')
print(' ')
#Reads through each frame, calculates the timestamp, places it on the frame and exports the frame to the output video.
#import pdb
#pdb.set_trace()
while current_frame < total_frames:
success, image = video.read()
if success:
elapsed_time = video.get(cv2.CAP_PROP_POS_MSEC)
current_frame = video.get(cv2.CAP_PROP_POS_FRAMES)
timestamp = initial + dt.timedelta(microseconds = elapsed_time*1000)
cv2.putText(image, 'Date: ' + str(timestamp)[0:10], (50,int(height-150)), cv2.FONT_HERSHEY_COMPLEX_SMALL, 2, (255, 255, 255), 3)
cv2.putText(image, 'Time: ' + str(timestamp)[11:-4], (50,int(height-100)), cv2.FONT_HERSHEY_COMPLEX_SMALL, 2, (255, 255, 255), 3)
pipe.stdin.write(image.tostring())
print('frame number',current_frame)
else:
print('video reader fail')
video.release()
pipe.stdin.close()
pipe.stderr.close()However, after around 18k frames, Python gets stuck at ’pipe.stdin.write(image.tostring())’. It does not produce any error, but simply hangs. How to resolve this issue ?
Thanks in advance.