
Recherche avancée
Autres articles (55)
-
À propos des documents
21 juin 2013, parQue faire quand un document ne passe pas en traitement, dont le rendu ne correspond pas aux attentes ?
Document bloqué en file d’attente ?
Voici une liste d’actions ordonnée et empirique possible pour tenter de débloquer la situation : Relancer le traitement du document qui ne passe pas Retenter l’insertion du document sur le site MédiaSPIP Dans le cas d’un média de type video ou audio, retravailler le média produit à l’aide d’un éditeur ou un transcodeur. Convertir le document dans un format (...) -
Emballe Médias : Mettre en ligne simplement des documents
29 octobre 2010, parLe plugin emballe médias a été développé principalement pour la distribution mediaSPIP mais est également utilisé dans d’autres projets proches comme géodiversité par exemple. Plugins nécessaires et compatibles
Pour fonctionner ce plugin nécessite que d’autres plugins soient installés : CFG Saisies SPIP Bonux Diogène swfupload jqueryui
D’autres plugins peuvent être utilisés en complément afin d’améliorer ses capacités : Ancres douces Légendes photo_infos spipmotion (...) -
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)
Sur d’autres sites (6339)
-
You can generate a video with audio and videos clip with ffmpeg
8 mai 2018, par Jhonny LuisI am making an application in which I have to generate a single video clip of x duration, I was recommended to use the ffmpeg but I do not know if it could be created and if possible how the structure would be, since I understand that you need a file with a structure in which the path is established in this case videos and audio, I am working on codeigniter with php 7, I have already executed the ffmpeg to change the format of a video.
The question is the following, from a database I bring the list of the route of the videos its duration and weight, equal with the audios, the thing is how I can do to create the video with ffmpeg from this.
-
FFMPEG frames lost
4 juin 2018, par ST94I use ffmpeg to stream video from the source to destination. The workflow is as follows,
At the source using ffmpeg, I stream live feed from a webcam using tcp and also save a copy of the live video as mp4 file locally and the command I use is$ ffmpeg -hide_banner -f v4l2 -i /dev/video0 -filter:v "fps=30" -c:v libx264 -f mpegts tcp://hostname:port -c:v libx264 /path/to/.mp4file
`Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 272402.639303, bitrate: 147456 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480, 147456 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Stream #0:0 -> #1:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
No pixel format specified, yuv422p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x55e421ec9560] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x55e421ec9560] profile High 4:2:2, level 3.0, 4:2:2 8-bit
Output #0, mpegts, to 'tcp://172.16.0.169:50000':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: h264 (libx264), yuv422p, 640x480, q=-1--1, 30 fps, 90k tbn, 30 tbc
Metadata:
encoder : Lavc57.89.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
No pixel format specified, yuv422p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x55e421ed5ea0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x55e421ed5ea0] profile High 4:2:2, level 3.0, 4:2:2 8-bit
[libx264 @ 0x55e421ed5ea0] 264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #1, mp4, to '/path/to/tcp.mp4':
Metadata:
encoder : Lavf57.71.100
Stream #1:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv422p, 640x480, q=-1--1, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc57.89.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[sana@localhost ~]$ frame= 978 fps= 30 q=-1.0 Lq=-1.0 size= 5062kB time=00:00:32.53 bitrate=1274.6kbits/s dup=514 drop=0 speed=0.991x
video:9174kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x55e421ec9560] frame I:463 Avg QP:19.03 size: 9994
[libx264 @ 0x55e421ec9560] frame P:476 Avg QP:22.85 size: 137
[libx264 @ 0x55e421ec9560] frame B:39 Avg QP:23.33 size: 19
[libx264 @ 0x55e421ec9560] consecutive B-frames: 94.7% 0.0% 0.0% 5.3%
[libx264 @ 0x55e421ec9560] mb I I16..4: 60.4% 39.0% 0.5%
[libx264 @ 0x55e421ec9560] mb P I16..4: 0.2% 0.0% 0.0% P16..4: 4.2% 0.3% 0.5% 0.0% 0.0% skip:94.8%
[libx264 @ 0x55e421ec9560] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0% L0:15.4% L1:84.6% BI: 0.0%
[libx264 @ 0x55e421ec9560] 8x8 transform intra:38.9% inter:100.0%
[libx264 @ 0x55e421ec9560] coded y,uvDC,uvAC intra: 34.9% 97.2% 83.8% inter: 0.0% 1.5% 0.0%
[libx264 @ 0x55e421ec9560] i16 v,h,dc,p: 0% 31% 0% 69%
[libx264 @ 0x55e421ec9560] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 3% 50% 16% 4% 2% 1% 6% 1% 17%
[libx264 @ 0x55e421ec9560] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 52% 14% 4% 7% 3% 5% 1% 3%
[libx264 @ 0x55e421ec9560] i8c dc,h,v,p: 55% 12% 25% 8%
[libx264 @ 0x55e421ec9560] Weighted P-Frames: Y:0.2% UV:0.0%
[libx264 @ 0x55e421ec9560] ref P L0: 96.7% 0.5% 2.7% 0.1%
[libx264 @ 0x55e421ec9560] kb/s:1151.61
[libx264 @ 0x55e421ed5ea0] frame I:463 Avg QP:19.02 size: 10007
[libx264 @ 0x55e421ed5ea0] frame P:477 Avg QP:22.84 size: 140
[libx264 @ 0x55e421ed5ea0] frame B:39 Avg QP:23.33 size: 19
[libx264 @ 0x55e421ed5ea0] consecutive B-frames: 94.7% 0.0% 0.0% 5.3%
[libx264 @ 0x55e421ed5ea0] mb I I16..4: 60.4% 39.0% 0.5%
[libx264 @ 0x55e421ed5ea0] mb P I16..4: 0.3% 0.0% 0.0% P16..4: 4.2% 0.3% 0.5% 0.0% 0.0% skip:94.8%
[libx264 @ 0x55e421ed5ea0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0% L0:15.4% L1:84.6% BI: 0.0%
[libx264 @ 0x55e421ed5ea0] 8x8 transform intra:38.9% inter:100.0%
[libx264 @ 0x55e421ed5ea0] coded y,uvDC,uvAC intra: 35.0% 97.2% 84.0% inter: 0.0% 1.6% 0.0%
[libx264 @ 0x55e421ed5ea0] i16 v,h,dc,p: 0% 31% 0% 69%
[libx264 @ 0x55e421ed5ea0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 3% 50% 16% 4% 2% 1% 6% 1% 17%
[libx264 @ 0x55e421ed5ea0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 52% 14% 4% 7% 3% 5% 1% 3%
[libx264 @ 0x55e421ed5ea0] i8c dc,h,v,p: 55% 12% 25% 8%
[libx264 @ 0x55e421ed5ea0] Weighted P-Frames: Y:0.2% UV:0.0%
[libx264 @ 0x55e421ed5ea0] ref P L0: 96.8% 0.5% 2.7% 0.1%
[libx264 @ 0x55e421ed5ea0] kb/s:1152.39`At the receiver, I take the tcp url as the input and output it to an mp4 file.
$ffmpeg -hide_banner -i tcp://hostname:port?listen out.mp4 /path/to/.mp4
The output is
`Input #0, mpegts, from 'tcp://172.16.0.169:50000?listen':
Duration: N/A, start: 1.466667, bitrate: N/A
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High 4:2:2) ([27][0][0][0] / 0x001B), yuv422p(progressive), 640x480, 30 fps, 30 tbr, 90k tbn, 60 tbc
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
No pixel format specified, yuv422p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x55c1d6bff0a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x55c1d6bff0a0] profile High 4:2:2, level 3.0, 4:2:2 8-bit
[libx264 @ 0x55c1d6bff0a0] 264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/home/sana/Desktop/receiver_new_mp4/tcp2.mp4':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv422p, 640x480, q=-1--1, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc57.89.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 160 fps=0.0 q=26.0 size= 158kB time=00:00:03.36 bitrate= 384.5kbits/frame= 175 fps=168 q=26.0 size= 200kB time=00:00:03.86 bitrate= 424.8kbits/frame= 190 fps=119 q=26.0 size= 242kB time=00:00:04.36 bitrate= 453.3kbits/frame= 206 fps= 97 q=29.0 size= 292kB time=00:00:04.90 bitrate= 487.8kbits/frame= 222 fps= 84 q=29.0 size= 336kB time=00:00:05.43 bitrate= 506.5kbits/frame= 238 fps= 75 q=29.0 size= 378kB time=00:00:05.96 bitrate= 519.2kbits/frame= 254 fps= 68 q=29.0 size= 422kB time=00:00:06.50 bitrate= 531.6kbits/frame= 270 fps= 64 q=26.0 size= 457kB time=00:00:07.03 bitrate= 532.0kbits/frame= 286 fps= 60 q=29.0 size= 511kB time=00:00:07.56 bitrate= 552.8kbits/frame= 302 fps= 57 q=26.0 size= 562kB time=00:00:08.10 bitrate= 568.3kbits/frame= 318 fps= 54 q=26.0 size= 609kB time=00:00:08.63 bitrate= 577.9kbits/frame= 334 fps= 52 q=26.0 size= 674kB time=00:00:09.16 bitrate= 602.7kbits/frame= 350 fps= 51 q=29.0 size= 719kB time=00:00:09.70 bitrate= 606.8kbits/frame= 366 fps= 49 q=26.0 size= 770kB time=00:00:10.23 bitrate= 616.1kbits/frame= 382 fps= 48 q=29.0 size= 828kB time=00:00:10.76 bitrate= 630.3kbits/frame= 398 fps= 47 q=26.0 size= 872kB time=00:00:11.30 bitrate= 632.0kbits/frame= 414 fps= 46 q=26.0 size= 933kB time=00:00:11.83 bitrate= 645.9kbits/frame= 430 fps= 45 q=29.0 size= 987kB time=00:00:12.36 bitrate= 653.9kbits/frame= 446 fps= 44 q=26.0 size= 1033kB time=00:00:12.90 bitrate= 656.2kbits/frame= 462 fps= 43 q=29.0 size= 1098kB time=00:00:13.43 bitrate= 669.7kbits/frame= 478 fps= 43 q=29.0 size= 1132kB time=00:00:13.96 bitrate= 664.2kbits/frame= 548 fps= 47 q=-1.0 Lsize= 1536kB time=00:00:18.16 bitrate= 692.8kbits/s speed=1.56x
video:1531kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.377405%
[libx264 @ 0x55c1d6bff0a0] frame I:115 Avg QP:18.12 size: 8204
[libx264 @ 0x55c1d6bff0a0] frame P:203 Avg QP:21.62 size: 1893
[libx264 @ 0x55c1d6bff0a0] frame B:230 Avg QP:21.99 size: 1039
[libx264 @ 0x55c1d6bff0a0] consecutive B-frames: 41.1% 6.6% 7.1% 45.3%
[libx264 @ 0x55c1d6bff0a0] mb I I16..4: 67.6% 32.3% 0.1%
[libx264 @ 0x55c1d6bff0a0] mb P I16..4: 15.3% 3.1% 0.0% P16..4: 28.6% 2.8% 2.0% 0.0% 0.0% skip:48.3%
[libx264 @ 0x55c1d6bff0a0] mb B I16..4: 0.8% 0.3% 0.0% B16..8: 26.2% 0.4% 0.0% direct:13.5% skip:58.7% L0:65.0% L1:34.5% BI: 0.5%
[libx264 @ 0x55c1d6bff0a0] 8x8 transform intra:28.4% inter:100.0%
[libx264 @ 0x55c1d6bff0a0] coded y,uvDC,uvAC intra: 15.0% 89.4% 53.1% inter: 2.6% 28.7% 0.2%
[libx264 @ 0x55c1d6bff0a0] i16 v,h,dc,p: 2% 49% 1% 47%
[libx264 @ 0x55c1d6bff0a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 6% 57% 19% 2% 1% 1% 4% 1% 9%
[libx264 @ 0x55c1d6bff0a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 59% 18% 1% 2% 1% 2% 0% 1%
[libx264 @ 0x55c1d6bff0a0] i8c dc,h,v,p: 52% 17% 27% 4%
[libx264 @ 0x55c1d6bff0a0] Weighted P-Frames: Y:17.7% UV:6.9%
[libx264 @ 0x55c1d6bff0a0] ref P L0: 68.7% 0.7% 18.3% 10.6% 1.7%
[libx264 @ 0x55c1d6bff0a0] ref B L0: 86.1% 10.6% 3.3%
[libx264 @ 0x55c1d6bff0a0] ref B L1: 96.6% 3.4%
[libx264 @ 0x55c1d6bff0a0] kb/s:686.10`From the ffmpeg processes running on both ends, if you notice the number of B frames at the receiver is more than the B frames at the sender. In other cases that I tried, the number of I as well as P frames are higher at the receiver than that at the sender.
Can anyone please tell me why is it so ? I am not able to figure out why. -
FFmpeg encoding produces slightly incompatible MKV/MP4 container
11 juin 2018, par james2048I’ve been using the FFmpeg libraries to read and write media files using the C API.
So far, reading seems to be pretty straightforward. I am able to read frames which I can then process, convert to RGB, process, and then convert back to YUV420 to be encoded.
The encoded files play back with VLC media player fine, and Windows Media Player if I have a codec pack installed. However, they do behave strangely : the stock Windows 10 player won’t play them, same for Adobe Premiere. Also thumbnailers don’t work on it.
Basically it seems like nothing other than VLC or FFmpeg itself can play/process the file. I have seen this with both MP4 and MKV, so it is not a format-specific issue.The problems go away once you remux the file with FFmpeg, for example "ffmpeg -i input.mkv -c copy output.mkv". Everything can play the file correctly.
Also, the "remuxing.c" sample from the official samples works as well, with the same library version and compilers that I’m using (Visual Studio 2017, FFmpeg compiled with MinGW). It will fix the file and make it playable in all software.I’m not sure what could be causing this. I also don’t understand what the remuxing "fixed". It must be a container issue as the frames aren’t touched by remuxing.
I have analysed the output MKVs with FFprobe -show_packets. It seems to have budged the packet timestamps a little constant factor, and the output stream now has
is_avc=true and nal_length_size=4 instead of is_avc=false and nal_length_size=0, but apart from that the files are identical.Now here’s the output of FFprobe with the 3 last test packets, stream info and format info for both streams. As you can see, they are identical except for a couple of field. But something in here must have been "fixed" during remuxing to make it work.
[PACKET]
codec_type=video
stream_index=0
pts=59050
pts_time=59.050000
dts=58890
dts_time=58.890000
duration=1
duration_time=0.001000
convergence_duration=N/A
convergence_duration_time=N/A
size=427
pos=277358
flags=__
[/PACKET]
[PACKET]
codec_type=video
stream_index=0
pts=58970
pts_time=58.970000
dts=58970
dts_time=58.970000
duration=1
duration_time=0.001000
convergence_duration=N/A
convergence_duration_time=N/A
size=205
pos=277792
flags=__
[/PACKET]
[PACKET]
codec_type=video
stream_index=0
pts=59130
pts_time=59.130000
dts=59050
dts_time=59.050000
duration=1
duration_time=0.001000
convergence_duration=N/A
convergence_duration_time=N/A
size=268
pos=278004
flags=__
[/PACKET]
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=Main
codec_type=video
codec_time_base=1/2000
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=720
height=576
coded_width=720
coded_height=576
has_b_frames=2
sample_aspect_ratio=N/A
display_aspect_ratio=N/A
pix_fmt=yuv420p
level=50
color_range=unknown
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=progressive
timecode=N/A
refs=1
is_avc=false
nal_length_size=0
id=N/A
r_frame_rate=299/12
avg_frame_rate=1000/1
time_base=1/1000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=737
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
TAG:DURATION=00:00:59.211000000
[/STREAM]
[FORMAT]
filename=testEncLeft.mkv
nb_streams=1
nb_programs=0
format_name=matroska,webm
format_long_name=Matroska / WebM
start_time=0.000000
duration=59.211000
size=278349
bit_rate=37607
probe_score=100
TAG:COMMENT=Slickline Player Export
TAG:ENCODER=Lavf57.83.100
[/FORMAT]And the info after remuxing, which works :
[PACKET]
codec_type=video
stream_index=0
pts=59050
pts_time=59.050000
dts=58890
dts_time=58.890000
duration=1
duration_time=0.001000
convergence_duration=N/A
convergence_duration_time=N/A
size=427
pos=277418
flags=__
[/PACKET]
[PACKET]
codec_type=video
stream_index=0
pts=58970
pts_time=58.970000
dts=58970
dts_time=58.970000
duration=1
duration_time=0.001000
convergence_duration=N/A
convergence_duration_time=N/A
size=205
pos=277852
flags=__
[/PACKET]
[PACKET]
codec_type=video
stream_index=0
pts=59130
pts_time=59.130000
dts=59050
dts_time=59.050000
duration=1
duration_time=0.001000
convergence_duration=N/A
convergence_duration_time=N/A
size=268
pos=278064
flags=__
[/PACKET]
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=Main
codec_type=video
codec_time_base=1/2000
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=720
height=576
coded_width=720
coded_height=576
has_b_frames=2
sample_aspect_ratio=N/A
display_aspect_ratio=N/A
pix_fmt=yuv420p
level=50
color_range=unknown
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=progressive
timecode=N/A
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=299/12
avg_frame_rate=1000/1
time_base=1/1000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=737
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
TAG:DURATION=00:00:59.212000000
[/STREAM]
[FORMAT]
filename=fixedLeft.mkv
nb_streams=1
nb_programs=0
format_name=matroska,webm
format_long_name=Matroska / WebM
start_time=0.000000
duration=59.212000
size=278409
bit_rate=37615
probe_score=100
TAG:COMMENT=Slickline Player Export
TAG:ENCODER=Lavf58.12.100
[/FORMAT]Here is how I’m setting up the output context, for reference : it’s pretty standard, following the sample code.
int ret;
avformat_alloc_output_context2(&outputFormatCtx, nullptr, nullptr, outFilePath.c_str());
av_dict_set(&outputFormatCtx->metadata, "comment", "FFmpeg Export", 0);
if (!outputFormatCtx)
{
LOG_AND_THROW("Could not allocate output context");
}
outputVideoStream = avformat_new_stream(outputFormatCtx, nullptr);
outputVideoStream->time_base = AVRational{ 1, AV_TIME_BASE }; // Stream timebase will be used by codec
if (!outputVideoStream)
{
LOG_AND_THROW("Failed allocating output stream");
}
// defaults to "libx264"
AVCodec *outCodec = avcodec_find_encoder_by_name(selectedCodecName.c_str());
if (!outCodec)
{
LOG_AND_THROW("Failed finding output codec");
}
AVDictionary *opts = nullptr;
if (selectedCodecName == "libx264")
{
opts = getX264CodecOptions();
}
encoderCtx = avcodec_alloc_context3(outCodec);
if (!encoderCtx)
{
LOG_AND_THROW("Failed to allocate the encoder context");
}
encoderCtx->width = width;
encoderCtx->height = height;
encoderCtx->pix_fmt = AV_PIX_FMT_YUV420P;
// time base for the frames we will provide to the encoder
encoderCtx->time_base = AVRational{ 1, AV_TIME_BASE };
// convert framerate from double to rational
encoderCtx->framerate = AVRational{ (int)(frameRate * AV_TIME_BASE), AV_TIME_BASE};
// Match encoderCtx time base for the stream
outputVideoStream->time_base = encoderCtx->time_base;
ret = avcodec_open2(encoderCtx, outCodec, &opts);
if (ret < 0)
{
LOG_AND_THROW_PARAM("Cannot open video encoder for stream: %d", ret);
}
// Fill in some params for MP4 stream, details about encoder
ret = avcodec_parameters_from_context(outputVideoStream->codecpar, encoderCtx);
if (ret < 0)
{
LOG_AND_THROW_PARAM("Failed to copy encoder parameters to output stream: %d", ret);
}
if (outputFormatCtx->oformat->flags & AVFMT_GLOBALHEADER)
{
encoderCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
}
av_dump_format(outputFormatCtx, 0, filePath.c_str(), 1);
// End of encoder settings, setting up MP4
if (!(outputFormatCtx->oformat->flags & AVFMT_NOFILE))
{
ret = avio_open(&outputFormatCtx->pb, outFilePath.c_str(), AVIO_FLAG_WRITE);
if (ret < 0)
{
LOG_AND_THROW_PARAMSTR("Could not open output file '%s'", outFilePath.c_str());
}
}
ret = avformat_write_header(outputFormatCtx, nullptr);
if (ret < 0)
{
LOG_AND_THROW_PARAM("Error occurred when opening output file for writing: %d", ret);
}Can anyone help me figure out why the container is not playing properly ?
Thanks in advance.
-James