Recherche avancée
Médias (16)
-
#1 The Wires
11 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
1,000,000
27 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
The Four of Us are Dying
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Corona Radiata
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Lights in the Sky
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Head Down
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Sur d’autres sites (333)
-
webm video - it can not be copy to cut a correct time part for ffmpeg command(without re-encode) [closed]
15 mars, par DanielHsuCommand Goal :


- 

- fast copy video's part
- no re-encode with libvpx






Linux command below :
ffmpeg -ss 00:01:00 -to 00:02:00 -i input.webm -c copy output.webm


command's process details :


ffmpeg version 6.1.1 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration:
--enable-libvpx libavutil 58. 29.100 / 58. 29.100 libavcodec 60. 31.102 / 60. 31.102 libavformat 60. 16.100 / 60. 16.100 libavdevice 60. 3.100 / 60. 3.100 libavfilter 9. 12.100 / 
9. 12.100 libswscale 7. 5.100 / 7. 5.100 libswresample 4. 12.100 / 4. 12.100 Input #0, matroska,webm, from 'input.webm': Metadata:
 title : FFmpeg
 ENCODER : Lavf58.29.100 Duration: 00:06:04.43, start: 0.000000, bitrate: 2487 kb/s Stream #0:0: Video: vp8, yuv420p(tv, bt470bg/unknown/unknown, progressive), 1280x720, SAR 1:1 DAR 16:9, 1k tbr, 1k tbn (default)
 Metadata:
 DURATION : 00:06:04.432000000 Output #0, webm, to 'output.webm': Metadata:
 title : FFmpeg
 encoder : Lavf60.16.100 Stream #0:0: Video: vp8, yuv420p(tv, bt470bg/unknown/unknown, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 1k tbr, 1k tbn (default)
 Metadata:
 DURATION : 00:06:04.432000000 Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help [out#0/webm @ 0x5609ee9bb840] video:35912kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.069370% size= 35937kB time=00:00:59.96 bitrate=4909.2kbits/s speed= 211x



command usage's result :
output.webm always start from input.webm's 00:00:00 to end input.webm's 00:01:00
(it should be start from input.webm's 00:01:00 to end input.webm's 00:02:00 )


input.webm format details from mediainfo tool :




General Count : 331 Count of stream
of this kind : 1 Kind of stream

 : General Kind of stream : General Stream
identifier : 0 Count of video streams

 : 1 Video_Format_List : VP8
Video_Format_WithHint_List : VP8 Codecs Video

 : VP8 Complete name :
pure_film/65ea641a4075c92236151349_video.webm Folder name

 : pure_film File name extension :
65ea641a4075c92236151349_video.webm File name

 : 65ea641a4075c92236151349_video File extension

 : webm Format : WebM Format

 : WebM Format/Url :
http://www.webmproject.org/ Format/Extensions usually used :
webm Commercial name : WebM Format version

 : Version 2 Internet media type : video/webm File
size : 113301943 File size

 : 108 MiB File size : 108 MiB File size
 : 108 MiB File size : 108 MiB File size
 : 108.1 MiB Duration : 364432 Duration
 : 6 min 4 s Duration : 6 min 4 s 432
ms Duration : 6 min 4 s Duration

 : 00:06:04.432 Duration : 00:06:04.432
Overall bit rate : 2487201 Overall bit rate

 : 2 487 kb/s Stream size : 4801069 Stream
size : 4.58 MiB (4%) Stream size

 : 5 MiB Stream size : 4.6 MiB Stream size
 : 4.58 MiB Stream size : 4.579 MiB Stream
size : 4.58 MiB (4%) Proportion of this
stream : 0.04237 IsStreamable

 : Yes Title : FFmpeg Movie name

 : FFmpeg File last modification date : UTC 2024-03-08
01:41:47 File last modification date (local) : 2024-03-08
09:41:47 Writing application : Lavf58.29.100
Writing application : Lavf58.29.100 Writing
library : Lavf58.29.100 Writing library

 : Lavf58.29.100

Video Count : 377 Count of stream
of this kind : 1 Kind of stream

 : Video Kind of stream : Video Stream
identifier : 0 StreamOrder

 : 0 ID : 1 ID

 : 1 Unique ID : 1 Format

 : VP8 Format : VP8 Format/Url

 : http://www.webmproject.org/ Commercial name

 : VP8 Codec ID : V_VP8 Codec ID/Url

 : http://www.webmproject.org/ Duration

 : 364432.000000 Duration : 6 min 4 s
Duration : 6 min 4 s 432 ms Duration

 : 6 min 4 s Duration : 00:06:04.432
Duration : 00:06:04.432 Bit rate

 : 2381808 Bit rate : 2 382 kb/s Width
 : 1280 Width : 1 280 pixels Height
 : 720 Height : 720 pixels Pixel
aspect ratio : 1.000 Display aspect ratio

 : 1.778 Display aspect ratio : 16:9 Frame rate
mode : VFR Frame rate mode

 : Variable Color space : YUV Compression
mode : Lossy Compression mode

 : Lossy Delay : 0 Delay

 : 00:00:00.000 Delay, origin : Container
Delay, origin : Container Stream size

 : 108500874 Stream size : 103 MiB (96%)
Stream size : 103 MiB Stream size

 : 103 MiB Stream size : 103 MiB Stream
size : 103.5 MiB Stream size

 : 103 MiB (96%) Proportion of this stream : 0.95763
Default : Yes Default

 : Yes Forced : No Forced

 : No colour_description_present : Yes
colour_description_present_Source : Container Color range

 : Limited colour_range_Source : Container Matrix
coefficients : BT.470 System B/G
matrix_coefficients_Source : Container



How to make the output.webm be in correct time range(00:01:00 00:02:00) ????


-
FFMPEG C Library : Encoding h264 stream into Matroska .mkv container creates corrupt files
16 mars, par Marvin KillingI want to use the FFMPEG C Library to create a Matroska Video .mkv file with only an h264 stream, but the resulting .mkv file comes out corrupt.


The file cannot be played back with Windows Media Player, ffplay, or VLC, and when I try to
ffprobe
the resulting file, these are the error messages :

[h264 @ 0000015060d8f5c0] No start code is found.
 Last message repeated 1 times
[h264 @ 0000015060d8f5c0] non-existing PPS 0 referenced
 Last message repeated 1 times
[h264 @ 0000015060d8f5c0] decode_slice_header error
[h264 @ 0000015060d8f5c0] no frame!
[h264 @ 0000015060d8f5c0] non-existing PPS 0 referenced
 Last message repeated 1 times
[h264 @ 0000015060d8f5c0] decode_slice_header error
[h264 @ 0000015060d8f5c0] no frame!
[h264 @ 0000015060d8f5c0] non-existing PPS 0 referenced
 Last message repeated 1 times
# [...]
# this continues for a long time



I have followed the other troubleshooting steps for encoding h264 into Matroska, but none of them seemed to have done the trick for me :


- 

- Setting
AV_CODEC_FLAG_GLOBAL_HEADER
: Invalid data when creating mkv container with h264 stream because extradata is null - Allocating some space for extradata : Initializing an output file for muxing mkv with FFmpeg






This is my C code :


#include 
#include <libavutil></libavutil>opt.h>
#include <libavutil></libavutil>imgutils.h>
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>

int main(void) {
 char *out_file_path = "./video.mkv";
 AVFormatContext *format_context;
 AVStream *video_stream;
 AVCodecContext *codec_context;

 avformat_alloc_output_context2(&format_context, NULL, NULL, out_file_path);

 const AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_H264);
 video_stream = avformat_new_stream(format_context, NULL);

 codec_context = avcodec_alloc_context3(codec);
 av_opt_set(codec_context->priv_data, "preset", "superfast", 0);
 av_opt_set(codec_context->priv_data, "crf", "22", 0);

 codec_context->width = 1920;
 codec_context->height = 1080;
 codec_context->time_base = av_make_q(1, 30);
 codec_context->pix_fmt = AV_PIX_FMT_YUV420P;

 if (strncmp("./video.mkv", out_file_path, 11) == 0) {
 printf("Writing .mkv...\n");
 codec_context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
 codec_context->extradata = (uint8_t*)av_mallocz(1024 * 1024);
 codec_context->extradata_size = 1024 * 1024;
 } else {
 printf("Writing .mp4...\n");
 }

 // XXX avcodec_parameters_from_context is potentially superfluous (?)
 int ret = avcodec_parameters_from_context(video_stream->codecpar, codec_context);

 ret = avcodec_open2(codec_context, codec, NULL);

 avio_open(&format_context->pb, out_file_path, AVIO_FLAG_WRITE);

 ret = avformat_write_header(format_context, NULL);

 // create a black input frame
 AVFrame *input_frame = av_frame_alloc();
 input_frame->width = 1920;
 input_frame->height = 1080;
 input_frame->format = AV_PIX_FMT_YUV420P;
 ret = av_image_alloc(input_frame->data, input_frame->linesize, input_frame->width, input_frame->height, input_frame->format, 32);
 ptrdiff_t linesize[4] = { input_frame->linesize[0], input_frame->linesize[1], input_frame->linesize[2], input_frame->linesize[3] };
 ret = av_image_fill_black(input_frame->data, linesize, input_frame->format, 0, 1920, 1080);

 // write 2 seconds of video, all black
 for (size_t current_pts = 0; current_pts < 60; current_pts++) {
 input_frame->pts = av_rescale_q(current_pts, av_make_q(1, 30), codec_context->time_base);;

 ret = avcodec_send_frame(codec_context, input_frame);

 AVPacket* packet = av_packet_alloc();

 while (1) {
 ret = avcodec_receive_packet(codec_context, packet);
 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
 break;
 } else if (ret < 0) {
 printf("avcodec_receive_packet failed");
 } else {
 av_packet_rescale_ts(packet, codec_context->time_base, video_stream->time_base);
 ret = av_interleaved_write_frame(format_context, packet);
 }
 }

 av_packet_free(&packet);
 }

 av_frame_free(&input_frame);

 // flush encoder
 avcodec_send_frame(codec_context, NULL);
 AVPacket *flush_packet = av_packet_alloc();
 while (avcodec_receive_packet(codec_context, flush_packet) != AVERROR_EOF) {
 //int ret = av_interleaved_write_frame(format_context_, packet);
 av_packet_rescale_ts(flush_packet, codec_context->time_base, video_stream->time_base);
 ret = av_write_frame(format_context, flush_packet);
 }
 av_packet_free(&flush_packet);

 ret = av_write_trailer(format_context);
 ret = avio_close(format_context->pb);

 return 0;
}



The error handling is stripped out, but it does not raise any errors.


This code works when I write into an mp4 file, but creates a corrupt file when writing into .mkv. You can change the output container format to mp4 by setting

char *out_file_path = "./video.mp4";


You can compile this by running


clang -I$(FFMPEG_DIR)/include -L$(FFMPEG_DIR)/lib -lavformat -lavcodec -lavutil main.c -o makemkv



The output I’m getting while the above code is running :


Writing .mkv...
[libx264 @ 0x139804c40] using cpu capabilities: ARMv8 NEON
[libx264 @ 0x139804c40] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x139804c40] 264 - core 164 r3108 31e19f9 - H.264/MPEG-4 AVC codec - Copyleft 2003-2023 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x3 me=dia subme=1 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=15 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=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=crf mbtree=0 crf=22.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 pb_ratio=1.30 aq=1:1.00



When I use the ffmpeg CLI, I can create a working .mkv from my working .mp4 like this :


ffmpeg -i video.mp4 -c:v copy created-with-ffmpeg-cli.mkv



I have uploaded the resulting video files here : https://drive.google.com/drive/folders/1FS-0fBAwKBbO-tyxC0VrFqcCyyqd0BR_?usp=sharing


- Setting
-
FFMPEG : FATAL error, file duration too long for timebase ?
26 février, par clxI want to add a subtitle track on a ProRes files with ffmpeg command on Windows :


ffmpeg.exe -i "X:\Test\Tokyo01.mov" -i "X:\Test\SubtitleEN.srt" -f mov -c:v copy -c:a copy -c:s mov_text -map 0:v -map 0:a -map "1:0" "-metadata:s:s:0" "language=EN" "-metadata:s:s:0" "handler_name=English" "-metadata:s:s:0" "title=English" -y "X:\Test\Tokyo01_WithSub.mov" 



I have a fatal error at the end :


...
FATAL error, file duration too long for timebase, this file will not be1737.7kbits/s speed=0.979x
playable with QuickTime. Choose a different timebase with -video_track_timescale or a different container format
...



Source file looks good with FFProbe :



[STREAM]
index=0
codec_name=prores
codec_long_name=Apple ProRes (iCodec Pro)
profile=HQ
codec_type=video
codec_time_base=15139/363340
codec_tag_string=apch
codec_tag=0x68637061
width=3996
height=2160
coded_width=3996
coded_height=2160
closed_captions=0
has_b_frames=0
sample_aspect_ratio=N/A
display_aspect_ratio=N/A
pix_fmt=yuv422p10le
level=-99
color_range=tv
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=unspecified
field_order=unknown
timecode=N/A
refs=1
id=N/A
r_frame_rate=24/1
avg_frame_rate=363340/15139
time_base=1/90000
start_pts=0
start_time=0.000000
duration_ts=340627500
duration=3784.750000
bit_rate=656235296
max_bit_rate=N/A
bits_per_raw_sample=10
nb_frames=90835



The complete FFmpeg return console :


ffmpeg version 2023-09-04-git-f8503b4c33-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
 built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
 configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
 libavutil 58. 19.100 / 58. 19.100
 libavcodec 60. 25.100 / 60. 25.100
 libavformat 60. 11.100 / 60. 11.100
 libavdevice 60. 2.101 / 60. 2.101
 libavfilter 9. 11.100 / 9. 11.100
 libswscale 7. 3.100 / 7. 3.100
 libswresample 4. 11.100 / 4. 11.100
 libpostproc 57. 2.100 / 57. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'X:\Test\Tokyo01.mov':
 Metadata:
 major_brand : qt
 minor_version : 512
 compatible_brands: qt
 encoder : Lavf58.76.100
 Duration: 01:03:04.79, start: 0.000000, bitrate: 663143 kb/s
 Stream #0:0[0x1]: Video: prores (HQ) (apch / 0x68637061), yuv422p10le, 3996x2160, 656235 kb/s, 24 fps, 24 tbr, 90k tbn (default)
 Metadata:
 handler_name : VideoHandler
 vendor_id : FFMP
 Stream #0:1[0x2]: Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 5.1, s32 (24 bit), 6912 kb/s (default)
 Metadata:
 handler_name : SoundHandler
 vendor_id : [0][0][0][0]
[srt @ 000001bc0ec608c0] UTF16 is automatically converted to UTF8, do not specify a character encoding
Input #1, srt, from 'X:\Test\SubtitleEN.srt':
 Duration: N/A, bitrate: N/A
 Stream #1:0: Subtitle: subrip
Output #0, mov, to 'X:\Test\Tokyo01_WithSub.mov':
 Metadata:
 major_brand : qt
 minor_version : 512
 compatible_brands: qt
 encoder : Lavf60.11.100
 Stream #0:0: Video: prores (HQ) (apch / 0x68637061), yuv422p10le, 3996x2160, q=2-31, 656235 kb/s, 24 fps, 24 tbr, 90k tbn (default)
 Metadata:
 handler_name : VideoHandler
 vendor_id : FFMP
 Stream #0:1: Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 5.1, s32 (24 bit), 6912 kb/s (default)
 Metadata:
 handler_name : SoundHandler
 vendor_id : [0][0][0][0]
 Stream #0:2(EN): Subtitle: mov_text (text / 0x74786574)
 Metadata:
 handler_name : English
 title : English
 encoder : Lavc60.25.100 mov_text
Stream mapping:
 Stream #0:0 -> #0:0 (copy)
 Stream #0:1 -> #0:1 (copy)
 Stream #1:0 -> #0:2 (subrip (srt) -> mov_text (native))
Press [q] to stop, [?] for help
FATAL error, file duration too long for timebase, this file will not be1737.7kbits/s speed=0.979x
playable with QuickTime. Choose a different timebase with -video_track_timescale or a different container format
[out#0/mov @ 000001bc0e847340] video:303184287kB audio:3193418kB subtitle:9kB other streams:0kB global headers:0kB muxing overhead: 0.000585%
frame=90834 fps= 23 q=-1.0 Lsize=306379507kB time=01:03:04.77 bitrate=663147.3kbits/s speed=0.979x




I don't find documentation for mentionned command "-video_track_timescale" to change timescale (here 1/90000 ).
I don't understand the problem ??