
Recherche avancée
Autres articles (59)
-
Problèmes fréquents
10 mars 2010, parPHP et safe_mode activé
Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site -
Mediabox : ouvrir les images dans l’espace maximal pour l’utilisateur
8 février 2011, parLa visualisation des images est restreinte par la largeur accordée par le design du site (dépendant du thème utilisé). Elles sont donc visibles sous un format réduit. Afin de profiter de l’ensemble de la place disponible sur l’écran de l’utilisateur, il est possible d’ajouter une fonctionnalité d’affichage de l’image dans une boite multimedia apparaissant au dessus du reste du contenu.
Pour ce faire il est nécessaire d’installer le plugin "Mediabox".
Configuration de la boite multimédia
Dès (...) -
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 (7013)
-
Python and ffmpeg audio sync and screen recording issues
9 août 2020, par odddollarI'm using ffmpeg and python to record my desktop screen. When the program is run, it starts recording, then when I press a key-combo it cuts off the last x amount of seconds and saves it then starts recording again ; similar to the "record that" functionality of windows game bar.


I have it working so it records video just fine, but then I change the ffmpeg command to record audio from my desktop and I get an error saying
ValueError: could not convert string to float: 'N/A'
occurring when I try to calculate the length of the recorded video. It appears as though the recording isn't being stopped until after I try to calculate the video length, even though this exact same code works fine when not recording audio.

Additionally, I also have an issue when recording audio in that the audio is a couple hundred milliseconds in front of the video. It's not a lot but it's enough to be noticeable.


What I'm overall asking, is there a way I can modify the ffmpeg command to prevent the audio desync issues, and what might be causing the problems I'm getting when attempting to find the length of the video with audio ?


import keyboard, signal
from os import remove
from os.path import isfile
from subprocess import Popen, getoutput
from datetime import datetime
import configparser

class Main:
 def __init__(self, save_location, framerate, duration):
 self.save_location = save_location
 self.framerate = int(framerate)
 self.duration = int(duration)
 self.working = self.save_location + '\\' + 'working.avi'
 self.start_recording()

 def start_recording(self):
 if isfile(self.working):
 remove(self.working)

 # start recording to working file at set framerate
 self.process = Popen(f'ffmpeg -thread_queue_size 578 -f gdigrab -video_size 1920x1080 -i desktop -f dshow -i audio="Stereo Mix (Realtek High Definition Audio)" -b:v 7M -minrate 4M -framerate {self.framerate} {self.working}')
 #self.process = Popen(f'ffmpeg -f gdigrab -framerate {self.framerate} -video_size 1920x1080 -i desktop -b:v 7M -minrate 2M {self.working}')

 def trim_video(self):
 # stop recording working file
 self.process.send_signal(signal.CTRL_C_EVENT)

 # call 'cause I have to
 getoutput(f"ffprobe -i {self.working}")

 # get length of working video
 length = getoutput(f'ffprobe -i {self.working} -show_entries format=duration -v quiet -of csv="p=0"')

 # get time before desired recording time
 start = float(length) - self.duration

 # get save location and title
 title = self.save_location+'\\'+self.get_time()+'.avi'

 # cut to last amount of desired time
 Popen(f"ffmpeg -ss {start} -i {self.working} -c copy -t {self.duration} {title}")
 getoutput(f"ffprobe -i {self.working}")

 self.start_recording()

 def get_time(self):
 now = datetime.now()
 return now.strftime("%Y_%m_%d#%H-%M-%S")


if __name__ == "__main__":
 config = configparser.ConfigParser()
 config.read("settings.ini")
 config = config["DEFAULT"]

 run = Main(config["savelocation"].replace("\\", "\\\\"), config["framerate"], config["recordlast"])
 keyboard.add_hotkey("ctrl+shift+alt+g", lambda:run.trim_video())

 while True:
 try:
 keyboard.wait()
 except KeyboardInterrupt:
 pass



The contents of the settings.ini file are listed below


[DEFAULT]
savelocation = C:\
framerate = 30
recordlast = 10



In the code block, the first line with
self.process = Popen
is the one that records audio and has the issues, the second line (the commented out one below) is the one that works fine.

-
avutil/channel_layout : add 22.2 layout
11 juin 2020, par Jan Ekströmavutil/channel_layout : add 22.2 layout
Requires some extraneous top side and bottom front channels to be
defined.According to STD-B59v2, the defined channel layout is :
FL
FR
FC
LFE1
BL
BR
FLc
FRc
BC
LFE2
SiL
SiR
TpFL
TpFR
TpFC
TpC
TpBL
TpBR
TpSiL
TpSiR
TpBC
BtFC
BtFL
BtFR
-
Ffmpeg inaccurate cutting with ts and m3u8 files despite resamping audio filter
31 juillet 2020, par Lemon SkyI need to accurately seek and cut a video. Some online sources say put -ss in front or after the source. The result is the same for me. In the examples below, the start time is accurate but the duration is not accurate.


ffmpeg -y -ss 00:00:05 -t 00:00:05 -i output.ts 5s.wav
ffprobe 5s.wav

Duration: 00:00:04.74

ffmpeg -y -i output.ts -ss 00:00:05 -t 00:00:05 5s.wav
ffprobe 5s.wav

Duration: 00:00:04.74



Sometimes the starting point is not accurate but the duration is. This is clearly audible by cutting the ts file and cutting an uncompressed wav file, and listening to both.


ffmpeg -y -i output.ts -ss 00:00:15 -t 00:00:05 5s.wav

ffmpeg -y -i output.wav -ss 00:00:15 -t 00:00:05 5s-reference.wav



What fixes the starting time is if I use an m3u8 file that contains the byte offset for every keyframe AND I put the -ss option in front of the source file (if I put it after the source, the start time is inaccurate but the duration is accurate) :


ffmpeg -y -ss 00:00:15 -t 00:00:05 -i output.m3u8 5s.wav



This fixes the start time but the duration is at the location that I would get had I used no m3u8 file (duration is just 4.47s).


It seems different timestamps are involved, and sometimes one or the other gets used.


The ts file was generated by capturing a UDP stream and storing it with ffmpeg and -codec:v copy.


Is ffmpeg broken, or the ts file ? How do I work around this issue or fix the ts file ? What I realize is that the video starts later than the audio, probably because the video does not start with a keyframe. Can I get ffmpeg to start the -codec:v copy after the first keyframe ? What I also notice is that using ffprobe reports "start : 1.400000". Can I force it to start at 0 ?


Any hints would be appreciated.


I tried both ffmpeg 4.3.1 and ffmpeg git-2020-07-24-21442a8.


The output.* files were generated as follows. The statement "af aresample=async=1" should fill missing audio according to Duration of source video and subtracted audio are different. Adding this statement makes no difference in terms of accuracy or duration. The question is not a duplicate.


ffmpeg -i udp://example:port ^
-af aresample=async=1 ^
-codec:v copy ^
-codec:a aac -ac 2 -ar 44100 -b:a 160k ^
-hls_time 4 -hls_flags single_file -hls_list_size 0 -hls_segment_filename output.ts -hls_segment_type mpegts output.m3u8 ^
-codec:a pcm_s16le -bitexact -ar 11025 -ac 1 output.wav