
Recherche avancée
Autres articles (26)
-
HTML5 audio and video support
13 avril 2011, parMediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
For older browsers the Flowplayer flash fallback is used.
MediaSPIP allows for media playback on major mobile platforms with the above (...) -
De l’upload à la vidéo finale [version standalone]
31 janvier 2010, parLe chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
Upload et récupération d’informations de la vidéo source
Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...) -
Support audio et vidéo HTML5
10 avril 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)
Sur d’autres sites (3012)
-
OpenCV3 returning float FRAME_COUNT
15 mars 2016, par mpratI am using OpenCV3 on OSX with Python 2.7 bindings. However, when I try to read the frame count of my video (a .mp4 video), it returns a float - I am expecting an int. Do I need to compile OpenCV3 with some special flags ? Am I missing some codecs ?
import cv2
vid = cv2.VideoCapture("vid.mp4")
print vid.get(cv2.CAP_PROP_FRAME_WIDTH)And it returns a float.
Installation details :
- ffmpeg :
brew install ffmpeg --with-dcadec --with-openh264 --with-openjpeg --with-openssl --with-tools --with-x265 --with-zimg --with-libvidstab --with-libvpx
- opencv3 :
brew install opencv3 --with-ffmpeg --with-contrib
- ffmpeg :
-
How to Match ASS Subtitle Font Size with Flutter Text Size for a 1080p Video ?
16 décembre 2024, par Mostafa FathiI’m working on a project where I need to synchronize the font size of ASS subtitles with the text size a user sees in a Flutter application. The goal is to ensure that the text size in a 1080p video matches what the user sees in the app.


What I've Tried :


- 

- Calculating font size using height ratio (PlayResY/DeviceHeight) :




- 

- I used the formula :




FontSize_ASS = FontSize_Flutter * (PlayResY / DeviceHeight)



- 

- While the result seemed logical, the final output in the video was smaller than expected.




- 

- Adding a scaling factor :




- 

- I introduced a scaling factor (around 3.0) to address the size discrepancy.
- This improved the result but still felt inconsistent and lacked precision.






- 

- Using force_style in FFmpeg :




- 

- I applied the force_style parameter to control the font size in FFmpeg directly.




ffmpeg -i input.mp4 -vf "subtitles=subtitle.ass:force_style='FontSize=90'" -c:a copy output.mp4



- 

- While it produced better results, it’s not an ideal solution as it bypasses the calculations in the ASS file.




- 

- Aligning
PlayResX
andPlayResY
in the ASS file :
I ensured that these parameters matched the target video resolution (1920×1080) :




PlayResX: 1920
PlayResY: 1080



- 

- Despite this adjustment, the font size didn’t align perfectly with the Flutter app text size.




- 

- Reading font metrics from the font file dynamically :
To improve precision, I wrote a function in Flutter that reads font metrics (units per EM, ascender, and descender) from the TTF font file and calculates a more accurate scaling factor :




Future readFontMetrics(
 String fontFilePath, 
 double originalFontSize,
) async {
 final fontData = await File(fontFilePath).readAsBytes();
 final fontBytes = fontData.buffer.asUint8List();
 final byteData = ByteData.sublistView(fontBytes);

 int numTables = readUInt16BE(byteData, 4);
 int offsetTableStart = 12;
 Map> tables = {};

 for (int i = 0; i < numTables; i++) {
 int recordOffset = offsetTableStart + i * 16;
 String tag =
 utf8.decode(fontBytes.sublist(recordOffset, recordOffset + 4));
 int offset = readUInt32BE(byteData, recordOffset + 8);
 int length = readUInt32BE(byteData, recordOffset + 12);

 tables[tag] = {
 'offset': offset,
 'length': length,
 };
 }

 if (!tables.containsKey('head') || !tables.containsKey('hhea'){
 print('Required tables not found in the font file.');
 return null;
 }

 int headOffset = tables['head']!['offset']!;
 int unitsPerEm = readUInt16BE(byteData, headOffset + 18);

 int hheaOffset = tables['hhea']!['offset']!;
 int ascender = readInt16BE(byteData, hheaOffset + 4);
 int descender = readInt16BE(byteData, hheaOffset + 6);

 print('unitsPerEm: $unitsPerEm');
 print('ascender: $ascender');
 print('descender: $descender');

 int nominalSize = unitsPerEm;
 int realDimensionSize = ascender - descender;
 double scaleFactor = realDimensionSize / nominalSize;
 double realFontSize = originalFontSize * scaleFactor;

 print('Scale Factor: $scaleFactor');
 print('Real Font Size: $realFontSize');

 return realFontSize;
}



- 

- This function dynamically reads the font properties (ascender, descender, and unitsPerEM) and calculates a scale factor to get the real font size. Despite this effort, discrepancies persist when mapping it to the ASS font size.




Question :
How can I ensure that the font size in the ASS file accurately reflects the size the user sees in Flutter ? Is there a reliable method to calculate or align the sizes correctly across both systems ? Any insights or suggestions would be greatly appreciated.


Thank you ! 🙏


-
FFmpeg generated video length doesn't match expected length [on hold]
21 juin 2018, par BentCoderI am using command below to generate video out of images. The problem is the length out the video generated. It is always 5 seconds less than expected. If I have 4 images, I expect to see 20 seconds of video but I am getting 15 seconds instead. The very last image
img-03.jpg
just appears at the end of the video as if it is a cover image. Any idea why and solution ?Command
ffmpeg -y -framerate 1/5 -f image2 \
-i img-%2d.jpg \
-c:v libvpx-vp9 \
-r 25 \
-crf 30 -b:v 0 \
video.webmImages
img-00.jpg
img-01.jpg
img-02.jpg
img-03.jpgOutput
ffmpeg version 3.2.10-1~deb9u1~bpo8+1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --prefix=/usr --extra-version='1~deb9u1~bpo8+1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --disable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Input #0, image2, from 'img-%2d.jpg':
Duration: 00:00:20.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 854x480 [SAR 1:1 DAR 427:240], 0.20 fps, 0.20 tbr, 0.20 tbn, 0.20 tbc
[swscaler @ 0x55f2af60e800] deprecated pixel format used, make sure you did set range correctly
[libvpx-vp9 @ 0x55f2af6276a0] v1.3.0
Output #0, webm, to 'video.webm':
Metadata:
encoder : Lavf57.56.101
Stream #0:0: Video: vp9 (libvpx-vp9), yuv420p, 854x480 [SAR 1:1 DAR 427:240], q=-1--1, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc57.64.101 libvpx-vp9
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> vp9 (libvpx-vp9))
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:854x480 fmt:yuvj444p to size:854x480 fmt:yuvj420p
[swscaler @ 0x55f2af602b60] deprecated pixel format used, make sure you did set range correctly
frame= 4 fps=0.0 q=0.0 Lsize= 214kB time=00:00:15.00 bitrate= 117.0kbits/s speed= 16x
video:214kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.234810%