On Fri, Jan 5, 2024 at 3:59 AM Andrew Randrianasulu
<[email protected]> wrote:
>
>
>
> пт, 5 янв. 2024 г., 02:59 Andrew Randrianasulu <[email protected]>:
>>
>>
>>
>> пт, 5 янв. 2024 г., 02:53 Phyllis Smith <[email protected]>:
>>>
>>> Bummer, although this does fix the 1 problem as discovered by Terje, it 
>>> breaks Bluray and DVD creation.  You can easily see this without having a 
>>> bluray writer simply with these steps:
>>> 1) load video with audio which in my case was 1440x1080 (from a sony camera)
>>> 2) pulldown Settings/Format and switch to HDV 1080/25
>>> 3) pulldown File and select bd_render
>>>
>>> Error is:  FFMPEG::encode_activate: write header failed 
>>> /tmp/bd_20240104-164102/bd.m2ts
>>>   err: Invalid argument
>
>
> To be honest it errs out for me even without my patch?
>
> FFMPEG::encode_activate: write header failed 
> /data/data/com.termux/files/home/tmp/bd_20240105-035457/bd.m2ts
>   err: Math result not representable
>
> for 1440*1080 hdv sample without setting format first (it sets itself on 
> media autoload) and using default bd render params (1440*1080, 25i)
>
>


ah, it was due to using system (unpatched) ffmpeg!

Try this series instead, it guards setting stream sample aspect ratio
only to muxers supporting it
(I grep in libavformat for sample_sapect)

I tested avi, qt, y4m, matroska


>>>
>>> In DVD creation, it does create the DVD without erring out, but the DVD 
>>> will not even load on an LG DVD/Bluray device hooked up to the TV.  It 
>>> plays on the Samsung UHD but hangs on 1 part towards the end.
>>
>>
>>
>> So, I guess it should not be applied for at least m2ts and mpeg2 containers 
>> ..... I'll try to limit it only to mov/mp4/mkv/webm .
>>>
>>>
>>> The patch probably has other unknown ramifications that I have not found.  
>>> Neither HV or CV have an existing "ffmpeg.C" file in the cinelerra 
>>> subdirectory for comparison.
>>>
>>>
>>> On Sat, Dec 30, 2023 at 10:31 AM Andrew Randrianasulu 
>>> <[email protected]> wrote:
>>>>
>>>> Now it seems to display correct (16/9) DAR for sample encoded directly 
>>>> from hdv. (but for speed I tested vp8/webm, not av1/webm)
>>>>
>>>>
From d3dd30c3d78cdd945c0f6ba78fd2eb264ada69c7 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Sat, 30 Dec 2023 20:26:24 +0300
Subject: [PATCH 1/3] Set also sample aspect ratio for encoded ffmpeg stream

---
 cinelerra-5.1/cinelerra/ffmpeg.C | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index e95cc87e..870cdd3c 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -3037,6 +3037,7 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
 				frame_rate.num, frame_rate.den, INT_MAX);
 			ctx->framerate = (AVRational) { frame_rate.num, frame_rate.den };
 			ctx->time_base = (AVRational) { frame_rate.den, frame_rate.num };
+			st->sample_aspect_ratio = to_sample_aspect_ratio(asset);
 			st->avg_frame_rate = frame_rate;
 			st->time_base = ctx->time_base;
 			vid->writing = -1;
-- 
2.35.8

From 00021cec83707ee720035102ae291e8d8a16c447 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Fri, 5 Jan 2024 03:51:57 +0300
Subject: [PATCH 2/3] Guard ffmpeg.C stream sample aspect ratio only for few
 formats

---
 cinelerra-5.1/cinelerra/ffmpeg.C | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index 870cdd3c..cfaa30b4 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -3037,7 +3037,13 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
 				frame_rate.num, frame_rate.den, INT_MAX);
 			ctx->framerate = (AVRational) { frame_rate.num, frame_rate.den };
 			ctx->time_base = (AVRational) { frame_rate.den, frame_rate.num };
+			printf("ofmt name %s \n", format_name);
+			if(!strcmp(format_name, "webm") || !strcmp(format_name, "mkv") || !strcmp(format_name, "mov") ||
+			!strcmp(format_name, "qt") || !strcmp(format_name, "mp4") || !strcmp(format_name, "avi"))
+			{
+			if (to_sample_aspect_ratio(asset).den > 0)
 			st->sample_aspect_ratio = to_sample_aspect_ratio(asset);
+			}
 			st->avg_frame_rate = frame_rate;
 			st->time_base = ctx->time_base;
 			vid->writing = -1;
-- 
2.35.8

From 2de88df0278fe40e2e75957179f2962c89e03cf8 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Fri, 5 Jan 2024 04:53:23 +0300
Subject: [PATCH 3/3] fix guard for stream sample aspect ratio for more fmts

---
 cinelerra-5.1/cinelerra/ffmpeg.C | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index cfaa30b4..12275eb2 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -3038,8 +3038,9 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
 			ctx->framerate = (AVRational) { frame_rate.num, frame_rate.den };
 			ctx->time_base = (AVRational) { frame_rate.den, frame_rate.num };
 			printf("ofmt name %s \n", format_name);
-			if(!strcmp(format_name, "webm") || !strcmp(format_name, "mkv") || !strcmp(format_name, "mov") ||
-			!strcmp(format_name, "qt") || !strcmp(format_name, "mp4") || !strcmp(format_name, "avi"))
+			if(!strcmp(format_name, "webm") || !strcmp(format_name, "matroska") || !strcmp(format_name, "mov") ||
+			!strcmp(format_name, "qt") || !strcmp(format_name, "mp4") || !strcmp(format_name, "avi") ||
+			!strcmp(format_name, "dv") || !strcmp(format_name, "yuv4mpegpipe"))
 			{
 			if (to_sample_aspect_ratio(asset).den > 0)
 			st->sample_aspect_ratio = to_sample_aspect_ratio(asset);
-- 
2.35.8

-- 
Cin mailing list
[email protected]
https://lists.cinelerra-gg.org/mailman/listinfo/cin

Reply via email to