Add nopts-v1: Ignore packets with unset PTS on streamcopy

This commit is contained in:
Ingo Oppermann
2023-05-16 12:09:20 +02:00
parent 3a60e27502
commit cc1385543d
6 changed files with 107 additions and 67 deletions

View File

@@ -68,6 +68,7 @@ RUN mkdir -p /dist && cd /dist && \
COPY ./contrib /contrib COPY ./contrib /contrib
RUN cd /dist/ffmpeg-${FFMPEG_VERSION} && \ RUN cd /dist/ffmpeg-${FFMPEG_VERSION} && \
patch -p1 < /contrib/ffmpeg-nopts.patch && \
patch -p1 < /contrib/ffmpeg-jsonstats.patch && \ patch -p1 < /contrib/ffmpeg-jsonstats.patch && \
patch -p1 < /contrib/ffmpeg-hlsbitrate.patch && \ patch -p1 < /contrib/ffmpeg-hlsbitrate.patch && \
./configure \ ./configure \

View File

@@ -76,6 +76,7 @@ RUN echo $uname
RUN cd /dist/ffmpeg-${FFMPEG_VERSION} && \ RUN cd /dist/ffmpeg-${FFMPEG_VERSION} && \
apkArch="$(apk --print-arch)" && if [ $apkArch != "aarch64" ]; then MMAL_SUPPORT="--enable-mmal"; fi && \ apkArch="$(apk --print-arch)" && if [ $apkArch != "aarch64" ]; then MMAL_SUPPORT="--enable-mmal"; fi && \
apkArch="$(apk --print-arch)" && if [ $apkArch != "aarch64" ]; then OMX_SUPPORT="--enable-omx --enable-omx-rpi"; fi && \ apkArch="$(apk --print-arch)" && if [ $apkArch != "aarch64" ]; then OMX_SUPPORT="--enable-omx --enable-omx-rpi"; fi && \
patch -p1 < /contrib/ffmpeg-nopts.patch && \
patch -p1 < /contrib/ffmpeg-jsonstats.patch && \ patch -p1 < /contrib/ffmpeg-jsonstats.patch && \
patch -p1 < /contrib/ffmpeg-hlsbitrate.patch && \ patch -p1 < /contrib/ffmpeg-hlsbitrate.patch && \
./configure \ ./configure \

View File

@@ -182,6 +182,7 @@ RUN mkdir -p /dist && cd /dist && \
COPY ./contrib /contrib COPY ./contrib /contrib
RUN cd /dist/ffmpeg-${FFMPEG_VERSION} && \ RUN cd /dist/ffmpeg-${FFMPEG_VERSION} && \
patch -p1 < /contrib/ffmpeg-nopts.patch && \
patch -p1 < /contrib/ffmpeg-jsonstats.patch && \ patch -p1 < /contrib/ffmpeg-jsonstats.patch && \
patch -p1 < /contrib/ffmpeg-hlsbitrate.patch && \ patch -p1 < /contrib/ffmpeg-hlsbitrate.patch && \
./configure \ ./configure \

View File

@@ -180,6 +180,7 @@ RUN mkdir -p /dist && cd /dist && \
COPY ./contrib /contrib COPY ./contrib /contrib
RUN cd /dist/ffmpeg-${FFMPEG_VERSION} && \ RUN cd /dist/ffmpeg-${FFMPEG_VERSION} && \
patch -p1 < /contrib/ffmpeg-nopts.patch && \
patch -p1 < /contrib/ffmpeg-jsonstats.patch && \ patch -p1 < /contrib/ffmpeg-jsonstats.patch && \
patch -p1 < /contrib/ffmpeg-hlsbitrate.patch && \ patch -p1 < /contrib/ffmpeg-hlsbitrate.patch && \
./configure \ ./configure \

View File

@@ -1,12 +1,17 @@
# Patches # Patches
FFmpeg patches. FFmpeg patches.
## No PTS
Ignore packets during streamcopy that don't have a valid PTS value.
## HLS bitrate ## HLS bitrate
Calculate bandwidth estimate for the hls master manifest. Calculate bandwidth estimate for the hls master manifest.
## JSON stats ## JSON stats
This repository contains a patch for the FFmpeg program to provide detailed progress information. With this patch, FFmpeg will output This repository contains a patch for the FFmpeg program to provide detailed progress information. With this patch, FFmpeg will output
the progress information in a JSON string that contains the data for each input and output stream individually. The JSON output is enabled the progress information in a JSON string that contains the data for each input and output stream individually. The JSON output is enabled
by default. It can be enabled with the global `-jsonstats` switch on the command line. Use the `-stats` switch by default. It can be enabled with the global `-jsonstats` switch on the command line. Use the `-stats` switch
@@ -28,71 +33,71 @@ The same output but nicely formatted:
```json ```json
{ {
"bitrate_kbps": 1367.7, "bitrate_kbps": 1367.7,
"drop": 0, "drop": 0,
"dup": 0, "dup": 0,
"fps": 24.95, "fps": 24.95,
"frame": 188, "frame": 188,
"inputs": [ "inputs": [
{ {
"bitrate_kbps": 552960.0, "bitrate_kbps": 552960.0,
"codec": "rawvideo", "codec": "rawvideo",
"coder": "rawvideo", "coder": "rawvideo",
"fps": 24.95, "fps": 24.95,
"frame": 188, "frame": 188,
"height": 720, "height": 720,
"id": 0, "id": 0,
"pix_fmt": "rgb24", "pix_fmt": "rgb24",
"size_kb": 507600, "size_kb": 507600,
"stream": 0, "stream": 0,
"type": "video", "type": "video",
"width": 1280 "width": 1280
}, },
{ {
"bitrate_kbps": 705.6, "bitrate_kbps": 705.6,
"codec": "pcm_u8", "codec": "pcm_u8",
"coder": "pcm_u8", "coder": "pcm_u8",
"frame": 314, "frame": 314,
"id": 1, "id": 1,
"layout": "stereo", "layout": "stereo",
"sampling_hz": 44100, "sampling_hz": 44100,
"size_kb": 628, "size_kb": 628,
"stream": 0, "stream": 0,
"type": "audio" "type": "audio"
} }
], ],
"outputs": [ "outputs": [
{ {
"bitrate_kbps": 1365.6, "bitrate_kbps": 1365.6,
"codec": "h264", "codec": "h264",
"coder": "libx264", "coder": "libx264",
"fps": 24.95, "fps": 24.95,
"frame": 188, "frame": 188,
"height": 720, "height": 720,
"id": 0, "id": 0,
"pix_fmt": "yuv420p", "pix_fmt": "yuv420p",
"q": -1.0, "q": -1.0,
"size_kb": 1247, "size_kb": 1247,
"stream": 0, "stream": 0,
"type": "video", "type": "video",
"width": 1280 "width": 1280
}, },
{ {
"bitrate_kbps": 2.1, "bitrate_kbps": 2.1,
"codec": "aac", "codec": "aac",
"coder": "aac", "coder": "aac",
"frame": 315, "frame": 315,
"id": 0, "id": 0,
"layout": "stereo", "layout": "stereo",
"sampling_hz": 44100, "sampling_hz": 44100,
"size_kb": 2, "size_kb": 2,
"stream": 1, "stream": 1,
"type": "audio" "type": "audio"
} }
], ],
"q": -1.0, "q": -1.0,
"size_kb": 1249, "size_kb": 1249,
"speed": 0.993, "speed": 0.993,
"time": "0h0m7.48s" "time": "0h0m7.48s"
} }
``` ```

View File

@@ -0,0 +1,31 @@
From 357b3d157b08ca5c7b91f605136bf140a4453fe7 Mon Sep 17 00:00:00 2001
From: Ingo Oppermann <ingo@datarhei.com>
Date: Tue, 16 May 2023 11:19:17 +0200
Subject: [PATCH v1] Ignore packets with unset PTS on streamcopy
---
fftools/ffmpeg.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index e7384f05..3385482b 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1858,8 +1858,11 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
if (av_packet_ref(opkt, pkt) < 0)
exit_program(1);
- if (pkt->pts != AV_NOPTS_VALUE)
+ if (pkt->pts != AV_NOPTS_VALUE) {
opkt->pts = av_rescale_q(pkt->pts, ist->st->time_base, ost->mux_timebase) - ost_tb_start_time;
+ } else {
+ return;
+ }
if (pkt->dts == AV_NOPTS_VALUE) {
opkt->dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ost->mux_timebase);
base-commit: 2bca71f4986725d7cf0d441e2f82a790d0a0c717
--
2.39.2 (Apple Git-143)