
Recherche avancée
Autres articles (35)
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
Support de tous types de médias
10 avril 2011Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)
-
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 (4881)
-
A ffmpeg comman canwork in cmd but not in Python using subprocess.call() or os.system()
6 juin 2018, par StarryskyI wanna transfer a .mp3 to .wav. This is my command :
ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav
It worked well in cmd
C:\Users\starrysky\Documents\GitHub\bing_pic\html>ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav
ffmpeg version N-86482-gbc40674 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.1.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
libavutil 55. 66.100 / 55. 66.100
libavcodec 57. 99.100 / 57. 99.100
libavformat 57. 73.100 / 57. 73.100
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 92.100 / 6. 92.100
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Input #0, mp3, from 'a.mp3':
Metadata:
encoder : Lavf54.6.100
Duration: 00:00:01.87, start: 0.000000, bitrate: 8 kb/s
Stream #0:0: Audio: mp3, 8000 Hz, mono, s16p, 8 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to 'a.wav':
Metadata:
ISFT : Lavf57.73.100
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s
Metadata:
encoder : Lavc57.99.100 pcm_s16le
size= 59kB time=00:00:01.87 bitrate= 256.3kbits/s speed= 187x
video:0kB audio:58kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.130208%but when I moved it into my python program, something strange happened.
>>> C:\Users\starrysky\Documents\GitHub\bing_pic\html\
'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
�����������
1 Command 'ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav' returned non-zero exit status 1.
文件错误啊,亲
[WinError 2] 系统找不到指定的文件。: 'a.wav'This is part of my python code :
@bot.register(wife, RECORDING)
def translate_sound(msg):
msg.get_file(save_path='a.mp3')
path = os.path.abspath('.')+'\\'
print(path)
try:
subprocess.check_call('ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav', shell=True)
# ''
except Exception as e:
print(1, e)
wav_to_text('a.wav')
try:
os.remove('a.wav')
except Exception as e:
print(e)# 调用百度语音识别API
def get_token():
URL = 'http://openapi.baidu.com/oauth/2.0/token'
_params = urllib.parse.urlencode({'grant_type': b'client_credentials',
'client_id': b''
'client_secret': b''})
_res = urllib.request.Request(URL, _params.encode())
_response = urllib.request.urlopen(_res)
_data = _response.read()
_data = json.loads(_data)
return _data['access_token']
def wav_to_text(wav_file):
try:
wav_file = open(wav_file, 'rb')
except IOError:
print('文件错误啊,亲')
return
wav_file = wave.open(wav_file)
n_frames = wav_file.getnframes()
print('n_frames ', n_frames)
frame_rate = wav_file.getframerate()
print("frame_rate ", frame_rate)
if n_frames == 1 or frame_rate not in (8000, 16000):
print('不符合格式')
return
audio = wav_file.readframes(n_frames)
seconds = n_frames/frame_rate+1
minute = int(seconds/60 + 1)
for i in range(0, minute):
sub_audio = audio[i*60*frame_rate:(i+1)*60*frame_rate]
base_data = base64.b64encode(sub_audio)
data = {"format": "wav",
"token": get_token(),
"len": len(sub_audio),
"rate": frame_rate,
"speech": base_data.decode(),
"cuid": "B8-AC-6F-2D-7A-94",
"channel": 1}
data = json.dumps(data)
res = urllib.request.Request('http://vop.baidu.com/server_api',
data.encode(),
{'content-type': 'application/json'})
response = urllib.request.urlopen(res)
res_data = json.loads(response.read())
try:
print(res_data['result'][0])
except Exception as e:
print(e)What happened ?
-
React Native Expo File System : open failed : ENOENT (No such file or directory)
9 février 2023, par coloradayI'm getting this error in a bare React Native project :


Possible Unhandled Promise Rejection (id: 123):
Error: /data/user/0/com.filsufius.VisionishAItest/files/image-new-♥d.jpg: open failed: ENOENT (No such file or directory)



The same code was saving to File System with no problem yesterday, but today as you can see I am getting an ENOENT error, plus I am getting these funny heart shapes ♥d in the path. Any pointers as to what might be causing this, please ? I use npx expo run:android to builld app locally and expo start —dev-client to run on a physical Android device connected through USB.


import { Image, View, Text, StyleSheet } from "react-native";
import * as FileSystem from "expo-file-system";
import RNFFmpeg from "react-native-ffmpeg";
import * as tf from "@tensorflow/tfjs";
import * as cocossd from "@tensorflow-models/coco-ssd";
import { decodeJpeg, bundleResourceIO } from "@tensorflow/tfjs-react-native";

const Record = () => {
 const [frames, setFrames] = useState([]);
 const [currentFrame, setCurrentFrame] = useState(0);
 const [model, setModel] = useState(null);
 const [detections, setDetections] = useState([]);

 useEffect(() => {
 const fileName = "image-new-%03d.jpg";
 const outputPath = FileSystem.documentDirectory + fileName;
 RNFFmpeg.execute(
 "-y -i https://res.cloudinary.com/dannykeane/video/upload/sp_full_hd/q_80:qmax_90,ac_none/v1/dk-memoji-dark.m3u8 -vf fps=25 -f mjpeg " +
 outputPath
 )
 .then((result) => {
 console.log("Extraction succeeded:", result);
 FileSystem.readDirectoryAsync(FileSystem.documentDirectory).then(
 (files) => {
 setFrames(
 files
 .filter((file) => file.endsWith(".jpg"))
 .sort((a, b) => {
 const aNum = parseInt(a.split("-")[2].split(".")[0]);
 const bNum = parseInt(b.split("-")[2].split(".")[0]);
 return aNum - bNum;
 })
 );
 }
 );
 })
 .catch((error) => {
 console.error("Extraction failed:", error);
 });
 }, []);

 useEffect(() => {
 tf.ready().then(() => cocossd.load().then((model) => setModel(model)));
 }, []);
 useEffect(() => {
 if (frames.length && model) {
 const intervalId = setInterval(async () => {
 setCurrentFrame((currentFrame) =>
 currentFrame === frames.length - 1 ? 0 : currentFrame + 1
 );
 const path = FileSystem.documentDirectory + frames[currentFrame];
 const imageAssetPath = await FileSystem.readAsStringAsync(path, {
 encoding: FileSystem.EncodingType.Base64,
 });
 const imgBuffer = tf.util.encodeString(imageAssetPath, "base64").buffer;
 const imageData = new Uint8Array(imgBuffer);
 const imageTensor = decodeJpeg(imageData, 3);
 console.log("after decodeJpeg.");
 const detections = await model.detect(imageTensor);
 console.log(detections);
 setDetections(detections);
 }, 100);
 return () => clearInterval(intervalId);
 }
 }, [frames, model]);

 
 return (
 <view style="{styles.container}">
 
 <view style="{styles.predictions}">
 {detections.map((p, i) => (
 <text key="{i}" style="{styles.text}">
 {p.class}: {(p.score * 100).toFixed(2)}%
 </text>
 ))}
 </view>
 </view>
 );
};

const styles = StyleSheet.create({
 container: {
 flex: 1,
 alignItems: "center",
 justifyContent: "center",
 },
 image: {
 width: 300,
 height: 300,
 resizeMode: "contain",
 },
 predictions: {
 width: 300,
 height: 100,
 marginTop: 20,
 },
 text: {
 fontSize: 14,
 textAlign: "center",
 },
});

export default Record;```



-
How can I sync the frames of multiple videos from a multi-camera capture system using FFMPEG
9 février 2023, par user9114146I have a multi-camera capture setup with 2 canon cameras. Each of these cameras have a tentacle sync e timecode generator connected to them.


After a video capture with these 2 cameras, the generated timecode (SMPTE format) is stored in the video files metadata.


It looks like this
00:00:53;30


Is there a bash script that uses FFmpeg to trim the start time of the video that started earlier (based on timecode) to match the other and then trim the end time of the video that ended last to match the one that ended first ?


The two trimmed output videos should be synced based on the timecode and have the same duration.


So far, my bash script looks like this :


file1="A001C002_220101EB_CANON.MXF"
file2="A001C002_220101US_CANON.MXF"

# Get the SMPTE timecodes of the two files
timecode1=$(ffmpeg -i "$file1" 2>&1 | sed -n 's/timecode.*: \(.*\)/\1/p')
timecode2=$(ffmpeg -i "$file2" 2>&1 | sed -n 's/timecode.*: \(.*\)/\1/p')

# Convert the SMPTE timecode to start time in seconds
start_time_1=$(echo "$timecode1" | awk -F ':' '{print 3600*$1 + 60*$2 + $3}')
start_time_2=$(echo "$timecode2" | awk -F ':' '{print 3600*$1 + 60*$2 + $3}')

# Trim the start of the video with the earlier start timecode so that both videos have the same start time
if [ "$start_time_1" -lt "$start_time_2" ]; then
 ffmpeg -i "$file1" -ss "$start_time_2" -c:v libx264 -crf 18 -preset veryfast trimmed_file1.mp4
 ffmpeg -i "$file2" -c:v libx264 -crf 18 -preset veryfast trimmed_file2.mp4
else
 ffmpeg -i "$file2" -ss "$start_time_1" -c:v libx264 -crf 18 -preset veryfast trimmed_file2.mp4
 ffmpeg -i "$file1" -c:v libx264 -crf 18 -preset veryfast trimmed_file1.mp4
fi

# Get the duration of both files
duration_1=$(ffmpeg -i trimmed_file1.mp4 2>&1 | grep "Duration" | cut -d ' ' -f 4 | sed s/,//)
duration_2=$(ffmpeg -i trimmed_file2.mp4 2>&1 | grep "Duration" | cut -d ' ' -f 4 | sed s/,//)

# Convert the duration to seconds
duration_1_secs=$(echo $duration_1 | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }')
duration_2_secs=$(echo $duration_2 | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }')

# Trim the end time of the video that ended last to match the one that ended first
if [ "$duration_1_secs" -gt "$duration_2_secs" ]; then
 echo "Trimming end time of file1 to match file2"
 ffmpeg -i trimmed_file1.mp4 -t "$duration_2" -c:v libx264 -c:a aac trimmed_file1.mp4
else
 echo "Trimming end time of file2 to match file1"
 ffmpeg -i trimmed_file2.mp4 -t "$duration_1" -c:v libx264 -c:a aac trimmed_file2.mp4
fi



But this does not make the videos have matching frames.


Thanks !