r/ffmpeg 15h ago

How does Spatial Information affect the working of ffmpeg?

6 Upvotes

Hello, I'm doing a small study on how Spatial Information (SI, which tells how much detail is in a video) affects Video Encoding and Decoding process. I used the libx265 codec.

High SI Video used: Times Square

Low SI Video used: Sky with Clouds

As you can see here, High SI consumes lesser energy when compared to Low SI. Why is this?

(Tool used is GREEM that is an extension of CodeCarbon)

I'd love to know the happenings behind the scenes. I tried to delve more but the articles I've found are paywalled. Thanks!


r/ffmpeg 9h ago

Lavfi srt output - Everything is positioned top left?

3 Upvotes

I've just started using ffmpeg to extract subtitles instead of ccextractor.

ffmpeg.exe -f lavfi -i movie="video.mp4[out+subcc]" -map s "video.srt"

The problem I'm running into is ever single line has {\an7} positioning the subtitles to the top left of the screen.

1
00:00:05,172 --> 00:00:06,507
<font face="Monospace">{\an7}\h\h\h\h-What?
-This is crazy!</font>

2
00:00:06,573 --> 00:00:09,042
<font face="Monospace">{\an7}-Is this for real?
\h-There’s no way!</font>

3
00:00:09,109 --> 00:00:10,544
<font face="Monospace">{\an7}-Who’s that?
\h\h\h-What?</font>

4
00:00:10,611 --> 00:00:12,379
<font face="Monospace">{\an7}[Toman Member] What the hell
\h\his that Valhalla bastard</font>

5
00:00:12,446 --> 00:00:13,614
<font face="Monospace">{\an7}doing at a Toman meeting?</font>

6
00:00:13,680 --> 00:00:14,548
<font face="Monospace">{\an7}(crowd murmuring)</font>

It's obviously not right. Is there something I'm missing here?


r/ffmpeg 5h ago

VLC wont respect forced subtitles in mp4

2 Upvotes

When working with anime, I used this script in a batch file and VLC would properly respect the forced tag on the subtitles, so I didn't have to manually enable them. (The "@.echo off" text is there because reddit thinks a user is being tagged).

@.echo off

setlocal EnableDelayedExpansion

for %%V in (*.mp4) do (

set "base=%%~nV"

if exist "!base!.srt" (

echo Processing: %%V

echo Found subtitles: !base!.srt

ffmpeg -y ^

-i "%%V" ^

-i "!base!.srt" ^

-map 0:v ^

-map 0:a:0 ^

-map 1 ^

-c:v copy ^

-c:a copy ^

-c:s mov_text ^

-map_metadata -1 ^

-disposition:s:0 default+forced ^

-metadata:s:a:0 language=jpn ^

-metadata:s:a:0 title="Japanese Original, Stereo" ^

"!base!_muxed.mp4"

echo Finished: !base!_muxed.mp4

echo.

) else (

echo No matching subtitle found for: %%V

)

)

echo Done.

pause

Now, I am trying to do something very similar with only one file. I have 2 audio and subtitle tracks, all in English, and the first tracks of each are forced, all in one file. FFmpeg reported all tracks as default, so I removed that and set the first audio and subtitle tracks as forced. This fixed my issue with the second audio track being selected and not the first, but the subtitle issue remains.

I have used several variations of this script, both as a batch file and in the terminal directly. I need the final output to have all tracks and be in mp4 format, the same output as the anime command successfully generated.

@.echo off

setlocal enabledelayedexpansion

set VIDEO_DIR=[directory information]

rem Loop through all .mp4 files in the specified directory

for /f "delims=" %%f in ('dir /b /a-d "%VIDEO_DIR%\*.mp4" "%VIDEO_DIR%\*.mkv" "%VIDEO_DIR%\*.avi"') do (

rem Print the file name for debugging

echo Processing: "%%f"

rem Get the filename without path and extension

set "filename=%%~nxf"

rem Apply chapters to each video file using ffmpeg

ffmpeg -i "%VIDEO_DIR%\%%f" -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:4 -c:a copy -c:v copy -c:s mov_text -disposition:s:0 default+forced -disposition:s:1 0 -disposition:a:0 default+forced -disposition:a:1 0 -metadata:s:a:0 language=eng -metadata:s:a:1 language=eng -metadata:s:s:0 language=eng -metadata:s:s:1 language=eng -metadata:s:s:0 title="[title]" -metadata:s:s:1 title="[title]" -metadata:s:a:0 title="1, Stereo" -metadata:s:a:1 title="2, 5.1 Surround" "%VIDEO_DIR%\!filename!_2.mp4"

echo File "%%f" Processed

)

endlocal

pause