
A mis contenedores mkv generados (que contienen video h265) les falta la duración del video. ¿Hay alguna manera de configurar esto antes de que se cierre la entrada canalizada?
Input #0, matroska,webm, from 'camera01-20190815-203646.mkv':
Metadata:
ENCODER : Lavf58.20.100
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: hevc (Main), yuv420p(tv), 2048x1536, 1 fps, 1 tbr, 1k tbn, 1 tbc (default)
Actualmente los archivos se crean usando los siguientes comandos. (gracias agyanpor ayudar con esto):
ffmpeg \
-hide_banner \
-loglevel error \
-nostdin \
-nostats \
-xerror \
-stimeout 5000000 \
-thread_queue_size 2048 \
-reorder_queue_size 16000 \
-rtsp_transport tcp \
-i rtsp://xxx \
-c:v copy -an -sn -dn \
-bsf:v hevc_metadata=tick_rate=1 \
-f hevc - \
| \
ffmpeg \
-hide_banner \
-loglevel info \
-nostats \
-nostdin \
-xerror \
-f hevc \
-i - \
-c copy \
-f segment \
-segment_time 3600 \
-segment_format matroska \
-segment_format_options live=1:reserve_index_space=100k \
-strftime 1 \
"/srv/video/netcams/archive/recordall/camera01-%%Y%%m%%d-%%H%%M%%S.mkv"
¿Existe una forma sencilla de especificar la longitud del archivo durante la escritura mkv o hacer que ffmpeg lo inserte antes de cerrar el segmento del archivo?
Respuesta1
Así que nos acercamos un poco más a una solución ahora:
ffmpeg -f hevc -i - -c copy -f segment -segment_time 30 -segment_format matroska -strftime 1 camera01-%Y%m%d-%H%M%S.mkv
(se eliminó la opción reserve_index_space).
proporciona datos de duración al archivo. Sin embargo, esto no se restablece al comienzo de cada segmento; en cambio, la duración de cada segmento incluye la duración de los segmentos anteriores.
find . -exec ffmpeg -hide_banner -i {} -f ffmetadata \; > /tmp/out.txt
Input #0, matroska,webm, from './camera01-20190819-212041.mkv':
Metadata:
ENCODER : Lavf58.20.100
Duration: 00:00:32.00, start: 0.000000, bitrate: 694 kb/s
Stream #0:0: Video: hevc (Main), yuv420p(tv), 2048x1536, 1 fps, 1 tbr, 1k tbn, 1 tbc (default)
Metadata:
DURATION : 00:00:32.000000000
Input #0, matroska,webm, from './camera01-20190819-212102.mkv':
Metadata:
ENCODER : Lavf58.20.100
Duration: 00:01:00.00, start: 32.000000, bitrate: 401 kb/s
Stream #0:0: Video: hevc (Main), yuv420p(tv), 2048x1536, 1 fps, 1 tbr, 1k tbn, 1 tbc (default)
Metadata:
DURATION : 00:01:00.000000000
Input #0, matroska,webm, from './camera01-20190819-212130.mkv':
Metadata:
ENCODER : Lavf58.20.100
Duration: 00:01:32.00, start: 60.000000, bitrate: 287 kb/s
Stream #0:0: Video: hevc (Main), yuv420p(tv), 2048x1536, 1 fps, 1 tbr, 1k tbn, 1 tbc (default)
Metadata:
DURATION : 00:01:32.000000000
Me pregunto si existe un equivalente al indicador "restablecer datos de tiempo para cada archivo"... o equivalente.
Sí hay. El comando final se ve así:
ffmpeg \
-hide_banner \
-loglevel info \
-nostats \
-nostdin \
-xerror \
-f hevc \
-i - \
-c copy \
-f segment \
-reset_timestamps 1 \
-segment_time 30 \
-segment_format matroska \
-strftime 1 \
"/srv/video/netcams/archive/recordall/camera01-%%Y%%m%%d-%%H%%M%%S.mkv"
(Sigo viendo [segment @ 0x5652b57e1500] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
advertencias falsas que nunca supe cómo eliminar, pero al menos los servicios que buscan una duración válida ahora las ven.