
Recherche avancée
Médias (1)
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
Autres articles (62)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
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 (10258)
-
Create a mkv file with colored background and containing a given audio and subtitle stream
25 mai 2023, par rdrg109Table of contents


- 

- The context
- Minimal working example
- What I've tried

- 

- Create a mkv file with colored background and an audio stream
- Create a mkv file with colored background, an audio stream and a subtitles stream






- The question












The context


I have a
*.flac
file and a*.srt
file. I want to merge those files in a MKV file, but at the same time, I want to add a video stream. I want the video stream to show a green background the entire time.



Minimal working example


For our experimentation, let's create two sample files : one
*.flac
file and one*.srt
file.

The following command creates a
*.flac
file that lasts 60 seconds and contains a sine wave.

$ ffmpeg -y -f lavfi -i "sine=f=1000:d=60" input.flac



The following command creates a
*.srt
file. Note that our last subtitle lasts until the sixth second, this is intended.

$ cat << EOF > input.srt
1
00:00:00,000 --> 00:00:03,000
This is the first subtitle in a
SRT file.

2
00:00:03,000 --> 00:00:06,000
This is the second subtitle in a
SRT file.
EOF





What I've tried




Create a mkv file with colored background and an audio stream


I know how to create a MKV file containing a given audio stream and a colored background as the video stream.


The following command creates a MKV file containing
input.flac
as the audio stream and green background as the video stream. The MKV file have the same duration asinput.flac
.

$ ffmpeg \
 -y \
 -f lavfi \
 -i color=c=green:s=2x2 \
 -i input.flac \
 -c:v libx264 \
 -c:a copy \
 -shortest \
 output.mkv



The following command shows the duration of the streams in the resulting file.


$ ffprobe -v error -print_format json -show_entries stream=codec_type:stream_tags=duration output.mkv | jq -r ''



{
 "programs": [],
 "streams": [
 {
 "codec_type": "video",
 "tags": {
 "DURATION": "00:00:58.200000000"
 }
 },
 {
 "codec_type": "audio",
 "tags": {
 "DURATION": "00:01:00.000000000"
 }
 }
 ]
}





Create a mkv file with colored background, an audio stream and a subtitles stream


To add a subtitles stream, I just need to specify the
*.srt
file. However, when I do this, the duration of the video is set to the time of the last subtitle in the*.srt
file. This is expected because I have used-shortest
. I would get the result I'm looking for if it were possible to specify the stream that-shortest
gives top priority to. I haven't found this information on the Internet.

$ ffmpeg \
 -y \
 -f lavfi \
 -i color=c=green:s=2x2 \
 -i input.flac \
 -i input.srt \
 -c:v libx264 \
 -c:a copy \
 -shortest \
 output.mkv



The following command shows the duration of the streams in the resulting file. Note that the maximum duration of the resulting file is 6 seconds, while in the resulting file from the previous section it was 1 minute.


$ ffprobe -v error -print_format json -show_entries stream=codec_type:stream_tags=duration output.mkv | jq -r ''



{
 "programs": [],
 "streams": [
 {
 "codec_type": "video",
 "tags": {
 "DURATION": "00:00:01.160000000"
 }
 },
 {
 "codec_type": "audio",
 "tags": {
 "DURATION": "00:00:03.134000000"
 }
 },
 {
 "codec_type": "subtitle",
 "tags": {
 "DURATION": "00:00:06.000000000"
 }
 }
 ]
}





The question


Given a
*.flac
file and a*.srt
file. How to merge them in a*.mkv
file so that it has the*.flac
file as the audio stream, the*.srt
file as the subtitles stream and a green background as the video stream ?

-
sws_scale() does not convert image simply copying it from source to target
14 mars 2020, par SlavTrying to read arbitrary video as plain RGB24 pixels so convert frame with
sws_scale()
this way ://...
AVFrame* pic_out = av_frame_alloc();
pic_out->format = AV_PIX_FMT_RGB24;
pic_out->width = 1920;
pic_out->height = 1080;
av_frame_get_buffer( pic_out, 32 );
struct SwsContext * img_convert_ctx = sws_getContext(
1920, 1080, AV_PIX_FMT_YUV420P,
1920, 1080, AV_PIX_FMT_RGB24,
SWS_BICUBIC,
NULL, NULL, NULL
);
//...
sws_scale(
img_convert_ctx,
pic_src->data, //pic_src is from avcodec_receive_frame()
pic_src->linesize,
0,
1080,
pic_out->data,
pic_out->linesize
);Everything goes without any errors, but
pic_out
ends up having the same data aspic_src
.
What could be the problem ?Full minimal example is here (supposed to be RGB24 image is there as 2.bmp which looks like actually being YUV-something)
-
subprocess.run output is empty (python 3.8)
26 juillet 2022, par Marino LinajeI'm trying to capture the output of a command with the following code :


lines = subprocess.run(['ffmpeg', '-hide_banner', '-nostats', '-i', in_filename, '-vn', '-af', 'silencedetect=n={}:d={}'.format(silence_threshold, silence_duration), '-f', 'null', '-'], capture_output=True, text=True, shell=True, check=True, encoding='utf-8').stdout 
print (lines)



But lines is an empty string and nothing is printed.
When
capture_output=True
is removed, the correct output is showed (without printing it).

I tested many combinations, including removing all the
subprocess.run
parameters and only includecapture_output=True
with the same result.

I also tested with few argument for a minimal example :
subprocess.run(['ffmpeg', '-version'], capture_output=True, text=True, shell=True, check=True, encoding='utf-8').stdout


Also tested
stdout=subprocess.PIPE
andstderr=subprocess.PIPE
assubprocess.run
arguments instead ofcapture_output=True


I can't figure out what is happening. Thanks in advance !