How to use ffmpeg in batch mode?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use ffmpeg in batch mode?

FFmpeg-users mailing list
I have been trying to convert a bunch of mkv files to mp4 using ffmpeg in batch mode via a .bat file but I can't get it right.
I've followed a number of suggested commands from various hits I've got on google but none of them work.
Don't need anything fancy.  Just a basic convert from mkv to mp4 if anyone can help?


-------------------------------------
Remember Brandolini's Law and look around.

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to use ffmpeg in batch mode?

Michael Koch
Am 20.10.2019 um 23:56 schrieb arthur brogard via ffmpeg-user:
> I have been trying to convert a bunch of mkv files to mp4 using ffmpeg in batch mode via a .bat file but I can't get it right.
> I've followed a number of suggested commands from various hits I've got on google but none of them work.
> Don't need anything fancy.  Just a basic convert from mkv to mp4 if anyone can help?

I haven't tested it, but I thing this (Windows) batch file should work:


for %%f in (*.mkv) do call :for_body %%f
goto :the_end

:for_body
set IN=%1
set OUT=%IN:mkv=mp4%
ffmpeg -i %IN% -y %OUT%
exit /b

:the_end
pause


You find a similar (tested and working) example in my book on page 88:
http://www.astro-electronic.de/FFmpeg_Book.pdf

Michael
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to use ffmpeg in batch mode?

Goran Obal
Hi.

If you are only changing the container and don't want to transcode the
contents, be sure to add -c copy in the ffmpeg line of the example (haven't
tested it but it seems fine), so it looks like this:
ffmpeg -i %IN% -y -c copy %OUT%

Br.

On Mon, Oct 21, 2019 at 9:14 AM Michael Koch <[hidden email]>
wrote:

> Am 20.10.2019 um 23:56 schrieb arthur brogard via ffmpeg-user:
> > I have been trying to convert a bunch of mkv files to mp4 using ffmpeg
> in batch mode via a .bat file but I can't get it right.
> > I've followed a number of suggested commands from various hits I've got
> on google but none of them work.
> > Don't need anything fancy.  Just a basic convert from mkv to mp4 if
> anyone can help?
>
> I haven't tested it, but I thing this (Windows) batch file should work:
>
>
> for %%f in (*.mkv) do call :for_body %%f
> goto :the_end
>
> :for_body
> set IN=%1
> set OUT=%IN:mkv=mp4%
> ffmpeg -i %IN% -y %OUT%
> exit /b
>
> :the_end
> pause
>
>
> You find a similar (tested and working) example in my book on page 88:
> http://www.astro-electronic.de/FFmpeg_Book.pdf
>
> Michael
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to use ffmpeg in batch mode?

Michael Koch
In reply to this post by Michael Koch

>
> set OUT=%IN:mkv=mp4%

please note that this renaming will give unexpected results if "mkv" is
also part of the filename, for example
aamkv.mkv will be renamed to
aamp4.mp4

If someone knows a solution to this problem, please let us know.

Michael
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to use ffmpeg in batch mode?

Goran Obal
Michael, you could use this:
%~ni <- this means the filename without the extension, so instead of
renaming, just use:
ffmpeg -i %1 -y %~n1
or
ffmpeg -i %1 -y -c copy %~n1

On Mon, Oct 21, 2019 at 10:28 AM Michael Koch <[hidden email]>
wrote:

>
> >
> > set OUT=%IN:mkv=mp4%
>
> please note that this renaming will give unexpected results if "mkv" is
> also part of the filename, for example
> aamkv.mkv will be renamed to
> aamp4.mp4
>
> If someone knows a solution to this problem, please let us know.
>
> Michael
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to use ffmpeg in batch mode?

Goran Obal
Sorry, forgot the extensions for output. ;)
ffmpeg -i %1 -y %~n1.mkv
or
ffmpeg -i %1 -y -c copy %~n1.mkv

On Mon, Oct 21, 2019 at 10:33 AM Goran Obal <[hidden email]> wrote:

> Michael, you could use this:
> %~ni <- this means the filename without the extension, so instead of
> renaming, just use:
> ffmpeg -i %1 -y %~n1
> or
> ffmpeg -i %1 -y -c copy %~n1
>
> On Mon, Oct 21, 2019 at 10:28 AM Michael Koch <[hidden email]>
> wrote:
>
>>
>> >
>> > set OUT=%IN:mkv=mp4%
>>
>> please note that this renaming will give unexpected results if "mkv" is
>> also part of the filename, for example
>> aamkv.mkv will be renamed to
>> aamp4.mp4
>>
>> If someone knows a solution to this problem, please let us know.
>>
>> Michael
>> _______________________________________________
>> ffmpeg-user mailing list
>> [hidden email]
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>
>> To unsubscribe, visit link above, or email
>> [hidden email] with subject "unsubscribe".
>
>
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to use ffmpeg in batch mode?

Goran Obal
Silly me, it's the other way around (mkv to mp4)...
ffmpeg -i %1 -y %~n1.mp4
or
ffmpeg -i %1 -y -c copy %~n1.mp4

On Mon, Oct 21, 2019 at 10:34 AM Goran Obal <[hidden email]> wrote:

> Sorry, forgot the extensions for output. ;)
> ffmpeg -i %1 -y %~n1.mkv
> or
> ffmpeg -i %1 -y -c copy %~n1.mkv
>
> On Mon, Oct 21, 2019 at 10:33 AM Goran Obal <[hidden email]> wrote:
>
>> Michael, you could use this:
>> %~ni <- this means the filename without the extension, so instead of
>> renaming, just use:
>> ffmpeg -i %1 -y %~n1
>> or
>> ffmpeg -i %1 -y -c copy %~n1
>>
>> On Mon, Oct 21, 2019 at 10:28 AM Michael Koch <
>> [hidden email]> wrote:
>>
>>>
>>> >
>>> > set OUT=%IN:mkv=mp4%
>>>
>>> please note that this renaming will give unexpected results if "mkv" is
>>> also part of the filename, for example
>>> aamkv.mkv will be renamed to
>>> aamp4.mp4
>>>
>>> If someone knows a solution to this problem, please let us know.
>>>
>>> Michael
>>> _______________________________________________
>>> ffmpeg-user mailing list
>>> [hidden email]
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>>>
>>> To unsubscribe, visit link above, or email
>>> [hidden email] with subject "unsubscribe".
>>
>>
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to use ffmpeg in batch mode?

FFmpeg-users mailing list
 Personally I tend to do this sort of thing with JScript on Windows. It's not the loveliest interpreter, but then at least you have something approaching a real programming language to do all your string manipulation!
P
    On Monday, 21 October 2019, 09:45:12 BST, Goran Obal <[hidden email]> wrote:  
 
 Silly me, it's the other way around (mkv to mp4)...
ffmpeg -i %1 -y %~n1.mp4
or
ffmpeg -i %1 -y -c copy %~n1.mp4  
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to use ffmpeg in batch mode?

FFmpeg-users mailing list
In reply to this post by Goran Obal
Thank you for that. It worked perfectly.  And thank you for the book - it looks like there's realms of good stuff in it. 

Looks like a text book to me..  probably won't be able to read it but will have to dip in and out of it to find things when I need them.

Congratulations on it... wish I'd achieved something like that...   :)
Don't understand your batch file either, though I used to write  DOS batch files all the time back then in the day... I think the command set and syntax maybe have changed a bit....
anyway....  thanks very much...
:)

-------------------------------------
Remember Brandolini's Law and look around.

 

    On Monday, 21 October 2019, 6:29:36 pm ACDT, Goran Obal <[hidden email]> wrote:  
 
 Hi.

If you are only changing the container and don't want to transcode the
contents, be sure to add -c copy in the ffmpeg line of the example (haven't
tested it but it seems fine), so it looks like this:
ffmpeg -i %IN% -y -c copy %OUT%

Br.

On Mon, Oct 21, 2019 at 9:14 AM Michael Koch <[hidden email]>
wrote:

> Am 20.10.2019 um 23:56 schrieb arthur brogard via ffmpeg-user:
> > I have been trying to convert a bunch of mkv files to mp4 using ffmpeg
> in batch mode via a .bat file but I can't get it right.
> > I've followed a number of suggested commands from various hits I've got
> on google but none of them work.
> > Don't need anything fancy.  Just a basic convert from mkv to mp4 if
> anyone can help?
>
> I haven't tested it, but I thing this (Windows) batch file should work:
>
>
> for %%f in (*.mkv) do call :for_body %%f
> goto :the_end
>
> :for_body
> set IN=%1
> set OUT=%IN:mkv=mp4%
> ffmpeg -i %IN% -y %OUT%
> exit /b
>
> :the_end
> pause
>
>
> You find a similar (tested and working) example in my book on page 88:
> http://www.astro-electronic.de/FFmpeg_Book.pdf
>
> Michael
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".  
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".