Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 428 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a batch file with the "IF" command

#1
I have created a little batch file for helping people to convert MP4 video to FLV with FFMPEG. A way to make it simple to everyone i know to use it. I was thinking the line i've put in was perfect for every situation (converting a MP4 file to FLV), but few days ago, it didn't work for a file. (audio sample to high for FLV format)

I found with the help of people a other codeline to convert it, but i don't know how to correctly integrate it, in my batch file.

There is what i use right now :

> echo "Enter the name of the file, whitout the extension" : set
> /p namefile=
>
> echo "Enter the name you what to give to the destination file" : set /p destinationfile=
>
> ffmpeg -i %namefile%.mp4 -c:v libx264 -crf 19 %destinationfile%.flv

And i want to add a "IF". Because if that doesn't work with this line, use that one :

> ffmpeg -i %namefile%.mp4 -c:v libx264 -ar 22050 -crf 28
> %destinationfile%.flv

How can i do that ?

Thank you very much for your help and if i'm unclear on something, just tell it to me and i will do my best to make it clear.

Thanks !
Reply

#2
I'm not sure if FFMPEG returns a standard error code in case of failure, but if it does, you can use the following:

ffmpeg -i %namefile%.mp4 -c:v libx264 -crf 19 %destinationfile%.flv
if not errorlevel 1 goto Done
ffmpeg -i %namefile%.mp4 -c:v libx264 -ar 22050 -crf 28 %destinationfile%.flv
:Done

If this approach doesn't work, you can check the existence of the destination file to determine further action:

ffmpeg -i %namefile%.mp4 -c:v libx264 -crf 19 %destinationfile%.flv
if exist %destinationfile%.flv goto Done
ffmpeg -i %namefile%.mp4 -c:v libx264 -ar 22050 -crf 28 %destinationfile%.flv
:Done

Hope one of these works.
Reply

#3
Similar to EitanT's first solution, but without using GOTO.

ffmpeg -i %namefile%.mp4 -c:v libx264 -crf 19 %destinationfile%.flv
if errorlevel 1 ffmpeg -i %namefile%.mp4 -c:v libx264 -ar 22050 -crf 28 %destinationfile%.flv

or<br/> ***Edited*** - *the code had gotten truncated, all fixed now*

ffmpeg -i %namefile%.mp4 -c:v libx264 -crf 19 %destinationfile%.flv||ffmpeg -i %namefile%.mp4 -c:v libx264 -ar 22050 -crf 28 %destinationfile%.flv

Similar to EitanT's second solution, but without using GOTO

ffmpeg -i %namefile%.mp4 -c:v libx264 -crf 19 %destinationfile%.flv
if not exist %destinationfile%.flv ffmpeg -i %namefile%.mp4 -c:v libx264 -ar 22050 -crf 28 %destinationfile%.flv

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through