Skip to content

Commit 226e4ba

Browse files
committed
Force stereo videos to solve issue with 5.1 sound videos
1 parent 9b959eb commit 226e4ba

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111

1212
- Upgrade to wombat 3.8.8 and other Python/JS dependencies (#249)
13+
- Force stereo videos to solve issue with 5.1 sound videos (#250)
1314

1415
## [5.1.0] - 2025-01-21
1516

Diff for: src/zimscraperlib/video/presets.py

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class VoiceMp3Low(Config):
2222
"-codec:a": "mp3", # audio codec
2323
"-ar": "44100", # audio sampling rate
2424
"-b:a": "48k", # target audio bitrate
25+
"-ac": "2", # force stereo
2526
}
2627

2728

@@ -49,6 +50,7 @@ class VideoWebmLow(Config):
4950
"-codec:a": "libvorbis", # audio codec
5051
"-b:a": "48k", # target audio bitrate
5152
"-ar": "44100", # audio sampling rate
53+
"-ac": "2", # force stereo
5254
}
5355

5456

@@ -77,6 +79,7 @@ class VideoMp4Low(Config):
7779
"-ar": "44100", # audio sampling rate
7880
"-b:a": "48k", # target audio bitrate
7981
"-movflags": "+faststart", # extra flag
82+
"-ac": "2", # force stereo
8083
}
8184

8285

@@ -101,6 +104,7 @@ class VideoWebmHigh(Config):
101104
"-codec:a": "libvorbis", # audio codec
102105
"-b:a": "48k", # target audio bitrate
103106
"-ar": "44100", # audio sampling rate
107+
"-ac": "2", # force stereo
104108
}
105109

106110

Diff for: tests/video/test_video.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def test_preset_video_webm_low():
180180
config = VideoWebmLow()
181181
assert config.VERSION == 3
182182
args = config.to_ffmpeg_args()
183-
assert len(args) == 24
183+
assert len(args) == 26
184184
options_map = [
185185
("codec:v", "libvpx-vp9"),
186186
("codec:a", "libvorbis"),
@@ -193,6 +193,7 @@ def test_preset_video_webm_low():
193193
("vf", "scale='480:trunc(ow/a/2)*2'"),
194194
("g", "240"),
195195
("speed", "4"),
196+
("ac", "2"),
196197
]
197198
for option, val in options_map:
198199
idx = args.index(f"-{option}")
@@ -213,7 +214,7 @@ def test_preset_video_webm_high():
213214
config = VideoWebmHigh()
214215
assert config.VERSION == 2
215216
args = config.to_ffmpeg_args()
216-
assert len(args) == 22
217+
assert len(args) == 24
217218
options_map = [
218219
("codec:v", "libvpx-vp9"),
219220
("codec:a", "libvorbis"),
@@ -225,6 +226,7 @@ def test_preset_video_webm_high():
225226
("qmax", "54"),
226227
("g", "240"),
227228
("speed", "1"),
229+
("ac", "2"),
228230
]
229231
for option, val in options_map:
230232
idx = args.index(f"-{option}")
@@ -245,7 +247,7 @@ def test_preset_video_mp4_low():
245247
config = VideoMp4Low()
246248
assert config.VERSION == 1
247249
args = config.to_ffmpeg_args()
248-
assert len(args) == 24
250+
assert len(args) == 26
249251
options_map = [
250252
("codec:v", "h264"),
251253
("codec:a", "aac"),
@@ -258,6 +260,7 @@ def test_preset_video_mp4_low():
258260
("qmin", "30"),
259261
("qmax", "42"),
260262
("vf", "scale='480:trunc(ow/a/2)*2'"),
263+
("ac", "2"),
261264
]
262265
for option, val in options_map:
263266
idx = args.index(f"-{option}")
@@ -303,11 +306,12 @@ def test_preset_voice_mp3_low():
303306
config = VoiceMp3Low()
304307
assert config.VERSION == 1
305308
args = config.to_ffmpeg_args()
306-
assert len(args) == 9
309+
assert len(args) == 11
307310
options_map = [
308311
("codec:a", "mp3"),
309312
("ar", "44100"),
310313
("b:a", "48k"),
314+
("ac", "2"),
311315
]
312316
for option, val in options_map:
313317
idx = args.index(f"-{option}")

0 commit comments

Comments
 (0)